excalibur 0.25.2 → 0.25.3
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/CHANGELOG.md +7 -2
- package/build/dist/Actions/Action/Blink.js +51 -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 +25 -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/EaseTo.js +69 -0
- package/build/dist/Actions/Action/EaseTo.js.map +1 -0
- package/build/dist/Actions/Action/Fade.js +46 -0
- package/build/dist/Actions/Action/Fade.js.map +1 -0
- package/build/dist/Actions/Action/Follow.js +55 -0
- package/build/dist/Actions/Action/Follow.js.map +1 -0
- package/build/dist/Actions/Action/Meet.js +52 -0
- package/build/dist/Actions/Action/Meet.js.map +1 -0
- package/build/dist/Actions/Action/MoveBy.js +47 -0
- package/build/dist/Actions/Action/MoveBy.js.map +1 -0
- package/build/dist/Actions/Action/MoveTo.js +40 -0
- package/build/dist/Actions/Action/MoveTo.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 +91 -0
- package/build/dist/Actions/Action/RotateBy.js.map +1 -0
- package/build/dist/Actions/Action/RotateTo.js +90 -0
- package/build/dist/Actions/Action/RotateTo.js.map +1 -0
- package/build/dist/Actions/Action/ScaleBy.js +45 -0
- package/build/dist/Actions/Action/ScaleBy.js.map +1 -0
- package/build/dist/Actions/Action/ScaleTo.js +56 -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 +305 -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 +198 -0
- package/build/dist/Actions/ActionsComponent.js.map +1 -0
- package/build/dist/Actions/ActionsSystem.js +18 -0
- package/build/dist/Actions/ActionsSystem.js.map +1 -0
- package/build/dist/Actions/Index.js +22 -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 +831 -0
- package/build/dist/Actor.js.map +1 -0
- package/build/dist/Camera.js +663 -0
- package/build/dist/Camera.js.map +1 -0
- package/build/dist/Class.js +48 -0
- package/build/dist/Class.js.map +1 -0
- package/build/dist/Collision/BodyComponent.js +351 -0
- package/build/dist/Collision/BodyComponent.js.map +1 -0
- package/build/dist/Collision/BoundingBox.js +361 -0
- package/build/dist/Collision/BoundingBox.js.map +1 -0
- package/build/dist/Collision/ColliderComponent.js +198 -0
- package/build/dist/Collision/ColliderComponent.js.map +1 -0
- package/build/dist/Collision/Colliders/CircleCollider.js +264 -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 +26 -0
- package/build/dist/Collision/Colliders/Collider.js.map +1 -0
- package/build/dist/Collision/Colliders/CollisionJumpTable.js +301 -0
- package/build/dist/Collision/Colliders/CollisionJumpTable.js.map +1 -0
- package/build/dist/Collision/Colliders/CompositeCollider.js +232 -0
- package/build/dist/Collision/Colliders/CompositeCollider.js.map +1 -0
- package/build/dist/Collision/Colliders/EdgeCollider.js +253 -0
- package/build/dist/Collision/Colliders/EdgeCollider.js.map +1 -0
- package/build/dist/Collision/Colliders/PolygonCollider.js +389 -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 +102 -0
- package/build/dist/Collision/Colliders/Shape.js.map +1 -0
- package/build/dist/Collision/CollisionSystem.js +116 -0
- package/build/dist/Collision/CollisionSystem.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 +46 -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/DynamicTreeCollisionProcessor.js +211 -0
- package/build/dist/Collision/Detection/DynamicTreeCollisionProcessor.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/Group/CollisionGroup.js +114 -0
- package/build/dist/Collision/Group/CollisionGroup.js.map +1 -0
- package/build/dist/Collision/Group/CollisionGroupManager.js +52 -0
- package/build/dist/Collision/Group/CollisionGroupManager.js.map +1 -0
- package/build/dist/Collision/Index.js +29 -0
- package/build/dist/Collision/Index.js.map +1 -0
- package/build/dist/Collision/Integrator.js +11 -0
- package/build/dist/Collision/Integrator.js.map +1 -0
- package/build/dist/Collision/MotionSystem.js +42 -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/Side.js +51 -0
- package/build/dist/Collision/Side.js.map +1 -0
- package/build/dist/Collision/Solver/ArcadeSolver.js +101 -0
- package/build/dist/Collision/Solver/ArcadeSolver.js.map +1 -0
- package/build/dist/Collision/Solver/ContactConstraintPoint.js +83 -0
- package/build/dist/Collision/Solver/ContactConstraintPoint.js.map +1 -0
- package/build/dist/Collision/Solver/RealisticSolver.js +248 -0
- package/build/dist/Collision/Solver/RealisticSolver.js.map +1 -0
- package/build/dist/Collision/Solver/Solver.js +37 -0
- package/build/dist/Collision/Solver/Solver.js.map +1 -0
- package/build/dist/Color.js +461 -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.js +375 -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 +251 -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/Drawing/Animation.js +294 -0
- package/build/dist/Drawing/Animation.js.map +1 -0
- package/build/dist/Drawing/CanvasDrawComponent.js +16 -0
- package/build/dist/Drawing/CanvasDrawComponent.js.map +1 -0
- package/build/dist/Drawing/CanvasDrawingSystem.js +95 -0
- package/build/dist/Drawing/CanvasDrawingSystem.js.map +1 -0
- package/build/dist/Drawing/Index.js +10 -0
- package/build/dist/Drawing/Index.js.map +1 -0
- package/build/dist/Drawing/Polygon.js +139 -0
- package/build/dist/Drawing/Polygon.js.map +1 -0
- package/build/dist/Drawing/Sprite.js +355 -0
- package/build/dist/Drawing/Sprite.js.map +1 -0
- package/build/dist/Drawing/SpriteEffects.js +246 -0
- package/build/dist/Drawing/SpriteEffects.js.map +1 -0
- package/build/dist/Drawing/SpriteSheet.js +413 -0
- package/build/dist/Drawing/SpriteSheet.js.map +1 -0
- package/build/dist/Drawing/Texture.js +69 -0
- package/build/dist/Drawing/Texture.js.map +1 -0
- package/build/dist/Engine.d.ts +4 -1
- package/build/dist/Engine.js +985 -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 +249 -0
- package/build/dist/EntityComponentSystem/Components/TransformComponent.js.map +1 -0
- package/build/dist/EntityComponentSystem/Entity.js +452 -0
- package/build/dist/EntityComponentSystem/Entity.js.map +1 -0
- package/build/dist/EntityComponentSystem/EntityManager.js +128 -0
- package/build/dist/EntityComponentSystem/EntityManager.js.map +1 -0
- package/build/dist/EntityComponentSystem/Query.js +91 -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 +102 -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 +114 -0
- package/build/dist/EventDispatcher.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 +497 -0
- package/build/dist/Events.js.map +1 -0
- package/build/dist/Flags.js +90 -0
- package/build/dist/Flags.js.map +1 -0
- package/build/dist/Graphics/Animation.js +310 -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 +47 -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 +207 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContext2DCanvas.js.map +1 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.js +331 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.js.map +1 -0
- package/build/dist/Graphics/Context/circle-renderer/circle-renderer.js +160 -0
- package/build/dist/Graphics/Context/circle-renderer/circle-renderer.js.map +1 -0
- 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/image-renderer/image-renderer.js +209 -0
- package/build/dist/Graphics/Context/image-renderer/image-renderer.js.map +1 -0
- package/build/dist/Graphics/Context/line-renderer/line-renderer.js +87 -0
- package/build/dist/Graphics/Context/line-renderer/line-renderer.js.map +1 -0
- package/build/dist/Graphics/Context/point-renderer/point-renderer.js +82 -0
- package/build/dist/Graphics/Context/point-renderer/point-renderer.js.map +1 -0
- package/build/dist/Graphics/Context/quad-index-buffer.js +69 -0
- package/build/dist/Graphics/Context/quad-index-buffer.js.map +1 -0
- package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.js +272 -0
- package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.js.map +1 -0
- 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-pass-painter.js +53 -0
- package/build/dist/Graphics/Context/screen-pass-painter/screen-pass-painter.js.map +1 -0
- package/build/dist/Graphics/Context/shader.js +236 -0
- package/build/dist/Graphics/Context/shader.js.map +1 -0
- package/build/dist/Graphics/Context/state-stack.js +27 -0
- package/build/dist/Graphics/Context/state-stack.js.map +1 -0
- package/build/dist/Graphics/Context/texture-loader.d.ts +8 -0
- package/build/dist/Graphics/Context/texture-loader.js +121 -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 +45 -0
- package/build/dist/Graphics/Context/vertex-buffer.js.map +1 -0
- package/build/dist/Graphics/Context/vertex-layout.js +93 -0
- package/build/dist/Graphics/Context/vertex-layout.js.map +1 -0
- package/build/dist/Graphics/Context/webgl-adapter.js +19 -0
- package/build/dist/Graphics/Context/webgl-adapter.js.map +1 -0
- package/build/dist/Graphics/Context/webgl-util.js +105 -0
- package/build/dist/Graphics/Context/webgl-util.js.map +1 -0
- package/build/dist/Graphics/DebugGraphicsComponent.js +15 -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 +293 -0
- package/build/dist/Graphics/Font.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/Graphic.js +200 -0
- package/build/dist/Graphics/Graphic.js.map +1 -0
- package/build/dist/Graphics/GraphicsComponent.js +290 -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 +153 -0
- package/build/dist/Graphics/GraphicsSystem.js.map +1 -0
- package/build/dist/Graphics/ImageSource.js +116 -0
- package/build/dist/Graphics/ImageSource.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 +56 -0
- package/build/dist/Graphics/PostProcessor/ScreenShader.js.map +1 -0
- package/build/dist/Graphics/Raster.js +207 -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 +103 -0
- package/build/dist/Graphics/Sprite.js.map +1 -0
- package/build/dist/Graphics/SpriteFont.js +120 -0
- package/build/dist/Graphics/SpriteFont.js.map +1 -0
- package/build/dist/Graphics/SpriteSheet.js +115 -0
- package/build/dist/Graphics/SpriteSheet.js.map +1 -0
- package/build/dist/Graphics/Text.js +94 -0
- package/build/dist/Graphics/Text.js.map +1 -0
- package/build/dist/Graphics/index.js +42 -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 +358 -0
- package/build/dist/Input/Gamepad.js.map +1 -0
- package/build/dist/Input/Index.js +22 -0
- package/build/dist/Input/Index.js.map +1 -0
- package/build/dist/Input/Keyboard.js +267 -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 +41 -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 +414 -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 +217 -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/Drawable.js +2 -0
- package/build/dist/Interfaces/Drawable.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 +10 -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/Interfaces/Trait.js +2 -0
- package/build/dist/Interfaces/Trait.js.map +1 -0
- package/build/dist/Label.js +273 -0
- package/build/dist/Label.js.map +1 -0
- package/build/dist/Loader.js +367 -0
- package/build/dist/Loader.js.map +1 -0
- package/build/dist/Math/Index.js +10 -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/global-coordinates.js +30 -0
- package/build/dist/Math/global-coordinates.js.map +1 -0
- package/build/dist/Math/line.js +194 -0
- package/build/dist/Math/line.js.map +1 -0
- package/build/dist/Math/matrix.js +446 -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/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 +326 -0
- package/build/dist/Math/vector.js.map +1 -0
- package/build/dist/Particles.js +449 -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/Promises.js +205 -0
- package/build/dist/Promises.js.map +1 -0
- package/build/dist/Resources/Gif.js +479 -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 +74 -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 +240 -0
- package/build/dist/Resources/Sound/Sound.js.map +1 -0
- package/build/dist/Resources/Sound/WebAudioInstance.js +160 -0
- package/build/dist/Resources/Sound/WebAudioInstance.js.map +1 -0
- package/build/dist/Scene.js +458 -0
- package/build/dist/Scene.js.map +1 -0
- package/build/dist/Screen.js +634 -0
- package/build/dist/Screen.js.map +1 -0
- package/build/dist/ScreenElement.js +29 -0
- package/build/dist/ScreenElement.js.map +1 -0
- package/build/dist/TileMap.js +488 -0
- package/build/dist/TileMap.js.map +1 -0
- package/build/dist/Timer.js +198 -0
- package/build/dist/Timer.js.map +1 -0
- package/build/dist/Traits/Index.js +5 -0
- package/build/dist/Traits/Index.js.map +1 -0
- package/build/dist/Traits/OffscreenCulling.js +35 -0
- package/build/dist/Traits/OffscreenCulling.js.map +1 -0
- package/build/dist/Trigger.js +113 -0
- package/build/dist/Trigger.js.map +1 -0
- package/build/dist/Util/Actors.js +19 -0
- package/build/dist/Util/Actors.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/CullingBox.js +104 -0
- package/build/dist/Util/CullingBox.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 +117 -0
- package/build/dist/Util/DrawUtil.js.map +1 -0
- package/build/dist/Util/EasingFunctions.js +118 -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/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 +60 -0
- package/build/dist/Util/Observable.js.map +1 -0
- package/build/dist/Util/Pool.js +66 -0
- package/build/dist/Util/Pool.js.map +1 -0
- package/build/dist/Util/SortedList.js +261 -0
- package/build/dist/Util/SortedList.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/Util.js +294 -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.js +101 -22
- 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 +74 -0
- package/build/dist/index.js.map +1 -0
- package/build/esm/Engine.d.ts +4 -1
- package/build/esm/Graphics/Context/texture-loader.d.ts +8 -0
- package/build/esm/excalibur.js +101 -22
- 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/package.json +23 -22
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { Vector, vec } from '../Math/vector';
|
|
2
|
+
import { BoundingBox } from '../Collision/BoundingBox';
|
|
3
|
+
import { Matrix } from '..';
|
|
4
|
+
import { watch } from '../Util/Watch';
|
|
5
|
+
/**
|
|
6
|
+
* A Graphic is the base Excalibur primitive for something that can be drawn to the [[ExcaliburGraphicsContext]].
|
|
7
|
+
* [[Sprite]], [[Animation]], [[GraphicsGroup]], [[Canvas]], [[Rectangle]], [[Circle]], and [[Polygon]] all derive from the
|
|
8
|
+
* [[Graphic]] abstract class.
|
|
9
|
+
*
|
|
10
|
+
* Implementors of a Graphic must override the abstract [[Graphic._drawImage]] method to render an image to the graphics context. Graphic
|
|
11
|
+
* handles all the position, rotation, and scale transformations in [[Graphic._preDraw]] and [[Graphic._postDraw]]
|
|
12
|
+
*/
|
|
13
|
+
export class Graphic {
|
|
14
|
+
constructor(options) {
|
|
15
|
+
var _a, _b, _c, _d, _e, _f;
|
|
16
|
+
this.id = Graphic._ID++;
|
|
17
|
+
this.transform = Matrix.identity();
|
|
18
|
+
this._transformStale = true;
|
|
19
|
+
/**
|
|
20
|
+
* Gets or sets wether to show debug information about the graphic
|
|
21
|
+
*/
|
|
22
|
+
this.showDebug = false;
|
|
23
|
+
this._flipHorizontal = false;
|
|
24
|
+
this._flipVertical = false;
|
|
25
|
+
this._rotation = 0;
|
|
26
|
+
/**
|
|
27
|
+
* Gets or sets the opacity of the graphic, 0 is transparent, 1 is solid (opaque).
|
|
28
|
+
*/
|
|
29
|
+
this.opacity = 1;
|
|
30
|
+
this._scale = Vector.One;
|
|
31
|
+
this._origin = null;
|
|
32
|
+
this._width = 0;
|
|
33
|
+
this._height = 0;
|
|
34
|
+
if (options) {
|
|
35
|
+
this.origin = (_a = options.origin) !== null && _a !== void 0 ? _a : this.origin;
|
|
36
|
+
this.flipHorizontal = (_b = options.flipHorizontal) !== null && _b !== void 0 ? _b : this.flipHorizontal;
|
|
37
|
+
this.flipVertical = (_c = options.flipVertical) !== null && _c !== void 0 ? _c : this.flipVertical;
|
|
38
|
+
this.rotation = (_d = options.rotation) !== null && _d !== void 0 ? _d : this.rotation;
|
|
39
|
+
this.opacity = (_e = options.opacity) !== null && _e !== void 0 ? _e : this.opacity;
|
|
40
|
+
this.scale = (_f = options.scale) !== null && _f !== void 0 ? _f : this.scale;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
isStale() {
|
|
44
|
+
return this._transformStale;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Gets or sets the flipHorizontal, which will flip the graphic horizontally (across the y axis)
|
|
48
|
+
*/
|
|
49
|
+
get flipHorizontal() {
|
|
50
|
+
return this._flipHorizontal;
|
|
51
|
+
}
|
|
52
|
+
set flipHorizontal(value) {
|
|
53
|
+
this._flipHorizontal = value;
|
|
54
|
+
this._transformStale = true;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Gets or sets the flipVertical, which will flip the graphic vertically (across the x axis)
|
|
58
|
+
*/
|
|
59
|
+
get flipVertical() {
|
|
60
|
+
return this._flipVertical;
|
|
61
|
+
}
|
|
62
|
+
set flipVertical(value) {
|
|
63
|
+
this._flipVertical = value;
|
|
64
|
+
this._transformStale = true;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Gets or sets the rotation of the graphic
|
|
68
|
+
*/
|
|
69
|
+
get rotation() {
|
|
70
|
+
return this._rotation;
|
|
71
|
+
}
|
|
72
|
+
set rotation(value) {
|
|
73
|
+
this._rotation = value;
|
|
74
|
+
this._transformStale = true;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Gets or sets the scale of the graphic, this affects the width and
|
|
78
|
+
*/
|
|
79
|
+
get scale() {
|
|
80
|
+
return this._scale;
|
|
81
|
+
}
|
|
82
|
+
set scale(value) {
|
|
83
|
+
this._scale = watch(value, () => {
|
|
84
|
+
this._transformStale = true;
|
|
85
|
+
});
|
|
86
|
+
this._transformStale = true;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Gets or sets the origin of the graphic, if not set the center of the graphic is the origin
|
|
90
|
+
*/
|
|
91
|
+
get origin() {
|
|
92
|
+
return this._origin;
|
|
93
|
+
}
|
|
94
|
+
set origin(value) {
|
|
95
|
+
this._origin = watch(value, () => {
|
|
96
|
+
this._transformStale = true;
|
|
97
|
+
});
|
|
98
|
+
this._transformStale = true;
|
|
99
|
+
}
|
|
100
|
+
cloneGraphicOptions() {
|
|
101
|
+
return {
|
|
102
|
+
origin: this.origin ? this.origin.clone() : null,
|
|
103
|
+
flipHorizontal: this.flipHorizontal,
|
|
104
|
+
flipVertical: this.flipVertical,
|
|
105
|
+
rotation: this.rotation,
|
|
106
|
+
opacity: this.opacity,
|
|
107
|
+
scale: this.scale ? this.scale.clone() : null
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Gets or sets the width of the graphic (always positive)
|
|
112
|
+
*/
|
|
113
|
+
get width() {
|
|
114
|
+
return Math.abs(this._width * this.scale.x);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Gets or sets the height of the graphic (always positive)
|
|
118
|
+
*/
|
|
119
|
+
get height() {
|
|
120
|
+
return Math.abs(this._height * this.scale.y);
|
|
121
|
+
}
|
|
122
|
+
set width(value) {
|
|
123
|
+
this._width = value;
|
|
124
|
+
this._transformStale = true;
|
|
125
|
+
}
|
|
126
|
+
set height(value) {
|
|
127
|
+
this._height = value;
|
|
128
|
+
this._transformStale = true;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Gets a copy of the bounds in pixels occupied by the graphic on the the screen. This includes scale.
|
|
132
|
+
*/
|
|
133
|
+
get localBounds() {
|
|
134
|
+
return BoundingBox.fromDimension(this.width, this.height, Vector.Zero);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Draw the whole graphic to the context including transform
|
|
138
|
+
* @param ex The excalibur graphics context
|
|
139
|
+
* @param x
|
|
140
|
+
* @param y
|
|
141
|
+
*/
|
|
142
|
+
draw(ex, x, y) {
|
|
143
|
+
this._preDraw(ex, x, y);
|
|
144
|
+
this._drawImage(ex, 0, 0);
|
|
145
|
+
this._postDraw(ex);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Apply affine transformations to the graphics context to manipulate the graphic before [[Graphic._drawImage]]
|
|
149
|
+
* @param ex
|
|
150
|
+
* @param x
|
|
151
|
+
* @param y
|
|
152
|
+
*/
|
|
153
|
+
_preDraw(ex, x, y) {
|
|
154
|
+
ex.save();
|
|
155
|
+
ex.translate(x, y);
|
|
156
|
+
if (this._transformStale) {
|
|
157
|
+
this.transform.reset();
|
|
158
|
+
this.transform.scale(Math.abs(this.scale.x), Math.abs(this.scale.y));
|
|
159
|
+
this._rotate(this.transform);
|
|
160
|
+
this._flip(this.transform);
|
|
161
|
+
this._transformStale = false;
|
|
162
|
+
}
|
|
163
|
+
ex.multiply(this.transform);
|
|
164
|
+
// it is important to multiply alphas so graphics respect the current context
|
|
165
|
+
ex.opacity = ex.opacity * this.opacity;
|
|
166
|
+
}
|
|
167
|
+
_rotate(ex) {
|
|
168
|
+
var _a;
|
|
169
|
+
const scaleDirX = this.scale.x > 0 ? 1 : -1;
|
|
170
|
+
const scaleDirY = this.scale.y > 0 ? 1 : -1;
|
|
171
|
+
const origin = (_a = this.origin) !== null && _a !== void 0 ? _a : vec(this.width / 2, this.height / 2);
|
|
172
|
+
ex.translate(origin.x, origin.y);
|
|
173
|
+
ex.rotate(this.rotation);
|
|
174
|
+
// This is for handling direction changes 1 or -1, that way we don't have mismatched translates()
|
|
175
|
+
ex.scale(scaleDirX, scaleDirY);
|
|
176
|
+
ex.translate(-origin.x, -origin.y);
|
|
177
|
+
}
|
|
178
|
+
_flip(ex) {
|
|
179
|
+
if (this.flipHorizontal) {
|
|
180
|
+
ex.translate(this.width / this.scale.x, 0);
|
|
181
|
+
ex.scale(-1, 1);
|
|
182
|
+
}
|
|
183
|
+
if (this.flipVertical) {
|
|
184
|
+
ex.translate(0, this.height / this.scale.y);
|
|
185
|
+
ex.scale(1, -1);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Apply any additional work after [[Graphic._drawImage]] and restore the context state.
|
|
190
|
+
* @param ex
|
|
191
|
+
*/
|
|
192
|
+
_postDraw(ex) {
|
|
193
|
+
if (this.showDebug) {
|
|
194
|
+
ex.debug.drawRect(0, 0, this.width, this.height);
|
|
195
|
+
}
|
|
196
|
+
ex.restore();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
Graphic._ID = 0;
|
|
200
|
+
//# sourceMappingURL=Graphic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Graphic.js","sourceRoot":"","sources":["../../../src/engine/Graphics/Graphic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAqCtC;;;;;;;GAOG;AACH,MAAM,OAAgB,OAAO;IA0F3B,YAAY,OAAwB;;QAxF3B,OAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAErB,cAAS,GAAW,MAAM,CAAC,QAAQ,EAAE,CAAC;QACrC,oBAAe,GAAG,IAAI,CAAC;QAK/B;;WAEG;QACI,cAAS,GAAY,KAAK,CAAC;QAG1B,oBAAe,GAAG,KAAK,CAAC;QAaxB,kBAAa,GAAG,KAAK,CAAC;QAatB,cAAS,GAAG,CAAC,CAAC;QAatB;;WAEG;QACI,YAAO,GAAW,CAAC,CAAC;QAEnB,WAAM,GAAG,MAAM,CAAC,GAAG,CAAC;QAepB,YAAO,GAAkB,IAAI,CAAC;QAqC9B,WAAM,GAAW,CAAC,CAAC;QASnB,YAAO,GAAW,CAAC,CAAC;QA9B1B,IAAI,OAAO,EAAE;YACX,IAAI,CAAC,MAAM,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,CAAC,CAAC;SACjB;QAED,IAAI,IAAI,CAAC,YAAY,EAAE;YACrB,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC5C,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;SACjB;IACH,CAAC;IAED;;;OAGG;IACO,SAAS,CAAC,EAA4B;QAC9C,IAAI,IAAI,CAAC,SAAS,EAAE;YAClB,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;SAClD;QACD,EAAE,CAAC,OAAO,EAAE,CAAC;IACf,CAAC;;AA7Nc,WAAG,GAAW,CAAC,CAAC"}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { Vector, vec } from '../Math/vector';
|
|
2
|
+
import { Graphic } from './Graphic';
|
|
3
|
+
import { Logger } from '../Util/Log';
|
|
4
|
+
import { BoundingBox } from '../Collision/Index';
|
|
5
|
+
import { Component } from '../EntityComponentSystem/Component';
|
|
6
|
+
/**
|
|
7
|
+
* Type guard for checking if a Graphic HasTick (used for graphics that change over time like animations)
|
|
8
|
+
* @param graphic
|
|
9
|
+
*/
|
|
10
|
+
export function hasGraphicsTick(graphic) {
|
|
11
|
+
return !!graphic.tick;
|
|
12
|
+
}
|
|
13
|
+
export class GraphicsLayer {
|
|
14
|
+
constructor(_options, _graphics) {
|
|
15
|
+
this._options = _options;
|
|
16
|
+
this._graphics = _graphics;
|
|
17
|
+
this.graphics = [];
|
|
18
|
+
}
|
|
19
|
+
get name() {
|
|
20
|
+
return this._options.name;
|
|
21
|
+
}
|
|
22
|
+
hide(nameOrGraphic) {
|
|
23
|
+
if (!nameOrGraphic) {
|
|
24
|
+
this.graphics.length = 0;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
let gfx = null;
|
|
28
|
+
if (nameOrGraphic instanceof Graphic) {
|
|
29
|
+
gfx = nameOrGraphic;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
gfx = this._graphics.getGraphic(nameOrGraphic);
|
|
33
|
+
}
|
|
34
|
+
this.graphics = this.graphics.filter((g) => g.graphic !== gfx);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Show a graphic by name or instance at an offset, graphics are shown in the order in which `show()` is called.
|
|
39
|
+
*
|
|
40
|
+
* If `show()` is called multiple times for the same graphic it will be shown multiple times.
|
|
41
|
+
* @param nameOrGraphic
|
|
42
|
+
* @param options
|
|
43
|
+
*/
|
|
44
|
+
show(nameOrGraphic, options) {
|
|
45
|
+
options = { ...options };
|
|
46
|
+
let gfx;
|
|
47
|
+
if (nameOrGraphic instanceof Graphic) {
|
|
48
|
+
gfx = this._graphics.copyGraphics ? nameOrGraphic.clone() : nameOrGraphic;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
gfx = this._graphics.getGraphic(nameOrGraphic);
|
|
52
|
+
if (!gfx) {
|
|
53
|
+
Logger.getInstance().error(`No such graphic added to component named ${nameOrGraphic}. These named graphics are available: `, this._graphics.getNames());
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (gfx) {
|
|
57
|
+
this.graphics.push({ graphic: gfx, options });
|
|
58
|
+
return gfx;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Use a specific graphic, swap out any current graphics being shown
|
|
66
|
+
* @param nameOrGraphic
|
|
67
|
+
* @param options
|
|
68
|
+
*/
|
|
69
|
+
use(nameOrGraphic, options) {
|
|
70
|
+
options = { ...options };
|
|
71
|
+
this.hide();
|
|
72
|
+
return this.show(nameOrGraphic, options);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Current order of the layer, higher numbers are on top, lower numbers are on the bottom.
|
|
76
|
+
*
|
|
77
|
+
* For example a layer with `order = -1` would be under a layer of `order = 1`
|
|
78
|
+
*/
|
|
79
|
+
get order() {
|
|
80
|
+
return this._options.order;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Set the order of the layer, higher numbers are on top, lower numbers are on the bottom.
|
|
84
|
+
*
|
|
85
|
+
* For example a layer with `order = -1` would be under a layer of `order = 1`
|
|
86
|
+
*/
|
|
87
|
+
set order(order) {
|
|
88
|
+
this._options.order = order;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Get or set the pixel offset from the layer anchor for all graphics in the layer
|
|
92
|
+
*/
|
|
93
|
+
get offset() {
|
|
94
|
+
var _a;
|
|
95
|
+
return (_a = this._options.offset) !== null && _a !== void 0 ? _a : Vector.Zero;
|
|
96
|
+
}
|
|
97
|
+
set offset(value) {
|
|
98
|
+
this._options.offset = value;
|
|
99
|
+
}
|
|
100
|
+
get currentKeys() {
|
|
101
|
+
var _a;
|
|
102
|
+
return (_a = this.name) !== null && _a !== void 0 ? _a : 'anonymous';
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export class GraphicsLayers {
|
|
106
|
+
constructor(_component) {
|
|
107
|
+
this._component = _component;
|
|
108
|
+
this._layers = [];
|
|
109
|
+
this._layerMap = {};
|
|
110
|
+
this.default = new GraphicsLayer({ name: 'default', order: 0 }, _component);
|
|
111
|
+
this._maybeAddLayer(this.default);
|
|
112
|
+
}
|
|
113
|
+
create(options) {
|
|
114
|
+
const layer = new GraphicsLayer(options, this._component);
|
|
115
|
+
return this._maybeAddLayer(layer);
|
|
116
|
+
}
|
|
117
|
+
get(name) {
|
|
118
|
+
if (name) {
|
|
119
|
+
return this._getLayer(name);
|
|
120
|
+
}
|
|
121
|
+
return this._layers;
|
|
122
|
+
}
|
|
123
|
+
currentKeys() {
|
|
124
|
+
const graphicsLayerKeys = [];
|
|
125
|
+
for (const layer of this._layers) {
|
|
126
|
+
graphicsLayerKeys.push(layer.currentKeys);
|
|
127
|
+
}
|
|
128
|
+
return graphicsLayerKeys;
|
|
129
|
+
}
|
|
130
|
+
has(name) {
|
|
131
|
+
return name in this._layerMap;
|
|
132
|
+
}
|
|
133
|
+
_maybeAddLayer(layer) {
|
|
134
|
+
if (this._layerMap[layer.name]) {
|
|
135
|
+
// todo log warning
|
|
136
|
+
return this._layerMap[layer.name];
|
|
137
|
+
}
|
|
138
|
+
this._layerMap[layer.name] = layer;
|
|
139
|
+
this._layers.push(layer);
|
|
140
|
+
this._layers.sort((a, b) => a.order - b.order);
|
|
141
|
+
return layer;
|
|
142
|
+
}
|
|
143
|
+
_getLayer(name) {
|
|
144
|
+
return this._layerMap[name];
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Component to manage drawings, using with the position component
|
|
149
|
+
*/
|
|
150
|
+
export class GraphicsComponent extends Component {
|
|
151
|
+
constructor(options) {
|
|
152
|
+
super();
|
|
153
|
+
this.type = 'ex.graphics';
|
|
154
|
+
this._graphics = {};
|
|
155
|
+
/**
|
|
156
|
+
* Sets or gets wether any drawing should be visible in this component
|
|
157
|
+
*/
|
|
158
|
+
this.visible = true;
|
|
159
|
+
/**
|
|
160
|
+
* Sets or gets wither all drawings should have an opacity applied
|
|
161
|
+
*/
|
|
162
|
+
this.opacity = 1;
|
|
163
|
+
/**
|
|
164
|
+
* Offset to apply to graphics by default
|
|
165
|
+
*/
|
|
166
|
+
this.offset = Vector.Zero;
|
|
167
|
+
/**
|
|
168
|
+
* Anchor to apply to graphics by default
|
|
169
|
+
*/
|
|
170
|
+
this.anchor = Vector.Half;
|
|
171
|
+
/**
|
|
172
|
+
* If set to true graphics added to the component will be copied. This can affect performance
|
|
173
|
+
*/
|
|
174
|
+
this.copyGraphics = false;
|
|
175
|
+
this._bounds = null;
|
|
176
|
+
// Defaults
|
|
177
|
+
options = {
|
|
178
|
+
visible: this.visible,
|
|
179
|
+
...options
|
|
180
|
+
};
|
|
181
|
+
const { current, anchor, opacity, visible, graphics, offset, copyGraphics, onPreDraw, onPostDraw } = options;
|
|
182
|
+
this._graphics = graphics || {};
|
|
183
|
+
this.offset = offset !== null && offset !== void 0 ? offset : this.offset;
|
|
184
|
+
this.opacity = opacity !== null && opacity !== void 0 ? opacity : this.opacity;
|
|
185
|
+
this.anchor = anchor !== null && anchor !== void 0 ? anchor : this.anchor;
|
|
186
|
+
this.copyGraphics = copyGraphics !== null && copyGraphics !== void 0 ? copyGraphics : this.copyGraphics;
|
|
187
|
+
this.onPreDraw = onPreDraw !== null && onPreDraw !== void 0 ? onPreDraw : this.onPreDraw;
|
|
188
|
+
this.onPostDraw = onPostDraw !== null && onPostDraw !== void 0 ? onPostDraw : this.onPostDraw;
|
|
189
|
+
this.visible = !!visible;
|
|
190
|
+
this.layers = new GraphicsLayers(this);
|
|
191
|
+
if (current && this._graphics[current]) {
|
|
192
|
+
this.show(this._graphics[current]);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
getGraphic(name) {
|
|
196
|
+
return this._graphics[name];
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Get registered graphics names
|
|
200
|
+
*/
|
|
201
|
+
getNames() {
|
|
202
|
+
return Object.keys(this._graphics);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Returns the currently displayed graphics and their offsets, empty array if hidden
|
|
206
|
+
*/
|
|
207
|
+
get current() {
|
|
208
|
+
return this.layers.default.graphics;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Returns all graphics associated with this component
|
|
212
|
+
*/
|
|
213
|
+
get graphics() {
|
|
214
|
+
return this._graphics;
|
|
215
|
+
}
|
|
216
|
+
add(nameOrGraphic, graphic) {
|
|
217
|
+
let name = 'default';
|
|
218
|
+
let graphicToSet = null;
|
|
219
|
+
if (typeof nameOrGraphic === 'string') {
|
|
220
|
+
name = nameOrGraphic;
|
|
221
|
+
graphicToSet = graphic;
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
graphicToSet = nameOrGraphic;
|
|
225
|
+
}
|
|
226
|
+
this._graphics[name] = this.copyGraphics ? graphicToSet.clone() : graphicToSet;
|
|
227
|
+
if (name === 'default') {
|
|
228
|
+
this.show('default');
|
|
229
|
+
}
|
|
230
|
+
return graphicToSet;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Show a graphic by name on the **default** layer, returns the new [[Graphic]]
|
|
234
|
+
*/
|
|
235
|
+
show(nameOrGraphic, options) {
|
|
236
|
+
return this.layers.default.show(nameOrGraphic, options);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Use a graphic only, swap out any graphics on the **default** layer, returns the new [[Graphic]]
|
|
240
|
+
* @param nameOrGraphic
|
|
241
|
+
* @param options
|
|
242
|
+
*/
|
|
243
|
+
use(nameOrGraphic, options) {
|
|
244
|
+
return this.layers.default.use(nameOrGraphic, options);
|
|
245
|
+
}
|
|
246
|
+
hide(nameOrGraphic) {
|
|
247
|
+
this.layers.default.hide(nameOrGraphic);
|
|
248
|
+
}
|
|
249
|
+
set localBounds(bounds) {
|
|
250
|
+
this._bounds = bounds;
|
|
251
|
+
}
|
|
252
|
+
get localBounds() {
|
|
253
|
+
if (this._bounds) {
|
|
254
|
+
return this._bounds;
|
|
255
|
+
}
|
|
256
|
+
let bb = new BoundingBox();
|
|
257
|
+
for (const layer of this.layers.get()) {
|
|
258
|
+
for (const { graphic, options } of layer.graphics) {
|
|
259
|
+
let anchor = this.anchor;
|
|
260
|
+
let offset = this.offset;
|
|
261
|
+
if (options === null || options === void 0 ? void 0 : options.anchor) {
|
|
262
|
+
anchor = options.anchor;
|
|
263
|
+
}
|
|
264
|
+
if (options === null || options === void 0 ? void 0 : options.offset) {
|
|
265
|
+
offset = options.offset;
|
|
266
|
+
}
|
|
267
|
+
const bounds = graphic.localBounds;
|
|
268
|
+
const offsetX = -bounds.width * anchor.x + offset.x;
|
|
269
|
+
const offsetY = -bounds.height * anchor.y + offset.y;
|
|
270
|
+
bb = graphic === null || graphic === void 0 ? void 0 : graphic.localBounds.translate(vec(offsetX + layer.offset.x, offsetY + layer.offset.y)).combine(bb);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return bb;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Update underlying graphics if necesary, called internally
|
|
277
|
+
* @param elapsed
|
|
278
|
+
* @internal
|
|
279
|
+
*/
|
|
280
|
+
update(elapsed, idempotencyToken = 0) {
|
|
281
|
+
for (const layer of this.layers.get()) {
|
|
282
|
+
for (const { graphic } of layer.graphics) {
|
|
283
|
+
if (hasGraphicsTick(graphic)) {
|
|
284
|
+
graphic === null || graphic === void 0 ? void 0 : graphic.tick(elapsed, idempotencyToken);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
//# sourceMappingURL=GraphicsComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GraphicsComponent.js","sourceRoot":"","sources":["../../../src/engine/Graphics/GraphicsComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAE/D;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,OAAgB;IAC9C,OAAO,CAAC,CAAE,OAA8B,CAAC,IAAI,CAAC;AAChD,CAAC;AA6DD,MAAM,OAAO,aAAa;IAExB,YAAoB,QAA8B,EAAU,SAA4B;QAApE,aAAQ,GAAR,QAAQ,CAAsB;QAAU,cAAS,GAAT,SAAS,CAAmB;QADjF,aAAQ,GA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AAC,MAAM,GAAI,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;gBACtD,EAAE,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;aAC1G;SACF;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,OAAe,EAAE,mBAA2B,CAAC;QACzD,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE;YACrC,KAAK,MAAM,EAAE,OAAO,EAAE,IAAI,KAAK,CAAC,QAAQ,EAAE;gBACxC,IAAI,eAAe,CAAC,OAAO,CAAC,EAAE;oBAC5B,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;iBAC1C;aACF;SACF;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export class GraphicsDiagnostics {
|
|
2
|
+
static clear() {
|
|
3
|
+
GraphicsDiagnostics.DrawCallCount = 0;
|
|
4
|
+
GraphicsDiagnostics.DrawnImagesCount = 0;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
GraphicsDiagnostics.DrawCallCount = 0;
|
|
8
|
+
GraphicsDiagnostics.DrawnImagesCount = 0;
|
|
9
|
+
//# sourceMappingURL=GraphicsDiagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GraphicsDiagnostics.js","sourceRoot":"","sources":["../../../src/engine/Graphics/GraphicsDiagnostics.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,mBAAmB;IAGvB,MAAM,CAAC,KAAK;QACjB,mBAAmB,CAAC,aAAa,GAAG,CAAC,CAAC;QACtC,mBAAmB,CAAC,gBAAgB,GAAG,CAAC,CAAC;IAC3C,CAAC;;AALa,iCAAa,GAAW,CAAC,CAAC;AAC1B,oCAAgB,GAAW,CAAC,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Graphic } from './Graphic';
|
|
2
|
+
import { Animation } from './Animation';
|
|
3
|
+
import { BoundingBox } from '../Collision/Index';
|
|
4
|
+
export class GraphicsGroup extends Graphic {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
super(options);
|
|
7
|
+
this.members = [];
|
|
8
|
+
this.members = options.members;
|
|
9
|
+
this._updateDimensions();
|
|
10
|
+
}
|
|
11
|
+
clone() {
|
|
12
|
+
return new GraphicsGroup({
|
|
13
|
+
members: [...this.members],
|
|
14
|
+
...this.cloneGraphicOptions()
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
_updateDimensions() {
|
|
18
|
+
let bb = new BoundingBox();
|
|
19
|
+
for (const { graphic, pos } of this.members) {
|
|
20
|
+
bb = graphic.localBounds.translate(pos).combine(bb);
|
|
21
|
+
}
|
|
22
|
+
this.width = bb.width;
|
|
23
|
+
this.height = bb.height;
|
|
24
|
+
return bb;
|
|
25
|
+
}
|
|
26
|
+
get localBounds() {
|
|
27
|
+
let bb = new BoundingBox();
|
|
28
|
+
for (const { graphic, pos } of this.members) {
|
|
29
|
+
bb = graphic.localBounds.translate(pos).combine(bb);
|
|
30
|
+
}
|
|
31
|
+
return bb;
|
|
32
|
+
}
|
|
33
|
+
_isAnimationOrGroup(graphic) {
|
|
34
|
+
return graphic instanceof Animation || graphic instanceof GraphicsGroup;
|
|
35
|
+
}
|
|
36
|
+
tick(elapsedMilliseconds, idempotencyToken) {
|
|
37
|
+
for (const member of this.members) {
|
|
38
|
+
const maybeAnimation = member.graphic;
|
|
39
|
+
if (this._isAnimationOrGroup(maybeAnimation)) {
|
|
40
|
+
maybeAnimation.tick(elapsedMilliseconds, idempotencyToken);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
reset() {
|
|
45
|
+
for (const member of this.members) {
|
|
46
|
+
const maybeAnimation = member.graphic;
|
|
47
|
+
if (this._isAnimationOrGroup(maybeAnimation)) {
|
|
48
|
+
maybeAnimation.reset();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
_preDraw(ex, x, y) {
|
|
53
|
+
this._updateDimensions();
|
|
54
|
+
super._preDraw(ex, x, y);
|
|
55
|
+
}
|
|
56
|
+
_drawImage(ex, x, y) {
|
|
57
|
+
for (const member of this.members) {
|
|
58
|
+
ex.save();
|
|
59
|
+
ex.translate(x, y);
|
|
60
|
+
member.graphic.draw(ex, member.pos.x, member.pos.y);
|
|
61
|
+
if (this.showDebug) {
|
|
62
|
+
/* istanbul ignore next */
|
|
63
|
+
ex.debug.drawRect(0, 0, this.width, this.height);
|
|
64
|
+
}
|
|
65
|
+
ex.restore();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=GraphicsGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GraphicsGroup.js","sourceRoot":"","sources":["../../../src/engine/Graphics/GraphicsGroup.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAkB,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,SAAS,EAAW,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAWjD,MAAM,OAAO,aAAc,SAAQ,OAAO;IAGxC,YAAY,OAAiD;QAC3D,KAAK,CAAC,OAAO,CAAC,CAAC;QAHV,YAAO,GAAuB,EAAE,CAAC;QAItC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC3B,CAAC;IAEM,KAAK;QACV,OAAO,IAAI,aAAa,CAAC;YACvB,OA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