excalibur 0.28.3 → 0.28.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitattributes +63 -63
- package/CHANGELOG.md +2003 -1955
- package/LICENSE.md +25 -25
- package/README.md +134 -134
- package/STYLEGUIDE.md +136 -136
- package/build/dist/Actions/Action/ActionSequence.js +31 -0
- package/build/dist/Actions/Action/ActionSequence.js.map +1 -0
- package/build/dist/Actions/Action/Blink.js +54 -0
- package/build/dist/Actions/Action/Blink.js.map +1 -0
- package/build/dist/Actions/Action/CallMethod.js +21 -0
- package/build/dist/Actions/Action/CallMethod.js.map +1 -0
- package/build/dist/Actions/Action/Delay.js +26 -0
- package/build/dist/Actions/Action/Delay.js.map +1 -0
- package/build/dist/Actions/Action/Die.js +22 -0
- package/build/dist/Actions/Action/Die.js.map +1 -0
- package/build/dist/Actions/Action/EaseBy.js +70 -0
- package/build/dist/Actions/Action/EaseBy.js.map +1 -0
- package/build/dist/Actions/Action/EaseTo.js +69 -0
- package/build/dist/Actions/Action/EaseTo.js.map +1 -0
- package/build/dist/Actions/Action/Fade.js +48 -0
- package/build/dist/Actions/Action/Fade.js.map +1 -0
- package/build/dist/Actions/Action/Follow.js +56 -0
- package/build/dist/Actions/Action/Follow.js.map +1 -0
- package/build/dist/Actions/Action/Meet.js +54 -0
- package/build/dist/Actions/Action/Meet.js.map +1 -0
- package/build/dist/Actions/Action/MoveBy.js +48 -0
- package/build/dist/Actions/Action/MoveBy.js.map +1 -0
- package/build/dist/Actions/Action/MoveTo.js +41 -0
- package/build/dist/Actions/Action/MoveTo.js.map +1 -0
- package/build/dist/Actions/Action/ParallelActions.js +23 -0
- package/build/dist/Actions/Action/ParallelActions.js.map +1 -0
- package/build/dist/Actions/Action/Repeat.js +31 -0
- package/build/dist/Actions/Action/Repeat.js.map +1 -0
- package/build/dist/Actions/Action/RepeatForever.js +37 -0
- package/build/dist/Actions/Action/RepeatForever.js.map +1 -0
- package/build/dist/Actions/Action/RotateBy.js +95 -0
- package/build/dist/Actions/Action/RotateBy.js.map +1 -0
- package/build/dist/Actions/Action/RotateTo.js +91 -0
- package/build/dist/Actions/Action/RotateTo.js.map +1 -0
- package/build/dist/Actions/Action/ScaleBy.js +46 -0
- package/build/dist/Actions/Action/ScaleBy.js.map +1 -0
- package/build/dist/Actions/Action/ScaleTo.js +58 -0
- package/build/dist/Actions/Action/ScaleTo.js.map +1 -0
- package/build/dist/Actions/Action.js +2 -0
- package/build/dist/Actions/Action.js.map +1 -0
- package/build/dist/Actions/ActionContext.js +322 -0
- package/build/dist/Actions/ActionContext.js.map +1 -0
- package/build/dist/Actions/ActionQueue.js +87 -0
- package/build/dist/Actions/ActionQueue.js.map +1 -0
- package/build/dist/Actions/Actionable.js +2 -0
- package/build/dist/Actions/Actionable.js.map +1 -0
- package/build/dist/Actions/ActionsComponent.js +195 -0
- package/build/dist/Actions/ActionsComponent.js.map +1 -0
- package/build/dist/Actions/ActionsSystem.js +30 -0
- package/build/dist/Actions/ActionsSystem.js.map +1 -0
- package/build/dist/Actions/Index.js +26 -0
- package/build/dist/Actions/Index.js.map +1 -0
- package/build/dist/Actions/RotationType.js +27 -0
- package/build/dist/Actions/RotationType.js.map +1 -0
- package/build/dist/Actor.js +629 -0
- package/build/dist/Actor.js.map +1 -0
- package/build/dist/Camera.js +660 -0
- package/build/dist/Camera.js.map +1 -0
- package/build/dist/Collision/BoundingBox.js +415 -0
- package/build/dist/Collision/BoundingBox.js.map +1 -0
- package/build/dist/Collision/ColliderComponent.js +202 -0
- package/build/dist/Collision/ColliderComponent.js.map +1 -0
- package/build/dist/Collision/Colliders/CircleCollider.js +226 -0
- package/build/dist/Collision/Colliders/CircleCollider.js.map +1 -0
- package/build/dist/Collision/Colliders/ClosestLineJumpTable.js +211 -0
- package/build/dist/Collision/Colliders/ClosestLineJumpTable.js.map +1 -0
- package/build/dist/Collision/Colliders/Collider.js +32 -0
- package/build/dist/Collision/Colliders/Collider.js.map +1 -0
- package/build/dist/Collision/Colliders/CollisionJumpTable.js +300 -0
- package/build/dist/Collision/Colliders/CollisionJumpTable.js.map +1 -0
- package/build/dist/Collision/Colliders/EdgeCollider.js +229 -0
- package/build/dist/Collision/Colliders/EdgeCollider.js.map +1 -0
- package/build/dist/Collision/Colliders/PolygonCollider.js +556 -0
- package/build/dist/Collision/Colliders/PolygonCollider.js.map +1 -0
- package/build/dist/Collision/Colliders/SeparatingAxis.js +67 -0
- package/build/dist/Collision/Colliders/SeparatingAxis.js.map +1 -0
- package/build/dist/Collision/Colliders/Shape.js +99 -0
- package/build/dist/Collision/Colliders/Shape.js.map +1 -0
- package/build/dist/Collision/CollisionType.js +33 -0
- package/build/dist/Collision/CollisionType.js.map +1 -0
- package/build/dist/Collision/Detection/CollisionContact.js +51 -0
- package/build/dist/Collision/Detection/CollisionContact.js.map +1 -0
- package/build/dist/Collision/Detection/CollisionProcessor.js +2 -0
- package/build/dist/Collision/Detection/CollisionProcessor.js.map +1 -0
- package/build/dist/Collision/Detection/DynamicTree.js +442 -0
- package/build/dist/Collision/Detection/DynamicTree.js.map +1 -0
- package/build/dist/Collision/Detection/Pair.js +92 -0
- package/build/dist/Collision/Detection/Pair.js.map +1 -0
- package/build/dist/Collision/Detection/QuadTree.js +193 -0
- package/build/dist/Collision/Detection/QuadTree.js.map +1 -0
- package/build/dist/Collision/Group/CollisionGroup.js +3 -3
- package/build/dist/Collision/Integrator.js +25 -0
- package/build/dist/Collision/Integrator.js.map +1 -0
- package/build/dist/Collision/MotionSystem.js +35 -0
- package/build/dist/Collision/MotionSystem.js.map +1 -0
- package/build/dist/Collision/Physics.js +163 -0
- package/build/dist/Collision/Physics.js.map +1 -0
- package/build/dist/Collision/PhysicsWorld.js +10 -0
- package/build/dist/Collision/PhysicsWorld.js.map +1 -0
- package/build/dist/Collision/Side.js +51 -0
- package/build/dist/Collision/Side.js.map +1 -0
- package/build/dist/Collision/Solver/ArcadeSolver.js +154 -0
- package/build/dist/Collision/Solver/ArcadeSolver.js.map +1 -0
- package/build/dist/Collision/Solver/ContactConstraintPoint.js +87 -0
- package/build/dist/Collision/Solver/ContactConstraintPoint.js.map +1 -0
- package/build/dist/Collision/Solver/RealisticSolver.js +293 -0
- package/build/dist/Collision/Solver/RealisticSolver.js.map +1 -0
- package/build/dist/Collision/Solver/Solver.js +2 -0
- package/build/dist/Collision/Solver/Solver.js.map +1 -0
- package/build/dist/Color.js +417 -0
- package/build/dist/Color.js.map +1 -0
- package/build/dist/Configurable.js +32 -0
- package/build/dist/Configurable.js.map +1 -0
- package/build/dist/Debug/Debug.d.ts +11 -0
- package/build/dist/Debug/Debug.js +385 -0
- package/build/dist/Debug/Debug.js.map +1 -0
- package/build/dist/Debug/DebugFlags.js +40 -0
- package/build/dist/Debug/DebugFlags.js.map +1 -0
- package/build/dist/Debug/DebugSystem.js +263 -0
- package/build/dist/Debug/DebugSystem.js.map +1 -0
- package/build/dist/Debug/index.js +4 -0
- package/build/dist/Debug/index.js.map +1 -0
- package/build/dist/Deprecated.js +2 -0
- package/build/dist/Deprecated.js.map +1 -0
- package/build/dist/Engine.js +986 -0
- package/build/dist/Engine.js.map +1 -0
- package/build/dist/EntityComponentSystem/Component.js +65 -0
- package/build/dist/EntityComponentSystem/Component.js.map +1 -0
- package/build/dist/EntityComponentSystem/Components/MotionComponent.js +33 -0
- package/build/dist/EntityComponentSystem/Components/MotionComponent.js.map +1 -0
- package/build/dist/EntityComponentSystem/Components/TransformComponent.js +107 -0
- package/build/dist/EntityComponentSystem/Components/TransformComponent.js.map +1 -0
- package/build/dist/EntityComponentSystem/Entity.js +487 -0
- package/build/dist/EntityComponentSystem/Entity.js.map +1 -0
- package/build/dist/EntityComponentSystem/EntityManager.js +137 -0
- package/build/dist/EntityComponentSystem/EntityManager.js.map +1 -0
- package/build/dist/EntityComponentSystem/Query.js +90 -0
- package/build/dist/EntityComponentSystem/Query.js.map +1 -0
- package/build/dist/EntityComponentSystem/QueryManager.js +90 -0
- package/build/dist/EntityComponentSystem/QueryManager.js.map +1 -0
- package/build/dist/EntityComponentSystem/System.js +76 -0
- package/build/dist/EntityComponentSystem/System.js.map +1 -0
- package/build/dist/EntityComponentSystem/SystemManager.js +104 -0
- package/build/dist/EntityComponentSystem/SystemManager.js.map +1 -0
- package/build/dist/EntityComponentSystem/Util.js +5 -0
- package/build/dist/EntityComponentSystem/Util.js.map +1 -0
- package/build/dist/EntityComponentSystem/World.js +55 -0
- package/build/dist/EntityComponentSystem/World.js.map +1 -0
- package/build/dist/EntityComponentSystem/index.js +11 -0
- package/build/dist/EntityComponentSystem/index.js.map +1 -0
- package/build/dist/EventDispatcher.js +122 -0
- package/build/dist/EventDispatcher.js.map +1 -0
- package/build/dist/EventEmitter.js +86 -0
- package/build/dist/EventEmitter.js.map +1 -0
- package/build/dist/Events/ExEvent.js +12 -0
- package/build/dist/Events/ExEvent.js.map +1 -0
- package/build/dist/Events/MediaEvents.js +75 -0
- package/build/dist/Events/MediaEvents.js.map +1 -0
- package/build/dist/Events/PointerEvents.js +52 -0
- package/build/dist/Events/PointerEvents.js.map +1 -0
- package/build/dist/Events.js +473 -0
- package/build/dist/Events.js.map +1 -0
- package/build/dist/Flags.js +67 -0
- package/build/dist/Flags.js.map +1 -0
- package/build/dist/Graphics/Animation.js +344 -0
- package/build/dist/Graphics/Animation.js.map +1 -0
- package/build/dist/Graphics/Canvas.js +38 -0
- package/build/dist/Graphics/Canvas.js.map +1 -0
- package/build/dist/Graphics/Circle.js +48 -0
- package/build/dist/Graphics/Circle.js.map +1 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContext.js +2 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContext.js.map +1 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContext2DCanvas.js +237 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContext2DCanvas.js.map +1 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.d.ts +1 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.js +481 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.js.map +1 -0
- package/build/dist/Graphics/Context/circle-renderer/circle-renderer.frag.glsl +52 -52
- package/build/dist/Graphics/Context/circle-renderer/circle-renderer.js +174 -0
- package/build/dist/Graphics/Context/circle-renderer/circle-renderer.js.map +1 -0
- package/build/dist/Graphics/Context/circle-renderer/circle-renderer.vert.glsl +37 -37
- package/build/dist/Graphics/Context/debug-text.js +47 -0
- package/build/dist/Graphics/Context/debug-text.js.map +1 -0
- package/build/dist/Graphics/Context/draw-call.js +16 -0
- package/build/dist/Graphics/Context/draw-call.js.map +1 -0
- package/build/dist/Graphics/Context/image-renderer/image-renderer.frag.glsl +32 -32
- package/build/dist/Graphics/Context/image-renderer/image-renderer.js +246 -0
- package/build/dist/Graphics/Context/image-renderer/image-renderer.js.map +1 -0
- package/build/dist/Graphics/Context/image-renderer/image-renderer.vert.glsl +32 -32
- package/build/dist/Graphics/Context/line-renderer/line-fragment.glsl +10 -10
- package/build/dist/Graphics/Context/line-renderer/line-renderer.js +90 -0
- package/build/dist/Graphics/Context/line-renderer/line-renderer.js.map +1 -0
- package/build/dist/Graphics/Context/line-renderer/line-vertex.glsl +14 -14
- package/build/dist/Graphics/Context/material-renderer/material-renderer.js +23 -2
- package/build/dist/Graphics/Context/material-renderer/material-renderer.js.map +1 -1
- package/build/dist/Graphics/Context/material.d.ts +2 -0
- package/build/dist/Graphics/Context/material.js +72 -0
- package/build/dist/Graphics/Context/material.js.map +1 -0
- package/build/dist/Graphics/Context/point-renderer/point-fragment.glsl +19 -19
- package/build/dist/Graphics/Context/point-renderer/point-renderer.js +91 -0
- package/build/dist/Graphics/Context/point-renderer/point-renderer.js.map +1 -0
- package/build/dist/Graphics/Context/point-renderer/point-vertex.glsl +11 -11
- package/build/dist/Graphics/Context/quad-index-buffer.js +67 -0
- package/build/dist/Graphics/Context/quad-index-buffer.js.map +1 -0
- package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.frag.glsl +85 -85
- package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.js +305 -0
- package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.js.map +1 -0
- package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.vert.glsl +42 -42
- package/build/dist/Graphics/Context/render-source.js +16 -0
- package/build/dist/Graphics/Context/render-source.js.map +1 -0
- package/build/dist/Graphics/Context/render-target.js +65 -0
- package/build/dist/Graphics/Context/render-target.js.map +1 -0
- package/build/dist/Graphics/Context/renderer.js +2 -0
- package/build/dist/Graphics/Context/renderer.js.map +1 -0
- package/build/dist/Graphics/Context/screen-pass-painter/screen-fragment.glsl +13 -13
- package/build/dist/Graphics/Context/screen-pass-painter/screen-pass-painter.js +56 -0
- package/build/dist/Graphics/Context/screen-pass-painter/screen-pass-painter.js.map +1 -0
- package/build/dist/Graphics/Context/screen-pass-painter/screen-vertex.glsl +11 -11
- package/build/dist/Graphics/Context/state-stack.js +37 -0
- package/build/dist/Graphics/Context/state-stack.js.map +1 -0
- package/build/dist/Graphics/Context/texture-loader.js +109 -0
- package/build/dist/Graphics/Context/texture-loader.js.map +1 -0
- package/build/dist/Graphics/Context/transform-stack.js +30 -0
- package/build/dist/Graphics/Context/transform-stack.js.map +1 -0
- package/build/dist/Graphics/Context/vertex-buffer.js +53 -0
- package/build/dist/Graphics/Context/vertex-buffer.js.map +1 -0
- package/build/dist/Graphics/Context/webgl-util.js +79 -0
- package/build/dist/Graphics/Context/webgl-util.js.map +1 -0
- package/build/dist/Graphics/DebugGraphicsComponent.d.ts +3 -2
- package/build/dist/Graphics/DebugGraphicsComponent.js +16 -0
- package/build/dist/Graphics/DebugGraphicsComponent.js.map +1 -0
- package/build/dist/Graphics/Filtering.js +17 -0
- package/build/dist/Graphics/Filtering.js.map +1 -0
- package/build/dist/Graphics/Font.js +148 -0
- package/build/dist/Graphics/Font.js.map +1 -0
- package/build/dist/Graphics/FontCache.d.ts +1 -0
- package/build/dist/Graphics/FontCache.js +80 -0
- package/build/dist/Graphics/FontCache.js.map +1 -0
- package/build/dist/Graphics/FontCommon.js +109 -0
- package/build/dist/Graphics/FontCommon.js.map +1 -0
- package/build/dist/Graphics/FontTextInstance.js +230 -0
- package/build/dist/Graphics/FontTextInstance.js.map +1 -0
- package/build/dist/Graphics/Graphic.js +208 -0
- package/build/dist/Graphics/Graphic.js.map +1 -0
- package/build/dist/Graphics/GraphicsComponent.js +336 -0
- package/build/dist/Graphics/GraphicsComponent.js.map +1 -0
- package/build/dist/Graphics/GraphicsDiagnostics.js +9 -0
- package/build/dist/Graphics/GraphicsDiagnostics.js.map +1 -0
- package/build/dist/Graphics/GraphicsGroup.js +69 -0
- package/build/dist/Graphics/GraphicsGroup.js.map +1 -0
- package/build/dist/Graphics/GraphicsSystem.js +210 -0
- package/build/dist/Graphics/GraphicsSystem.js.map +1 -0
- package/build/dist/Graphics/ImageSource.js +124 -0
- package/build/dist/Graphics/ImageSource.js.map +1 -0
- package/build/dist/Graphics/Line.js +45 -0
- package/build/dist/Graphics/Line.js.map +1 -0
- package/build/dist/Graphics/OffscreenSystem.js +64 -0
- package/build/dist/Graphics/OffscreenSystem.js.map +1 -0
- package/build/dist/Graphics/ParallaxComponent.js +11 -0
- package/build/dist/Graphics/ParallaxComponent.js.map +1 -0
- package/build/dist/Graphics/Polygon.js +59 -0
- package/build/dist/Graphics/Polygon.js.map +1 -0
- package/build/dist/Graphics/PostProcessor/ColorBlindnessMode.js +7 -0
- package/build/dist/Graphics/PostProcessor/ColorBlindnessMode.js.map +1 -0
- package/build/dist/Graphics/PostProcessor/ColorBlindnessPostProcessor.js +52 -0
- package/build/dist/Graphics/PostProcessor/ColorBlindnessPostProcessor.js.map +1 -0
- package/build/dist/Graphics/PostProcessor/PostProcessor.js +2 -0
- package/build/dist/Graphics/PostProcessor/PostProcessor.js.map +1 -0
- package/build/dist/Graphics/PostProcessor/ScreenShader.js +59 -0
- package/build/dist/Graphics/PostProcessor/ScreenShader.js.map +1 -0
- package/build/dist/Graphics/PostProcessor/color-blind-fragment.glsl +64 -64
- package/build/dist/Graphics/Raster.js +215 -0
- package/build/dist/Graphics/Raster.js.map +1 -0
- package/build/dist/Graphics/Rectangle.js +29 -0
- package/build/dist/Graphics/Rectangle.js.map +1 -0
- package/build/dist/Graphics/Sprite.js +82 -0
- package/build/dist/Graphics/Sprite.js.map +1 -0
- package/build/dist/Graphics/SpriteFont.js +139 -0
- package/build/dist/Graphics/SpriteFont.js.map +1 -0
- package/build/dist/Graphics/SpriteSheet.js +116 -0
- package/build/dist/Graphics/SpriteSheet.js.map +1 -0
- package/build/dist/Graphics/Text.js +103 -0
- package/build/dist/Graphics/Text.js.map +1 -0
- package/build/dist/Graphics/index.js +46 -0
- package/build/dist/Graphics/index.js.map +1 -0
- package/build/dist/Id.js +8 -0
- package/build/dist/Id.js.map +1 -0
- package/build/dist/Input/CapturePointerConfig.js +5 -0
- package/build/dist/Input/CapturePointerConfig.js.map +1 -0
- package/build/dist/Input/EngineInput.js +2 -0
- package/build/dist/Input/EngineInput.js.map +1 -0
- package/build/dist/Input/Gamepad.js +422 -0
- package/build/dist/Input/Gamepad.js.map +1 -0
- package/build/dist/Input/Index.js +88 -0
- package/build/dist/Input/Index.js.map +1 -0
- package/build/dist/Input/InputMapper.js +45 -0
- package/build/dist/Input/InputMapper.js.map +1 -0
- package/build/dist/Input/Keyboard.js +348 -0
- package/build/dist/Input/Keyboard.js.map +1 -0
- package/build/dist/Input/NativePointerButton.js +12 -0
- package/build/dist/Input/NativePointerButton.js.map +1 -0
- package/build/dist/Input/PointerAbstraction.js +44 -0
- package/build/dist/Input/PointerAbstraction.js.map +1 -0
- package/build/dist/Input/PointerButton.js +12 -0
- package/build/dist/Input/PointerButton.js.map +1 -0
- package/build/dist/Input/PointerComponent.js +28 -0
- package/build/dist/Input/PointerComponent.js.map +1 -0
- package/build/dist/Input/PointerEvent.js +25 -0
- package/build/dist/Input/PointerEvent.js.map +1 -0
- package/build/dist/Input/PointerEventReceiver.js +456 -0
- package/build/dist/Input/PointerEventReceiver.js.map +1 -0
- package/build/dist/Input/PointerScope.js +16 -0
- package/build/dist/Input/PointerScope.js.map +1 -0
- package/build/dist/Input/PointerSystem.js +249 -0
- package/build/dist/Input/PointerSystem.js.map +1 -0
- package/build/dist/Input/PointerType.js +11 -0
- package/build/dist/Input/PointerType.js.map +1 -0
- package/build/dist/Input/WheelDeltaMode.js +7 -0
- package/build/dist/Input/WheelDeltaMode.js.map +1 -0
- package/build/dist/Input/WheelEvent.js +21 -0
- package/build/dist/Input/WheelEvent.js.map +1 -0
- package/build/dist/Interfaces/Audio.js +2 -0
- package/build/dist/Interfaces/Audio.js.map +1 -0
- package/build/dist/Interfaces/AudioImplementation.js +11 -0
- package/build/dist/Interfaces/AudioImplementation.js.map +1 -0
- package/build/dist/Interfaces/Clonable.js +2 -0
- package/build/dist/Interfaces/Clonable.js.map +1 -0
- package/build/dist/Interfaces/Evented.js +2 -0
- package/build/dist/Interfaces/Evented.js.map +1 -0
- package/build/dist/Interfaces/Index.js +8 -0
- package/build/dist/Interfaces/Index.js.map +1 -0
- package/build/dist/Interfaces/LifecycleEvents.js +51 -0
- package/build/dist/Interfaces/LifecycleEvents.js.map +1 -0
- package/build/dist/Interfaces/Loadable.js +2 -0
- package/build/dist/Interfaces/Loadable.js.map +1 -0
- package/build/dist/Interfaces/PointerEventHandlers.js +2 -0
- package/build/dist/Interfaces/PointerEventHandlers.js.map +1 -0
- package/build/dist/Label.js +81 -0
- package/build/dist/Label.js.map +1 -0
- package/build/dist/Loader.js +416 -0
- package/build/dist/Loader.js.map +1 -0
- package/build/dist/Math/Index.js +13 -0
- package/build/dist/Math/Index.js.map +1 -0
- package/build/dist/Math/Random.js +239 -0
- package/build/dist/Math/Random.js.map +1 -0
- package/build/dist/Math/affine-matrix.js +331 -0
- package/build/dist/Math/affine-matrix.js.map +1 -0
- package/build/dist/Math/coord-plane.js +17 -0
- package/build/dist/Math/coord-plane.js.map +1 -0
- package/build/dist/Math/global-coordinates.js +30 -0
- package/build/dist/Math/global-coordinates.js.map +1 -0
- package/build/dist/Math/line-segment.js +205 -0
- package/build/dist/Math/line-segment.js.map +1 -0
- package/build/dist/Math/matrix.js +457 -0
- package/build/dist/Math/matrix.js.map +1 -0
- package/build/dist/Math/projection.js +24 -0
- package/build/dist/Math/projection.js.map +1 -0
- package/build/dist/Math/ray.js +52 -0
- package/build/dist/Math/ray.js.map +1 -0
- package/build/dist/Math/transform.js +219 -0
- package/build/dist/Math/transform.js.map +1 -0
- package/build/dist/Math/util.js +82 -0
- package/build/dist/Math/util.js.map +1 -0
- package/build/dist/Math/vector-view.js +25 -0
- package/build/dist/Math/vector-view.js.map +1 -0
- package/build/dist/Math/vector.js +340 -0
- package/build/dist/Math/vector.js.map +1 -0
- package/build/dist/Math/watch-vector.js +26 -0
- package/build/dist/Math/watch-vector.js.map +1 -0
- package/build/dist/Particles.js +430 -0
- package/build/dist/Particles.js.map +1 -0
- package/build/dist/Polyfill.js +56 -0
- package/build/dist/Polyfill.js.map +1 -0
- package/build/dist/Resources/Gif.js +464 -0
- package/build/dist/Resources/Gif.js.map +1 -0
- package/build/dist/Resources/Index.js +4 -0
- package/build/dist/Resources/Index.js.map +1 -0
- package/build/dist/Resources/Resource.js +81 -0
- package/build/dist/Resources/Resource.js.map +1 -0
- package/build/dist/Resources/Sound/AudioContext.js +16 -0
- package/build/dist/Resources/Sound/AudioContext.js.map +1 -0
- package/build/dist/Resources/Sound/Index.js +4 -0
- package/build/dist/Resources/Sound/Index.js.map +1 -0
- package/build/dist/Resources/Sound/Sound.js +326 -0
- package/build/dist/Resources/Sound/Sound.js.map +1 -0
- package/build/dist/Resources/Sound/WebAudioInstance.js +190 -0
- package/build/dist/Resources/Sound/WebAudioInstance.js.map +1 -0
- package/build/dist/Scene.js +444 -0
- package/build/dist/Scene.js.map +1 -0
- package/build/dist/Screen.js +782 -0
- package/build/dist/Screen.js.map +1 -0
- package/build/dist/ScreenElement.js +43 -0
- package/build/dist/ScreenElement.js.map +1 -0
- package/build/dist/TileMap/IsometricEntityComponent.js +17 -0
- package/build/dist/TileMap/IsometricEntityComponent.js.map +1 -0
- package/build/dist/TileMap/IsometricEntitySystem.js +23 -0
- package/build/dist/TileMap/IsometricEntitySystem.js.map +1 -0
- package/build/dist/TileMap/IsometricMap.js +311 -0
- package/build/dist/TileMap/IsometricMap.js.map +1 -0
- package/build/dist/TileMap/TileMap.d.ts +2 -1
- package/build/dist/TileMap/TileMap.js +630 -0
- package/build/dist/TileMap/TileMap.js.map +1 -0
- package/build/dist/TileMap/index.js +5 -0
- package/build/dist/TileMap/index.js.map +1 -0
- package/build/dist/Timer.js +202 -0
- package/build/dist/Timer.js.map +1 -0
- package/build/dist/Trigger.js +94 -0
- package/build/dist/Trigger.js.map +1 -0
- package/build/dist/Util/Browser.js +66 -0
- package/build/dist/Util/Browser.js.map +1 -0
- package/build/dist/Util/Clock.js +219 -0
- package/build/dist/Util/Clock.js.map +1 -0
- package/build/dist/Util/Decorators.js +78 -0
- package/build/dist/Util/Decorators.js.map +1 -0
- package/build/dist/Util/Detector.js +167 -0
- package/build/dist/Util/Detector.js.map +1 -0
- package/build/dist/Util/DrawUtil.js +115 -0
- package/build/dist/Util/DrawUtil.js.map +1 -0
- package/build/dist/Util/EasingFunctions.js +102 -0
- package/build/dist/Util/EasingFunctions.js.map +1 -0
- package/build/dist/Util/Fps.js +47 -0
- package/build/dist/Util/Fps.js.map +1 -0
- package/build/dist/Util/Future.js +30 -0
- package/build/dist/Util/Future.js.map +1 -0
- package/build/dist/Util/IFrame.js +23 -0
- package/build/dist/Util/IFrame.js.map +1 -0
- package/build/dist/Util/Index.js +7 -0
- package/build/dist/Util/Index.js.map +1 -0
- package/build/dist/Util/Log.js +195 -0
- package/build/dist/Util/Log.js.map +1 -0
- package/build/dist/Util/Observable.js +66 -0
- package/build/dist/Util/Observable.js.map +1 -0
- package/build/dist/Util/Pool.js +74 -0
- package/build/dist/Util/Pool.js.map +1 -0
- package/build/dist/Util/Semaphore.js +55 -0
- package/build/dist/Util/Semaphore.js.map +1 -0
- package/build/dist/Util/Sound.js +22 -0
- package/build/dist/Util/Sound.js.map +1 -0
- package/build/dist/Util/StateMachine.js +79 -0
- package/build/dist/Util/StateMachine.js.map +1 -0
- package/build/dist/Util/Toaster.css +28 -28
- package/build/dist/Util/Toaster.js +84 -0
- package/build/dist/Util/Toaster.js.map +1 -0
- package/build/dist/Util/Util.d.ts +6 -0
- package/build/dist/Util/Util.js +95 -0
- package/build/dist/Util/Util.js.map +1 -0
- package/build/dist/Util/Watch.js +67 -0
- package/build/dist/Util/Watch.js.map +1 -0
- package/build/dist/Util/WebAudio.js +62 -0
- package/build/dist/Util/WebAudio.js.map +1 -0
- package/build/dist/excalibur.d.ts +2 -2
- package/build/dist/excalibur.js +389 -258
- package/build/dist/excalibur.js.map +1 -1
- package/build/dist/excalibur.min.js +1 -1
- package/build/dist/excalibur.min.js.LICENSE.txt +1 -1
- package/build/dist/excalibur.min.js.map +1 -1
- package/build/dist/index.js +81 -0
- package/build/dist/index.js.map +1 -0
- package/build/esm/Debug/Debug.d.ts +11 -0
- package/build/esm/Graphics/Context/ExcaliburGraphicsContextWebGL.d.ts +1 -0
- package/build/esm/Graphics/Context/material.d.ts +2 -0
- package/build/esm/Graphics/DebugGraphicsComponent.d.ts +3 -2
- package/build/esm/Graphics/FontCache.d.ts +1 -0
- package/build/esm/TileMap/TileMap.d.ts +2 -1
- package/build/esm/Util/Util.d.ts +6 -0
- package/build/esm/excalibur.d.ts +2 -2
- package/build/esm/excalibur.js +389 -258
- package/build/esm/excalibur.js.map +1 -1
- package/build/esm/excalibur.min.js +1 -1
- package/build/esm/excalibur.min.js.LICENSE.txt +1 -1
- package/build/esm/excalibur.min.js.map +1 -1
- package/docker-compose.yml +11 -11
- package/package.json +131 -131
- package/build/dist/Loader.css +0 -122
- package/build/nuget/Excalibur.0.28.3.nupkg +0 -0
- package/build/v0.28.3.zip +0 -0
- package/excalibur-0.28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IACI,MAAM,CAAC,MAAc,EAAE,KAAa;QACzC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QACzB,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAC/B,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACI,WAAW,CAAC,OAAe,EAAE,MAAc;QAChD,cAAc;IAChB,CAAC;IAED;;;;OAIG;IACI,YAAY,CAAC,OAAe,EAAE,MAAc;QACjD,cAAc;IAChB,CAAC;IAED;;;;;OAKG;IACI,UAAU,CAAC,MAAc,EAAE,KAAa;QAC7C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;QACvE,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAClC,CAAC;IAED;;;;;OAKG;IACI,WAAW,CAAC,MAAc,EAAE,KAAa;QAC9C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;QACzE,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC;;AAhrBD,qBAAqB;AAErB;;GAEG;AACW,cAAQ,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC,IAAI;CACpB,AAFqB,CAEpB"}
|
|
@@ -0,0 +1,660 @@
|
|
|
1
|
+
import { EasingFunctions } from './Util/EasingFunctions';
|
|
2
|
+
import { Vector, vec } from './Math/vector';
|
|
3
|
+
import { removeItemFromArray } from './Util/Util';
|
|
4
|
+
import { PreUpdateEvent, PostUpdateEvent, InitializeEvent } from './Events';
|
|
5
|
+
import { BoundingBox } from './Collision/BoundingBox';
|
|
6
|
+
import { Logger } from './Util/Log';
|
|
7
|
+
import { watchAny } from './Util/Watch';
|
|
8
|
+
import { AffineMatrix } from './Math/affine-matrix';
|
|
9
|
+
import { EventEmitter } from './EventEmitter';
|
|
10
|
+
/**
|
|
11
|
+
* Container to house convenience strategy methods
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export class StrategyContainer {
|
|
15
|
+
constructor(camera) {
|
|
16
|
+
this.camera = camera;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Creates and adds the [[LockCameraToActorStrategy]] on the current camera.
|
|
20
|
+
* @param actor The actor to lock the camera to
|
|
21
|
+
*/
|
|
22
|
+
lockToActor(actor) {
|
|
23
|
+
this.camera.addStrategy(new LockCameraToActorStrategy(actor));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates and adds the [[LockCameraToActorAxisStrategy]] on the current camera
|
|
27
|
+
* @param actor The actor to lock the camera to
|
|
28
|
+
* @param axis The axis to follow the actor on
|
|
29
|
+
*/
|
|
30
|
+
lockToActorAxis(actor, axis) {
|
|
31
|
+
this.camera.addStrategy(new LockCameraToActorAxisStrategy(actor, axis));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Creates and adds the [[ElasticToActorStrategy]] on the current camera
|
|
35
|
+
* If cameraElasticity < cameraFriction < 1.0, the behavior will be a dampened spring that will slowly end at the target without bouncing
|
|
36
|
+
* If cameraFriction < cameraElasticity < 1.0, the behavior will be an oscillating spring that will over
|
|
37
|
+
* correct and bounce around the target
|
|
38
|
+
* @param actor Target actor to elastically follow
|
|
39
|
+
* @param cameraElasticity [0 - 1.0] The higher the elasticity the more force that will drive the camera towards the target
|
|
40
|
+
* @param cameraFriction [0 - 1.0] The higher the friction the more that the camera will resist motion towards the target
|
|
41
|
+
*/
|
|
42
|
+
elasticToActor(actor, cameraElasticity, cameraFriction) {
|
|
43
|
+
this.camera.addStrategy(new ElasticToActorStrategy(actor, cameraElasticity, cameraFriction));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Creates and adds the [[RadiusAroundActorStrategy]] on the current camera
|
|
47
|
+
* @param actor Target actor to follow when it is "radius" pixels away
|
|
48
|
+
* @param radius Number of pixels away before the camera will follow
|
|
49
|
+
*/
|
|
50
|
+
radiusAroundActor(actor, radius) {
|
|
51
|
+
this.camera.addStrategy(new RadiusAroundActorStrategy(actor, radius));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Creates and adds the [[LimitCameraBoundsStrategy]] on the current camera
|
|
55
|
+
* @param box The bounding box to limit the camera to.
|
|
56
|
+
*/
|
|
57
|
+
limitCameraBounds(box) {
|
|
58
|
+
this.camera.addStrategy(new LimitCameraBoundsStrategy(box));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Camera axis enum
|
|
63
|
+
*/
|
|
64
|
+
export var Axis;
|
|
65
|
+
(function (Axis) {
|
|
66
|
+
Axis[Axis["X"] = 0] = "X";
|
|
67
|
+
Axis[Axis["Y"] = 1] = "Y";
|
|
68
|
+
})(Axis || (Axis = {}));
|
|
69
|
+
/**
|
|
70
|
+
* Lock a camera to the exact x/y position of an actor.
|
|
71
|
+
*/
|
|
72
|
+
export class LockCameraToActorStrategy {
|
|
73
|
+
constructor(target) {
|
|
74
|
+
this.target = target;
|
|
75
|
+
this.action = (target, _cam, _eng, _delta) => {
|
|
76
|
+
const center = target.center;
|
|
77
|
+
return center;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Lock a camera to a specific axis around an actor.
|
|
83
|
+
*/
|
|
84
|
+
export class LockCameraToActorAxisStrategy {
|
|
85
|
+
constructor(target, axis) {
|
|
86
|
+
this.target = target;
|
|
87
|
+
this.axis = axis;
|
|
88
|
+
this.action = (target, cam, _eng, _delta) => {
|
|
89
|
+
const center = target.center;
|
|
90
|
+
const currentFocus = cam.getFocus();
|
|
91
|
+
if (this.axis === Axis.X) {
|
|
92
|
+
return new Vector(center.x, currentFocus.y);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
return new Vector(currentFocus.x, center.y);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Using [Hook's law](https://en.wikipedia.org/wiki/Hooke's_law), elastically move the camera towards the target actor.
|
|
102
|
+
*/
|
|
103
|
+
export class ElasticToActorStrategy {
|
|
104
|
+
/**
|
|
105
|
+
* If cameraElasticity < cameraFriction < 1.0, the behavior will be a dampened spring that will slowly end at the target without bouncing
|
|
106
|
+
* If cameraFriction < cameraElasticity < 1.0, the behavior will be an oscillating spring that will over
|
|
107
|
+
* correct and bounce around the target
|
|
108
|
+
* @param target Target actor to elastically follow
|
|
109
|
+
* @param cameraElasticity [0 - 1.0] The higher the elasticity the more force that will drive the camera towards the target
|
|
110
|
+
* @param cameraFriction [0 - 1.0] The higher the friction the more that the camera will resist motion towards the target
|
|
111
|
+
*/
|
|
112
|
+
constructor(target, cameraElasticity, cameraFriction) {
|
|
113
|
+
this.target = target;
|
|
114
|
+
this.cameraElasticity = cameraElasticity;
|
|
115
|
+
this.cameraFriction = cameraFriction;
|
|
116
|
+
this.action = (target, cam, _eng, _delta) => {
|
|
117
|
+
const position = target.center;
|
|
118
|
+
let focus = cam.getFocus();
|
|
119
|
+
let cameraVel = cam.vel.clone();
|
|
120
|
+
// Calculate the stretch vector, using the spring equation
|
|
121
|
+
// F = kX
|
|
122
|
+
// https://en.wikipedia.org/wiki/Hooke's_law
|
|
123
|
+
// Apply to the current camera velocity
|
|
124
|
+
const stretch = position.sub(focus).scale(this.cameraElasticity); // stretch is X
|
|
125
|
+
cameraVel = cameraVel.add(stretch);
|
|
126
|
+
// Calculate the friction (-1 to apply a force in the opposition of motion)
|
|
127
|
+
// Apply to the current camera velocity
|
|
128
|
+
const friction = cameraVel.scale(-1).scale(this.cameraFriction);
|
|
129
|
+
cameraVel = cameraVel.add(friction);
|
|
130
|
+
// Update position by velocity deltas
|
|
131
|
+
focus = focus.add(cameraVel);
|
|
132
|
+
return focus;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
export class RadiusAroundActorStrategy {
|
|
137
|
+
/**
|
|
138
|
+
*
|
|
139
|
+
* @param target Target actor to follow when it is "radius" pixels away
|
|
140
|
+
* @param radius Number of pixels away before the camera will follow
|
|
141
|
+
*/
|
|
142
|
+
constructor(target, radius) {
|
|
143
|
+
this.target = target;
|
|
144
|
+
this.radius = radius;
|
|
145
|
+
this.action = (target, cam, _eng, _delta) => {
|
|
146
|
+
const position = target.center;
|
|
147
|
+
const focus = cam.getFocus();
|
|
148
|
+
const direction = position.sub(focus);
|
|
149
|
+
const distance = direction.size;
|
|
150
|
+
if (distance >= this.radius) {
|
|
151
|
+
const offset = distance - this.radius;
|
|
152
|
+
return focus.add(direction.normalize().scale(offset));
|
|
153
|
+
}
|
|
154
|
+
return focus;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Prevent a camera from going beyond the given camera dimensions.
|
|
160
|
+
*/
|
|
161
|
+
export class LimitCameraBoundsStrategy {
|
|
162
|
+
constructor(target) {
|
|
163
|
+
this.target = target;
|
|
164
|
+
/**
|
|
165
|
+
* Useful for limiting the camera to a [[TileMap]]'s dimensions, or a specific area inside the map.
|
|
166
|
+
*
|
|
167
|
+
* Note that this strategy does not perform any movement by itself.
|
|
168
|
+
* It only sets the camera position to within the given bounds when the camera has gone beyond them.
|
|
169
|
+
* Thus, it is a good idea to combine it with other camera strategies and set this strategy as the last one.
|
|
170
|
+
*
|
|
171
|
+
* Make sure that the camera bounds are at least as large as the viewport size.
|
|
172
|
+
* @param target The bounding box to limit the camera to
|
|
173
|
+
*/
|
|
174
|
+
this.boundSizeChecked = false; // Check and warn only once
|
|
175
|
+
this.action = (target, cam, _eng, _delta) => {
|
|
176
|
+
const focus = cam.getFocus();
|
|
177
|
+
if (!this.boundSizeChecked) {
|
|
178
|
+
if (target.bottom - target.top < _eng.drawHeight || target.right - target.left < _eng.drawWidth) {
|
|
179
|
+
Logger.getInstance().warn('Camera bounds should not be smaller than the engine viewport');
|
|
180
|
+
}
|
|
181
|
+
this.boundSizeChecked = true;
|
|
182
|
+
}
|
|
183
|
+
let focusX = focus.x;
|
|
184
|
+
let focusY = focus.y;
|
|
185
|
+
if (focus.x < target.left + _eng.halfDrawWidth) {
|
|
186
|
+
focusX = target.left + _eng.halfDrawWidth;
|
|
187
|
+
}
|
|
188
|
+
else if (focus.x > target.right - _eng.halfDrawWidth) {
|
|
189
|
+
focusX = target.right - _eng.halfDrawWidth;
|
|
190
|
+
}
|
|
191
|
+
if (focus.y < target.top + _eng.halfDrawHeight) {
|
|
192
|
+
focusY = target.top + _eng.halfDrawHeight;
|
|
193
|
+
}
|
|
194
|
+
else if (focus.y > target.bottom - _eng.halfDrawHeight) {
|
|
195
|
+
focusY = target.bottom - _eng.halfDrawHeight;
|
|
196
|
+
}
|
|
197
|
+
return vec(focusX, focusY);
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
export const CameraEvents = {
|
|
202
|
+
Initialize: 'initialize',
|
|
203
|
+
PreUpdate: 'preupdate',
|
|
204
|
+
PostUpdate: 'postupdate'
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* Cameras
|
|
208
|
+
*
|
|
209
|
+
* [[Camera]] is the base class for all Excalibur cameras. Cameras are used
|
|
210
|
+
* to move around your game and set focus. They are used to determine
|
|
211
|
+
* what is "off screen" and can be used to scale the game.
|
|
212
|
+
*
|
|
213
|
+
*/
|
|
214
|
+
export class Camera {
|
|
215
|
+
constructor() {
|
|
216
|
+
this.events = new EventEmitter();
|
|
217
|
+
this.transform = AffineMatrix.identity();
|
|
218
|
+
this.inverse = AffineMatrix.identity();
|
|
219
|
+
this._cameraStrategies = [];
|
|
220
|
+
this.strategy = new StrategyContainer(this);
|
|
221
|
+
/**
|
|
222
|
+
* Get or set current zoom of the camera, defaults to 1
|
|
223
|
+
*/
|
|
224
|
+
this._z = 1;
|
|
225
|
+
/**
|
|
226
|
+
* Get or set rate of change in zoom, defaults to 0
|
|
227
|
+
*/
|
|
228
|
+
this.dz = 0;
|
|
229
|
+
/**
|
|
230
|
+
* Get or set zoom acceleration
|
|
231
|
+
*/
|
|
232
|
+
this.az = 0;
|
|
233
|
+
/**
|
|
234
|
+
* Current rotation of the camera
|
|
235
|
+
*/
|
|
236
|
+
this.rotation = 0;
|
|
237
|
+
this._angularVelocity = 0;
|
|
238
|
+
/**
|
|
239
|
+
* Get or set the camera's position
|
|
240
|
+
*/
|
|
241
|
+
this._posChanged = false;
|
|
242
|
+
this._pos = watchAny(Vector.Zero, () => (this._posChanged = true));
|
|
243
|
+
/**
|
|
244
|
+
* Get or set the camera's velocity
|
|
245
|
+
*/
|
|
246
|
+
this.vel = Vector.Zero;
|
|
247
|
+
/**
|
|
248
|
+
* Get or set the camera's acceleration
|
|
249
|
+
*/
|
|
250
|
+
this.acc = Vector.Zero;
|
|
251
|
+
this._cameraMoving = false;
|
|
252
|
+
this._currentLerpTime = 0;
|
|
253
|
+
this._lerpDuration = 1000; // 1 second
|
|
254
|
+
this._lerpStart = null;
|
|
255
|
+
this._lerpEnd = null;
|
|
256
|
+
//camera effects
|
|
257
|
+
this._isShaking = false;
|
|
258
|
+
this._shakeMagnitudeX = 0;
|
|
259
|
+
this._shakeMagnitudeY = 0;
|
|
260
|
+
this._shakeDuration = 0;
|
|
261
|
+
this._elapsedShakeTime = 0;
|
|
262
|
+
this._xShake = 0;
|
|
263
|
+
this._yShake = 0;
|
|
264
|
+
this._isZooming = false;
|
|
265
|
+
this._zoomStart = 1;
|
|
266
|
+
this._zoomEnd = 1;
|
|
267
|
+
this._currentZoomTime = 0;
|
|
268
|
+
this._zoomDuration = 0;
|
|
269
|
+
this._zoomEasing = EasingFunctions.EaseInOutCubic;
|
|
270
|
+
this._easing = EasingFunctions.EaseInOutCubic;
|
|
271
|
+
this._halfWidth = 0;
|
|
272
|
+
this._halfHeight = 0;
|
|
273
|
+
this._viewport = null;
|
|
274
|
+
this._isInitialized = false;
|
|
275
|
+
}
|
|
276
|
+
get zoom() {
|
|
277
|
+
return this._z;
|
|
278
|
+
}
|
|
279
|
+
set zoom(val) {
|
|
280
|
+
this._z = val;
|
|
281
|
+
if (this._engine) {
|
|
282
|
+
this._halfWidth = this._engine.halfDrawWidth;
|
|
283
|
+
this._halfHeight = this._engine.halfDrawHeight;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Get or set the camera's angular velocity
|
|
288
|
+
*/
|
|
289
|
+
get angularVelocity() {
|
|
290
|
+
return this._angularVelocity;
|
|
291
|
+
}
|
|
292
|
+
set angularVelocity(value) {
|
|
293
|
+
this._angularVelocity = value;
|
|
294
|
+
}
|
|
295
|
+
get pos() {
|
|
296
|
+
return this._pos;
|
|
297
|
+
}
|
|
298
|
+
set pos(vec) {
|
|
299
|
+
this._pos = watchAny(vec, () => (this._posChanged = true));
|
|
300
|
+
this._posChanged = true;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Get the camera's x position
|
|
304
|
+
*/
|
|
305
|
+
get x() {
|
|
306
|
+
return this.pos.x;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Set the camera's x position (cannot be set when following an [[Actor]] or when moving)
|
|
310
|
+
*/
|
|
311
|
+
set x(value) {
|
|
312
|
+
if (!this._follow && !this._cameraMoving) {
|
|
313
|
+
this.pos = vec(value, this.pos.y);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Get the camera's y position
|
|
318
|
+
*/
|
|
319
|
+
get y() {
|
|
320
|
+
return this.pos.y;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Set the camera's y position (cannot be set when following an [[Actor]] or when moving)
|
|
324
|
+
*/
|
|
325
|
+
set y(value) {
|
|
326
|
+
if (!this._follow && !this._cameraMoving) {
|
|
327
|
+
this.pos = vec(this.pos.x, value);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Get or set the camera's x velocity
|
|
332
|
+
*/
|
|
333
|
+
get dx() {
|
|
334
|
+
return this.vel.x;
|
|
335
|
+
}
|
|
336
|
+
set dx(value) {
|
|
337
|
+
this.vel = vec(value, this.vel.y);
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Get or set the camera's y velocity
|
|
341
|
+
*/
|
|
342
|
+
get dy() {
|
|
343
|
+
return this.vel.y;
|
|
344
|
+
}
|
|
345
|
+
set dy(value) {
|
|
346
|
+
this.vel = vec(this.vel.x, value);
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Get or set the camera's x acceleration
|
|
350
|
+
*/
|
|
351
|
+
get ax() {
|
|
352
|
+
return this.acc.x;
|
|
353
|
+
}
|
|
354
|
+
set ax(value) {
|
|
355
|
+
this.acc = vec(value, this.acc.y);
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Get or set the camera's y acceleration
|
|
359
|
+
*/
|
|
360
|
+
get ay() {
|
|
361
|
+
return this.acc.y;
|
|
362
|
+
}
|
|
363
|
+
set ay(value) {
|
|
364
|
+
this.acc = vec(this.acc.x, value);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Returns the focal point of the camera, a new point giving the x and y position of the camera
|
|
368
|
+
*/
|
|
369
|
+
getFocus() {
|
|
370
|
+
return this.pos;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* This moves the camera focal point to the specified position using specified easing function. Cannot move when following an Actor.
|
|
374
|
+
* @param pos The target position to move to
|
|
375
|
+
* @param duration The duration in milliseconds the move should last
|
|
376
|
+
* @param [easingFn] An optional easing function ([[ex.EasingFunctions.EaseInOutCubic]] by default)
|
|
377
|
+
* @returns A [[Promise]] that resolves when movement is finished, including if it's interrupted.
|
|
378
|
+
* The [[Promise]] value is the [[Vector]] of the target position. It will be rejected if a move cannot be made.
|
|
379
|
+
*/
|
|
380
|
+
move(pos, duration, easingFn = EasingFunctions.EaseInOutCubic) {
|
|
381
|
+
if (typeof easingFn !== 'function') {
|
|
382
|
+
throw 'Please specify an EasingFunction';
|
|
383
|
+
}
|
|
384
|
+
// cannot move when following an actor
|
|
385
|
+
if (this._follow) {
|
|
386
|
+
return Promise.reject(pos);
|
|
387
|
+
}
|
|
388
|
+
// resolve existing promise, if any
|
|
389
|
+
if (this._lerpPromise && this._lerpResolve) {
|
|
390
|
+
this._lerpResolve(pos);
|
|
391
|
+
}
|
|
392
|
+
this._lerpPromise = new Promise((resolve) => {
|
|
393
|
+
this._lerpResolve = resolve;
|
|
394
|
+
});
|
|
395
|
+
this._lerpStart = this.getFocus().clone();
|
|
396
|
+
this._lerpDuration = duration;
|
|
397
|
+
this._lerpEnd = pos;
|
|
398
|
+
this._currentLerpTime = 0;
|
|
399
|
+
this._cameraMoving = true;
|
|
400
|
+
this._easing = easingFn;
|
|
401
|
+
return this._lerpPromise;
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Sets the camera to shake at the specified magnitudes for the specified duration
|
|
405
|
+
* @param magnitudeX The x magnitude of the shake
|
|
406
|
+
* @param magnitudeY The y magnitude of the shake
|
|
407
|
+
* @param duration The duration of the shake in milliseconds
|
|
408
|
+
*/
|
|
409
|
+
shake(magnitudeX, magnitudeY, duration) {
|
|
410
|
+
this._isShaking = true;
|
|
411
|
+
this._shakeMagnitudeX = magnitudeX;
|
|
412
|
+
this._shakeMagnitudeY = magnitudeY;
|
|
413
|
+
this._shakeDuration = duration;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Zooms the camera in or out by the specified scale over the specified duration.
|
|
417
|
+
* If no duration is specified, it take effect immediately.
|
|
418
|
+
* @param scale The scale of the zoom
|
|
419
|
+
* @param duration The duration of the zoom in milliseconds
|
|
420
|
+
*/
|
|
421
|
+
zoomOverTime(scale, duration = 0, easingFn = EasingFunctions.EaseInOutCubic) {
|
|
422
|
+
this._zoomPromise = new Promise((resolve) => {
|
|
423
|
+
this._zoomResolve = resolve;
|
|
424
|
+
});
|
|
425
|
+
if (duration) {
|
|
426
|
+
this._isZooming = true;
|
|
427
|
+
this._zoomEasing = easingFn;
|
|
428
|
+
this._currentZoomTime = 0;
|
|
429
|
+
this._zoomDuration = duration;
|
|
430
|
+
this._zoomStart = this.zoom;
|
|
431
|
+
this._zoomEnd = scale;
|
|
432
|
+
}
|
|
433
|
+
else {
|
|
434
|
+
this._isZooming = false;
|
|
435
|
+
this.zoom = scale;
|
|
436
|
+
return Promise.resolve(true);
|
|
437
|
+
}
|
|
438
|
+
return this._zoomPromise;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Gets the bounding box of the viewport of this camera in world coordinates
|
|
442
|
+
*/
|
|
443
|
+
get viewport() {
|
|
444
|
+
if (this._viewport) {
|
|
445
|
+
return this._viewport;
|
|
446
|
+
}
|
|
447
|
+
return new BoundingBox(0, 0, 0, 0);
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Adds a new camera strategy to this camera
|
|
451
|
+
* @param cameraStrategy Instance of an [[CameraStrategy]]
|
|
452
|
+
*/
|
|
453
|
+
addStrategy(cameraStrategy) {
|
|
454
|
+
this._cameraStrategies.push(cameraStrategy);
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Removes a camera strategy by reference
|
|
458
|
+
* @param cameraStrategy Instance of an [[CameraStrategy]]
|
|
459
|
+
*/
|
|
460
|
+
removeStrategy(cameraStrategy) {
|
|
461
|
+
removeItemFromArray(cameraStrategy, this._cameraStrategies);
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Clears all camera strategies from the camera
|
|
465
|
+
*/
|
|
466
|
+
clearAllStrategies() {
|
|
467
|
+
this._cameraStrategies.length = 0;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* It is not recommended that internal excalibur methods be overridden, do so at your own risk.
|
|
471
|
+
*
|
|
472
|
+
* Internal _preupdate handler for [[onPreUpdate]] lifecycle event
|
|
473
|
+
* @internal
|
|
474
|
+
*/
|
|
475
|
+
_preupdate(engine, delta) {
|
|
476
|
+
this.events.emit('preupdate', new PreUpdateEvent(engine, delta, this));
|
|
477
|
+
this.onPreUpdate(engine, delta);
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Safe to override onPreUpdate lifecycle event handler. Synonymous with `.on('preupdate', (evt) =>{...})`
|
|
481
|
+
*
|
|
482
|
+
* `onPreUpdate` is called directly before a scene is updated.
|
|
483
|
+
*/
|
|
484
|
+
onPreUpdate(_engine, _delta) {
|
|
485
|
+
// Overridable
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* It is not recommended that internal excalibur methods be overridden, do so at your own risk.
|
|
489
|
+
*
|
|
490
|
+
* Internal _preupdate handler for [[onPostUpdate]] lifecycle event
|
|
491
|
+
* @internal
|
|
492
|
+
*/
|
|
493
|
+
_postupdate(engine, delta) {
|
|
494
|
+
this.events.emit('postupdate', new PostUpdateEvent(engine, delta, this));
|
|
495
|
+
this.onPostUpdate(engine, delta);
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Safe to override onPostUpdate lifecycle event handler. Synonymous with `.on('preupdate', (evt) =>{...})`
|
|
499
|
+
*
|
|
500
|
+
* `onPostUpdate` is called directly after a scene is updated.
|
|
501
|
+
*/
|
|
502
|
+
onPostUpdate(_engine, _delta) {
|
|
503
|
+
// Overridable
|
|
504
|
+
}
|
|
505
|
+
get isInitialized() {
|
|
506
|
+
return this._isInitialized;
|
|
507
|
+
}
|
|
508
|
+
_initialize(_engine) {
|
|
509
|
+
if (!this.isInitialized) {
|
|
510
|
+
this._engine = _engine;
|
|
511
|
+
this._screen = _engine.screen;
|
|
512
|
+
const currentRes = this._screen.contentArea;
|
|
513
|
+
let center = vec(currentRes.width / 2, currentRes.height / 2);
|
|
514
|
+
if (!this._engine.loadingComplete) {
|
|
515
|
+
// If there was a loading screen, we peek the configured resolution
|
|
516
|
+
const res = this._screen.peekResolution();
|
|
517
|
+
if (res) {
|
|
518
|
+
center = vec(res.width / 2, res.height / 2);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
this._halfWidth = center.x;
|
|
522
|
+
this._halfHeight = center.y;
|
|
523
|
+
// If the user has not set the camera pos, apply default center screen position
|
|
524
|
+
if (!this._posChanged) {
|
|
525
|
+
this.pos = center;
|
|
526
|
+
}
|
|
527
|
+
// First frame bootstrap
|
|
528
|
+
// Ensure camera tx is correct
|
|
529
|
+
// Run update twice to ensure properties are init'd
|
|
530
|
+
this.updateTransform();
|
|
531
|
+
// Run strategies for first frame
|
|
532
|
+
this.runStrategies(_engine, _engine.clock.elapsed());
|
|
533
|
+
// Setup the first frame viewport
|
|
534
|
+
this.updateViewport();
|
|
535
|
+
// It's important to update the camera after strategies
|
|
536
|
+
// This prevents jitter
|
|
537
|
+
this.updateTransform();
|
|
538
|
+
this.onInitialize(_engine);
|
|
539
|
+
this.events.emit('initialize', new InitializeEvent(_engine, this));
|
|
540
|
+
this._isInitialized = true;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Safe to override onPostUpdate lifecycle event handler. Synonymous with `.on('preupdate', (evt) =>{...})`
|
|
545
|
+
*
|
|
546
|
+
* `onPostUpdate` is called directly after a scene is updated.
|
|
547
|
+
*/
|
|
548
|
+
onInitialize(_engine) {
|
|
549
|
+
// Overridable
|
|
550
|
+
}
|
|
551
|
+
emit(eventName, event) {
|
|
552
|
+
this.events.emit(eventName, event);
|
|
553
|
+
}
|
|
554
|
+
on(eventName, handler) {
|
|
555
|
+
return this.events.on(eventName, handler);
|
|
556
|
+
}
|
|
557
|
+
once(eventName, handler) {
|
|
558
|
+
return this.events.once(eventName, handler);
|
|
559
|
+
}
|
|
560
|
+
off(eventName, handler) {
|
|
561
|
+
this.events.off(eventName, handler);
|
|
562
|
+
}
|
|
563
|
+
runStrategies(engine, delta) {
|
|
564
|
+
for (const s of this._cameraStrategies) {
|
|
565
|
+
this.pos = s.action.call(s, s.target, this, engine, delta);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
updateViewport() {
|
|
569
|
+
// recalc viewport
|
|
570
|
+
this._viewport = new BoundingBox(this.x - this._halfWidth, this.y - this._halfHeight, this.x + this._halfWidth, this.y + this._halfHeight);
|
|
571
|
+
}
|
|
572
|
+
update(_engine, delta) {
|
|
573
|
+
this._initialize(_engine);
|
|
574
|
+
this._preupdate(_engine, delta);
|
|
575
|
+
// Update placements based on linear algebra
|
|
576
|
+
this.pos = this.pos.add(this.vel.scale(delta / 1000));
|
|
577
|
+
this.zoom += (this.dz * delta) / 1000;
|
|
578
|
+
this.vel = this.vel.add(this.acc.scale(delta / 1000));
|
|
579
|
+
this.dz += (this.az * delta) / 1000;
|
|
580
|
+
this.rotation += (this.angularVelocity * delta) / 1000;
|
|
581
|
+
if (this._isZooming) {
|
|
582
|
+
if (this._currentZoomTime < this._zoomDuration) {
|
|
583
|
+
const zoomEasing = this._zoomEasing;
|
|
584
|
+
const newZoom = zoomEasing(this._currentZoomTime, this._zoomStart, this._zoomEnd, this._zoomDuration);
|
|
585
|
+
this.zoom = newZoom;
|
|
586
|
+
this._currentZoomTime += delta;
|
|
587
|
+
}
|
|
588
|
+
else {
|
|
589
|
+
this._isZooming = false;
|
|
590
|
+
this.zoom = this._zoomEnd;
|
|
591
|
+
this._currentZoomTime = 0;
|
|
592
|
+
this._zoomResolve(true);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
if (this._cameraMoving) {
|
|
596
|
+
if (this._currentLerpTime < this._lerpDuration) {
|
|
597
|
+
const moveEasing = EasingFunctions.CreateVectorEasingFunction(this._easing);
|
|
598
|
+
const lerpPoint = moveEasing(this._currentLerpTime, this._lerpStart, this._lerpEnd, this._lerpDuration);
|
|
599
|
+
this.pos = lerpPoint;
|
|
600
|
+
this._currentLerpTime += delta;
|
|
601
|
+
}
|
|
602
|
+
else {
|
|
603
|
+
this.pos = this._lerpEnd;
|
|
604
|
+
const end = this._lerpEnd.clone();
|
|
605
|
+
this._lerpStart = null;
|
|
606
|
+
this._lerpEnd = null;
|
|
607
|
+
this._currentLerpTime = 0;
|
|
608
|
+
this._cameraMoving = false;
|
|
609
|
+
// Order matters here, resolve should be last so any chain promises have a clean slate
|
|
610
|
+
this._lerpResolve(end);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
if (this._isDoneShaking()) {
|
|
614
|
+
this._isShaking = false;
|
|
615
|
+
this._elapsedShakeTime = 0;
|
|
616
|
+
this._shakeMagnitudeX = 0;
|
|
617
|
+
this._shakeMagnitudeY = 0;
|
|
618
|
+
this._shakeDuration = 0;
|
|
619
|
+
this._xShake = 0;
|
|
620
|
+
this._yShake = 0;
|
|
621
|
+
}
|
|
622
|
+
else {
|
|
623
|
+
this._elapsedShakeTime += delta;
|
|
624
|
+
this._xShake = ((Math.random() * this._shakeMagnitudeX) | 0) + 1;
|
|
625
|
+
this._yShake = ((Math.random() * this._shakeMagnitudeY) | 0) + 1;
|
|
626
|
+
}
|
|
627
|
+
this.runStrategies(_engine, delta);
|
|
628
|
+
this.updateViewport();
|
|
629
|
+
// It's important to update the camera after strategies
|
|
630
|
+
// This prevents jitter
|
|
631
|
+
this.updateTransform();
|
|
632
|
+
this._postupdate(_engine, delta);
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* Applies the relevant transformations to the game canvas to "move" or apply effects to the Camera
|
|
636
|
+
* @param ctx Canvas context to apply transformations
|
|
637
|
+
*/
|
|
638
|
+
draw(ctx) {
|
|
639
|
+
ctx.multiply(this.transform);
|
|
640
|
+
}
|
|
641
|
+
updateTransform() {
|
|
642
|
+
// center the camera
|
|
643
|
+
const newCanvasWidth = this._screen.resolution.width / this.zoom;
|
|
644
|
+
const newCanvasHeight = this._screen.resolution.height / this.zoom;
|
|
645
|
+
const cameraPos = vec(-this.x + newCanvasWidth / 2 + this._xShake, -this.y + newCanvasHeight / 2 + this._yShake);
|
|
646
|
+
// Calculate camera transform
|
|
647
|
+
this.transform.reset();
|
|
648
|
+
this.transform.scale(this.zoom, this.zoom);
|
|
649
|
+
// rotate about the focus
|
|
650
|
+
this.transform.translate(newCanvasWidth / 2, newCanvasHeight / 2);
|
|
651
|
+
this.transform.rotate(this.rotation);
|
|
652
|
+
this.transform.translate(-newCanvasWidth / 2, -newCanvasHeight / 2);
|
|
653
|
+
this.transform.translate(cameraPos.x, cameraPos.y);
|
|
654
|
+
this.transform.inverse(this.inverse);
|
|
655
|
+
}
|
|
656
|
+
_isDoneShaking() {
|
|
657
|
+
return !this._isShaking || this._elapsedShakeTime >= this._shakeDuration;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
//# sourceMappingURL=Camera.js.map
|