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.
Files changed (446) hide show
  1. package/CHANGELOG.md +7 -2
  2. package/build/dist/Actions/Action/Blink.js +51 -0
  3. package/build/dist/Actions/Action/Blink.js.map +1 -0
  4. package/build/dist/Actions/Action/CallMethod.js +21 -0
  5. package/build/dist/Actions/Action/CallMethod.js.map +1 -0
  6. package/build/dist/Actions/Action/Delay.js +25 -0
  7. package/build/dist/Actions/Action/Delay.js.map +1 -0
  8. package/build/dist/Actions/Action/Die.js +22 -0
  9. package/build/dist/Actions/Action/Die.js.map +1 -0
  10. package/build/dist/Actions/Action/EaseTo.js +69 -0
  11. package/build/dist/Actions/Action/EaseTo.js.map +1 -0
  12. package/build/dist/Actions/Action/Fade.js +46 -0
  13. package/build/dist/Actions/Action/Fade.js.map +1 -0
  14. package/build/dist/Actions/Action/Follow.js +55 -0
  15. package/build/dist/Actions/Action/Follow.js.map +1 -0
  16. package/build/dist/Actions/Action/Meet.js +52 -0
  17. package/build/dist/Actions/Action/Meet.js.map +1 -0
  18. package/build/dist/Actions/Action/MoveBy.js +47 -0
  19. package/build/dist/Actions/Action/MoveBy.js.map +1 -0
  20. package/build/dist/Actions/Action/MoveTo.js +40 -0
  21. package/build/dist/Actions/Action/MoveTo.js.map +1 -0
  22. package/build/dist/Actions/Action/Repeat.js +31 -0
  23. package/build/dist/Actions/Action/Repeat.js.map +1 -0
  24. package/build/dist/Actions/Action/RepeatForever.js +37 -0
  25. package/build/dist/Actions/Action/RepeatForever.js.map +1 -0
  26. package/build/dist/Actions/Action/RotateBy.js +91 -0
  27. package/build/dist/Actions/Action/RotateBy.js.map +1 -0
  28. package/build/dist/Actions/Action/RotateTo.js +90 -0
  29. package/build/dist/Actions/Action/RotateTo.js.map +1 -0
  30. package/build/dist/Actions/Action/ScaleBy.js +45 -0
  31. package/build/dist/Actions/Action/ScaleBy.js.map +1 -0
  32. package/build/dist/Actions/Action/ScaleTo.js +56 -0
  33. package/build/dist/Actions/Action/ScaleTo.js.map +1 -0
  34. package/build/dist/Actions/Action.js +2 -0
  35. package/build/dist/Actions/Action.js.map +1 -0
  36. package/build/dist/Actions/ActionContext.js +305 -0
  37. package/build/dist/Actions/ActionContext.js.map +1 -0
  38. package/build/dist/Actions/ActionQueue.js +87 -0
  39. package/build/dist/Actions/ActionQueue.js.map +1 -0
  40. package/build/dist/Actions/Actionable.js +2 -0
  41. package/build/dist/Actions/Actionable.js.map +1 -0
  42. package/build/dist/Actions/ActionsComponent.js +198 -0
  43. package/build/dist/Actions/ActionsComponent.js.map +1 -0
  44. package/build/dist/Actions/ActionsSystem.js +18 -0
  45. package/build/dist/Actions/ActionsSystem.js.map +1 -0
  46. package/build/dist/Actions/Index.js +22 -0
  47. package/build/dist/Actions/Index.js.map +1 -0
  48. package/build/dist/Actions/RotationType.js +27 -0
  49. package/build/dist/Actions/RotationType.js.map +1 -0
  50. package/build/dist/Actor.js +831 -0
  51. package/build/dist/Actor.js.map +1 -0
  52. package/build/dist/Camera.js +663 -0
  53. package/build/dist/Camera.js.map +1 -0
  54. package/build/dist/Class.js +48 -0
  55. package/build/dist/Class.js.map +1 -0
  56. package/build/dist/Collision/BodyComponent.js +351 -0
  57. package/build/dist/Collision/BodyComponent.js.map +1 -0
  58. package/build/dist/Collision/BoundingBox.js +361 -0
  59. package/build/dist/Collision/BoundingBox.js.map +1 -0
  60. package/build/dist/Collision/ColliderComponent.js +198 -0
  61. package/build/dist/Collision/ColliderComponent.js.map +1 -0
  62. package/build/dist/Collision/Colliders/CircleCollider.js +264 -0
  63. package/build/dist/Collision/Colliders/CircleCollider.js.map +1 -0
  64. package/build/dist/Collision/Colliders/ClosestLineJumpTable.js +211 -0
  65. package/build/dist/Collision/Colliders/ClosestLineJumpTable.js.map +1 -0
  66. package/build/dist/Collision/Colliders/Collider.js +26 -0
  67. package/build/dist/Collision/Colliders/Collider.js.map +1 -0
  68. package/build/dist/Collision/Colliders/CollisionJumpTable.js +301 -0
  69. package/build/dist/Collision/Colliders/CollisionJumpTable.js.map +1 -0
  70. package/build/dist/Collision/Colliders/CompositeCollider.js +232 -0
  71. package/build/dist/Collision/Colliders/CompositeCollider.js.map +1 -0
  72. package/build/dist/Collision/Colliders/EdgeCollider.js +253 -0
  73. package/build/dist/Collision/Colliders/EdgeCollider.js.map +1 -0
  74. package/build/dist/Collision/Colliders/PolygonCollider.js +389 -0
  75. package/build/dist/Collision/Colliders/PolygonCollider.js.map +1 -0
  76. package/build/dist/Collision/Colliders/SeparatingAxis.js +67 -0
  77. package/build/dist/Collision/Colliders/SeparatingAxis.js.map +1 -0
  78. package/build/dist/Collision/Colliders/Shape.js +102 -0
  79. package/build/dist/Collision/Colliders/Shape.js.map +1 -0
  80. package/build/dist/Collision/CollisionSystem.js +116 -0
  81. package/build/dist/Collision/CollisionSystem.js.map +1 -0
  82. package/build/dist/Collision/CollisionType.js +33 -0
  83. package/build/dist/Collision/CollisionType.js.map +1 -0
  84. package/build/dist/Collision/Detection/CollisionContact.js +46 -0
  85. package/build/dist/Collision/Detection/CollisionContact.js.map +1 -0
  86. package/build/dist/Collision/Detection/CollisionProcessor.js +2 -0
  87. package/build/dist/Collision/Detection/CollisionProcessor.js.map +1 -0
  88. package/build/dist/Collision/Detection/DynamicTree.js +442 -0
  89. package/build/dist/Collision/Detection/DynamicTree.js.map +1 -0
  90. package/build/dist/Collision/Detection/DynamicTreeCollisionProcessor.js +211 -0
  91. package/build/dist/Collision/Detection/DynamicTreeCollisionProcessor.js.map +1 -0
  92. package/build/dist/Collision/Detection/Pair.js +92 -0
  93. package/build/dist/Collision/Detection/Pair.js.map +1 -0
  94. package/build/dist/Collision/Group/CollisionGroup.js +114 -0
  95. package/build/dist/Collision/Group/CollisionGroup.js.map +1 -0
  96. package/build/dist/Collision/Group/CollisionGroupManager.js +52 -0
  97. package/build/dist/Collision/Group/CollisionGroupManager.js.map +1 -0
  98. package/build/dist/Collision/Index.js +29 -0
  99. package/build/dist/Collision/Index.js.map +1 -0
  100. package/build/dist/Collision/Integrator.js +11 -0
  101. package/build/dist/Collision/Integrator.js.map +1 -0
  102. package/build/dist/Collision/MotionSystem.js +42 -0
  103. package/build/dist/Collision/MotionSystem.js.map +1 -0
  104. package/build/dist/Collision/Physics.js +163 -0
  105. package/build/dist/Collision/Physics.js.map +1 -0
  106. package/build/dist/Collision/Side.js +51 -0
  107. package/build/dist/Collision/Side.js.map +1 -0
  108. package/build/dist/Collision/Solver/ArcadeSolver.js +101 -0
  109. package/build/dist/Collision/Solver/ArcadeSolver.js.map +1 -0
  110. package/build/dist/Collision/Solver/ContactConstraintPoint.js +83 -0
  111. package/build/dist/Collision/Solver/ContactConstraintPoint.js.map +1 -0
  112. package/build/dist/Collision/Solver/RealisticSolver.js +248 -0
  113. package/build/dist/Collision/Solver/RealisticSolver.js.map +1 -0
  114. package/build/dist/Collision/Solver/Solver.js +37 -0
  115. package/build/dist/Collision/Solver/Solver.js.map +1 -0
  116. package/build/dist/Color.js +461 -0
  117. package/build/dist/Color.js.map +1 -0
  118. package/build/dist/Configurable.js +32 -0
  119. package/build/dist/Configurable.js.map +1 -0
  120. package/build/dist/Debug/Debug.js +375 -0
  121. package/build/dist/Debug/Debug.js.map +1 -0
  122. package/build/dist/Debug/DebugFlags.js +40 -0
  123. package/build/dist/Debug/DebugFlags.js.map +1 -0
  124. package/build/dist/Debug/DebugSystem.js +251 -0
  125. package/build/dist/Debug/DebugSystem.js.map +1 -0
  126. package/build/dist/Debug/index.js +4 -0
  127. package/build/dist/Debug/index.js.map +1 -0
  128. package/build/dist/Deprecated.js +2 -0
  129. package/build/dist/Deprecated.js.map +1 -0
  130. package/build/dist/Drawing/Animation.js +294 -0
  131. package/build/dist/Drawing/Animation.js.map +1 -0
  132. package/build/dist/Drawing/CanvasDrawComponent.js +16 -0
  133. package/build/dist/Drawing/CanvasDrawComponent.js.map +1 -0
  134. package/build/dist/Drawing/CanvasDrawingSystem.js +95 -0
  135. package/build/dist/Drawing/CanvasDrawingSystem.js.map +1 -0
  136. package/build/dist/Drawing/Index.js +10 -0
  137. package/build/dist/Drawing/Index.js.map +1 -0
  138. package/build/dist/Drawing/Polygon.js +139 -0
  139. package/build/dist/Drawing/Polygon.js.map +1 -0
  140. package/build/dist/Drawing/Sprite.js +355 -0
  141. package/build/dist/Drawing/Sprite.js.map +1 -0
  142. package/build/dist/Drawing/SpriteEffects.js +246 -0
  143. package/build/dist/Drawing/SpriteEffects.js.map +1 -0
  144. package/build/dist/Drawing/SpriteSheet.js +413 -0
  145. package/build/dist/Drawing/SpriteSheet.js.map +1 -0
  146. package/build/dist/Drawing/Texture.js +69 -0
  147. package/build/dist/Drawing/Texture.js.map +1 -0
  148. package/build/dist/Engine.d.ts +4 -1
  149. package/build/dist/Engine.js +985 -0
  150. package/build/dist/Engine.js.map +1 -0
  151. package/build/dist/EntityComponentSystem/Component.js +65 -0
  152. package/build/dist/EntityComponentSystem/Component.js.map +1 -0
  153. package/build/dist/EntityComponentSystem/Components/MotionComponent.js +33 -0
  154. package/build/dist/EntityComponentSystem/Components/MotionComponent.js.map +1 -0
  155. package/build/dist/EntityComponentSystem/Components/TransformComponent.js +249 -0
  156. package/build/dist/EntityComponentSystem/Components/TransformComponent.js.map +1 -0
  157. package/build/dist/EntityComponentSystem/Entity.js +452 -0
  158. package/build/dist/EntityComponentSystem/Entity.js.map +1 -0
  159. package/build/dist/EntityComponentSystem/EntityManager.js +128 -0
  160. package/build/dist/EntityComponentSystem/EntityManager.js.map +1 -0
  161. package/build/dist/EntityComponentSystem/Query.js +91 -0
  162. package/build/dist/EntityComponentSystem/Query.js.map +1 -0
  163. package/build/dist/EntityComponentSystem/QueryManager.js +90 -0
  164. package/build/dist/EntityComponentSystem/QueryManager.js.map +1 -0
  165. package/build/dist/EntityComponentSystem/System.js +76 -0
  166. package/build/dist/EntityComponentSystem/System.js.map +1 -0
  167. package/build/dist/EntityComponentSystem/SystemManager.js +102 -0
  168. package/build/dist/EntityComponentSystem/SystemManager.js.map +1 -0
  169. package/build/dist/EntityComponentSystem/Util.js +5 -0
  170. package/build/dist/EntityComponentSystem/Util.js.map +1 -0
  171. package/build/dist/EntityComponentSystem/World.js +55 -0
  172. package/build/dist/EntityComponentSystem/World.js.map +1 -0
  173. package/build/dist/EntityComponentSystem/index.js +11 -0
  174. package/build/dist/EntityComponentSystem/index.js.map +1 -0
  175. package/build/dist/EventDispatcher.js +114 -0
  176. package/build/dist/EventDispatcher.js.map +1 -0
  177. package/build/dist/Events/ExEvent.js +12 -0
  178. package/build/dist/Events/ExEvent.js.map +1 -0
  179. package/build/dist/Events/MediaEvents.js +75 -0
  180. package/build/dist/Events/MediaEvents.js.map +1 -0
  181. package/build/dist/Events/PointerEvents.js +52 -0
  182. package/build/dist/Events/PointerEvents.js.map +1 -0
  183. package/build/dist/Events.js +497 -0
  184. package/build/dist/Events.js.map +1 -0
  185. package/build/dist/Flags.js +90 -0
  186. package/build/dist/Flags.js.map +1 -0
  187. package/build/dist/Graphics/Animation.js +310 -0
  188. package/build/dist/Graphics/Animation.js.map +1 -0
  189. package/build/dist/Graphics/Canvas.js +38 -0
  190. package/build/dist/Graphics/Canvas.js.map +1 -0
  191. package/build/dist/Graphics/Circle.js +47 -0
  192. package/build/dist/Graphics/Circle.js.map +1 -0
  193. package/build/dist/Graphics/Context/ExcaliburGraphicsContext.js +2 -0
  194. package/build/dist/Graphics/Context/ExcaliburGraphicsContext.js.map +1 -0
  195. package/build/dist/Graphics/Context/ExcaliburGraphicsContext2DCanvas.js +207 -0
  196. package/build/dist/Graphics/Context/ExcaliburGraphicsContext2DCanvas.js.map +1 -0
  197. package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.js +331 -0
  198. package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.js.map +1 -0
  199. package/build/dist/Graphics/Context/circle-renderer/circle-renderer.js +160 -0
  200. package/build/dist/Graphics/Context/circle-renderer/circle-renderer.js.map +1 -0
  201. package/build/dist/Graphics/Context/debug-text.js +47 -0
  202. package/build/dist/Graphics/Context/debug-text.js.map +1 -0
  203. package/build/dist/Graphics/Context/image-renderer/image-renderer.js +209 -0
  204. package/build/dist/Graphics/Context/image-renderer/image-renderer.js.map +1 -0
  205. package/build/dist/Graphics/Context/line-renderer/line-renderer.js +87 -0
  206. package/build/dist/Graphics/Context/line-renderer/line-renderer.js.map +1 -0
  207. package/build/dist/Graphics/Context/point-renderer/point-renderer.js +82 -0
  208. package/build/dist/Graphics/Context/point-renderer/point-renderer.js.map +1 -0
  209. package/build/dist/Graphics/Context/quad-index-buffer.js +69 -0
  210. package/build/dist/Graphics/Context/quad-index-buffer.js.map +1 -0
  211. package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.js +272 -0
  212. package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.js.map +1 -0
  213. package/build/dist/Graphics/Context/render-source.js +16 -0
  214. package/build/dist/Graphics/Context/render-source.js.map +1 -0
  215. package/build/dist/Graphics/Context/render-target.js +65 -0
  216. package/build/dist/Graphics/Context/render-target.js.map +1 -0
  217. package/build/dist/Graphics/Context/renderer.js +2 -0
  218. package/build/dist/Graphics/Context/renderer.js.map +1 -0
  219. package/build/dist/Graphics/Context/screen-pass-painter/screen-pass-painter.js +53 -0
  220. package/build/dist/Graphics/Context/screen-pass-painter/screen-pass-painter.js.map +1 -0
  221. package/build/dist/Graphics/Context/shader.js +236 -0
  222. package/build/dist/Graphics/Context/shader.js.map +1 -0
  223. package/build/dist/Graphics/Context/state-stack.js +27 -0
  224. package/build/dist/Graphics/Context/state-stack.js.map +1 -0
  225. package/build/dist/Graphics/Context/texture-loader.d.ts +8 -0
  226. package/build/dist/Graphics/Context/texture-loader.js +121 -0
  227. package/build/dist/Graphics/Context/texture-loader.js.map +1 -0
  228. package/build/dist/Graphics/Context/transform-stack.js +30 -0
  229. package/build/dist/Graphics/Context/transform-stack.js.map +1 -0
  230. package/build/dist/Graphics/Context/vertex-buffer.js +45 -0
  231. package/build/dist/Graphics/Context/vertex-buffer.js.map +1 -0
  232. package/build/dist/Graphics/Context/vertex-layout.js +93 -0
  233. package/build/dist/Graphics/Context/vertex-layout.js.map +1 -0
  234. package/build/dist/Graphics/Context/webgl-adapter.js +19 -0
  235. package/build/dist/Graphics/Context/webgl-adapter.js.map +1 -0
  236. package/build/dist/Graphics/Context/webgl-util.js +105 -0
  237. package/build/dist/Graphics/Context/webgl-util.js.map +1 -0
  238. package/build/dist/Graphics/DebugGraphicsComponent.js +15 -0
  239. package/build/dist/Graphics/DebugGraphicsComponent.js.map +1 -0
  240. package/build/dist/Graphics/Filtering.js +17 -0
  241. package/build/dist/Graphics/Filtering.js.map +1 -0
  242. package/build/dist/Graphics/Font.js +293 -0
  243. package/build/dist/Graphics/Font.js.map +1 -0
  244. package/build/dist/Graphics/FontCommon.js +109 -0
  245. package/build/dist/Graphics/FontCommon.js.map +1 -0
  246. package/build/dist/Graphics/Graphic.js +200 -0
  247. package/build/dist/Graphics/Graphic.js.map +1 -0
  248. package/build/dist/Graphics/GraphicsComponent.js +290 -0
  249. package/build/dist/Graphics/GraphicsComponent.js.map +1 -0
  250. package/build/dist/Graphics/GraphicsDiagnostics.js +9 -0
  251. package/build/dist/Graphics/GraphicsDiagnostics.js.map +1 -0
  252. package/build/dist/Graphics/GraphicsGroup.js +69 -0
  253. package/build/dist/Graphics/GraphicsGroup.js.map +1 -0
  254. package/build/dist/Graphics/GraphicsSystem.js +153 -0
  255. package/build/dist/Graphics/GraphicsSystem.js.map +1 -0
  256. package/build/dist/Graphics/ImageSource.js +116 -0
  257. package/build/dist/Graphics/ImageSource.js.map +1 -0
  258. package/build/dist/Graphics/Polygon.js +59 -0
  259. package/build/dist/Graphics/Polygon.js.map +1 -0
  260. package/build/dist/Graphics/PostProcessor/ColorBlindnessMode.js +7 -0
  261. package/build/dist/Graphics/PostProcessor/ColorBlindnessMode.js.map +1 -0
  262. package/build/dist/Graphics/PostProcessor/ColorBlindnessPostProcessor.js +52 -0
  263. package/build/dist/Graphics/PostProcessor/ColorBlindnessPostProcessor.js.map +1 -0
  264. package/build/dist/Graphics/PostProcessor/PostProcessor.js +2 -0
  265. package/build/dist/Graphics/PostProcessor/PostProcessor.js.map +1 -0
  266. package/build/dist/Graphics/PostProcessor/ScreenShader.js +56 -0
  267. package/build/dist/Graphics/PostProcessor/ScreenShader.js.map +1 -0
  268. package/build/dist/Graphics/Raster.js +207 -0
  269. package/build/dist/Graphics/Raster.js.map +1 -0
  270. package/build/dist/Graphics/Rectangle.js +29 -0
  271. package/build/dist/Graphics/Rectangle.js.map +1 -0
  272. package/build/dist/Graphics/Sprite.js +103 -0
  273. package/build/dist/Graphics/Sprite.js.map +1 -0
  274. package/build/dist/Graphics/SpriteFont.js +120 -0
  275. package/build/dist/Graphics/SpriteFont.js.map +1 -0
  276. package/build/dist/Graphics/SpriteSheet.js +115 -0
  277. package/build/dist/Graphics/SpriteSheet.js.map +1 -0
  278. package/build/dist/Graphics/Text.js +94 -0
  279. package/build/dist/Graphics/Text.js.map +1 -0
  280. package/build/dist/Graphics/index.js +42 -0
  281. package/build/dist/Graphics/index.js.map +1 -0
  282. package/build/dist/Id.js +8 -0
  283. package/build/dist/Id.js.map +1 -0
  284. package/build/dist/Input/CapturePointerConfig.js +5 -0
  285. package/build/dist/Input/CapturePointerConfig.js.map +1 -0
  286. package/build/dist/Input/EngineInput.js +2 -0
  287. package/build/dist/Input/EngineInput.js.map +1 -0
  288. package/build/dist/Input/Gamepad.js +358 -0
  289. package/build/dist/Input/Gamepad.js.map +1 -0
  290. package/build/dist/Input/Index.js +22 -0
  291. package/build/dist/Input/Index.js.map +1 -0
  292. package/build/dist/Input/Keyboard.js +267 -0
  293. package/build/dist/Input/Keyboard.js.map +1 -0
  294. package/build/dist/Input/NativePointerButton.js +12 -0
  295. package/build/dist/Input/NativePointerButton.js.map +1 -0
  296. package/build/dist/Input/PointerAbstraction.js +41 -0
  297. package/build/dist/Input/PointerAbstraction.js.map +1 -0
  298. package/build/dist/Input/PointerButton.js +12 -0
  299. package/build/dist/Input/PointerButton.js.map +1 -0
  300. package/build/dist/Input/PointerComponent.js +28 -0
  301. package/build/dist/Input/PointerComponent.js.map +1 -0
  302. package/build/dist/Input/PointerEvent.js +25 -0
  303. package/build/dist/Input/PointerEvent.js.map +1 -0
  304. package/build/dist/Input/PointerEventReceiver.js +414 -0
  305. package/build/dist/Input/PointerEventReceiver.js.map +1 -0
  306. package/build/dist/Input/PointerScope.js +16 -0
  307. package/build/dist/Input/PointerScope.js.map +1 -0
  308. package/build/dist/Input/PointerSystem.js +217 -0
  309. package/build/dist/Input/PointerSystem.js.map +1 -0
  310. package/build/dist/Input/PointerType.js +11 -0
  311. package/build/dist/Input/PointerType.js.map +1 -0
  312. package/build/dist/Input/WheelDeltaMode.js +7 -0
  313. package/build/dist/Input/WheelDeltaMode.js.map +1 -0
  314. package/build/dist/Input/WheelEvent.js +21 -0
  315. package/build/dist/Input/WheelEvent.js.map +1 -0
  316. package/build/dist/Interfaces/Audio.js +2 -0
  317. package/build/dist/Interfaces/Audio.js.map +1 -0
  318. package/build/dist/Interfaces/AudioImplementation.js +11 -0
  319. package/build/dist/Interfaces/AudioImplementation.js.map +1 -0
  320. package/build/dist/Interfaces/Clonable.js +2 -0
  321. package/build/dist/Interfaces/Clonable.js.map +1 -0
  322. package/build/dist/Interfaces/Drawable.js +2 -0
  323. package/build/dist/Interfaces/Drawable.js.map +1 -0
  324. package/build/dist/Interfaces/Evented.js +2 -0
  325. package/build/dist/Interfaces/Evented.js.map +1 -0
  326. package/build/dist/Interfaces/Index.js +10 -0
  327. package/build/dist/Interfaces/Index.js.map +1 -0
  328. package/build/dist/Interfaces/LifecycleEvents.js +51 -0
  329. package/build/dist/Interfaces/LifecycleEvents.js.map +1 -0
  330. package/build/dist/Interfaces/Loadable.js +2 -0
  331. package/build/dist/Interfaces/Loadable.js.map +1 -0
  332. package/build/dist/Interfaces/PointerEventHandlers.js +2 -0
  333. package/build/dist/Interfaces/PointerEventHandlers.js.map +1 -0
  334. package/build/dist/Interfaces/Trait.js +2 -0
  335. package/build/dist/Interfaces/Trait.js.map +1 -0
  336. package/build/dist/Label.js +273 -0
  337. package/build/dist/Label.js.map +1 -0
  338. package/build/dist/Loader.js +367 -0
  339. package/build/dist/Loader.js.map +1 -0
  340. package/build/dist/Math/Index.js +10 -0
  341. package/build/dist/Math/Index.js.map +1 -0
  342. package/build/dist/Math/Random.js +239 -0
  343. package/build/dist/Math/Random.js.map +1 -0
  344. package/build/dist/Math/global-coordinates.js +30 -0
  345. package/build/dist/Math/global-coordinates.js.map +1 -0
  346. package/build/dist/Math/line.js +194 -0
  347. package/build/dist/Math/line.js.map +1 -0
  348. package/build/dist/Math/matrix.js +446 -0
  349. package/build/dist/Math/matrix.js.map +1 -0
  350. package/build/dist/Math/projection.js +24 -0
  351. package/build/dist/Math/projection.js.map +1 -0
  352. package/build/dist/Math/ray.js +52 -0
  353. package/build/dist/Math/ray.js.map +1 -0
  354. package/build/dist/Math/util.js +82 -0
  355. package/build/dist/Math/util.js.map +1 -0
  356. package/build/dist/Math/vector-view.js +25 -0
  357. package/build/dist/Math/vector-view.js.map +1 -0
  358. package/build/dist/Math/vector.js +326 -0
  359. package/build/dist/Math/vector.js.map +1 -0
  360. package/build/dist/Particles.js +449 -0
  361. package/build/dist/Particles.js.map +1 -0
  362. package/build/dist/Polyfill.js +56 -0
  363. package/build/dist/Polyfill.js.map +1 -0
  364. package/build/dist/Promises.js +205 -0
  365. package/build/dist/Promises.js.map +1 -0
  366. package/build/dist/Resources/Gif.js +479 -0
  367. package/build/dist/Resources/Gif.js.map +1 -0
  368. package/build/dist/Resources/Index.js +4 -0
  369. package/build/dist/Resources/Index.js.map +1 -0
  370. package/build/dist/Resources/Resource.js +74 -0
  371. package/build/dist/Resources/Resource.js.map +1 -0
  372. package/build/dist/Resources/Sound/AudioContext.js +16 -0
  373. package/build/dist/Resources/Sound/AudioContext.js.map +1 -0
  374. package/build/dist/Resources/Sound/Index.js +4 -0
  375. package/build/dist/Resources/Sound/Index.js.map +1 -0
  376. package/build/dist/Resources/Sound/Sound.js +240 -0
  377. package/build/dist/Resources/Sound/Sound.js.map +1 -0
  378. package/build/dist/Resources/Sound/WebAudioInstance.js +160 -0
  379. package/build/dist/Resources/Sound/WebAudioInstance.js.map +1 -0
  380. package/build/dist/Scene.js +458 -0
  381. package/build/dist/Scene.js.map +1 -0
  382. package/build/dist/Screen.js +634 -0
  383. package/build/dist/Screen.js.map +1 -0
  384. package/build/dist/ScreenElement.js +29 -0
  385. package/build/dist/ScreenElement.js.map +1 -0
  386. package/build/dist/TileMap.js +488 -0
  387. package/build/dist/TileMap.js.map +1 -0
  388. package/build/dist/Timer.js +198 -0
  389. package/build/dist/Timer.js.map +1 -0
  390. package/build/dist/Traits/Index.js +5 -0
  391. package/build/dist/Traits/Index.js.map +1 -0
  392. package/build/dist/Traits/OffscreenCulling.js +35 -0
  393. package/build/dist/Traits/OffscreenCulling.js.map +1 -0
  394. package/build/dist/Trigger.js +113 -0
  395. package/build/dist/Trigger.js.map +1 -0
  396. package/build/dist/Util/Actors.js +19 -0
  397. package/build/dist/Util/Actors.js.map +1 -0
  398. package/build/dist/Util/Browser.js +66 -0
  399. package/build/dist/Util/Browser.js.map +1 -0
  400. package/build/dist/Util/Clock.js +219 -0
  401. package/build/dist/Util/Clock.js.map +1 -0
  402. package/build/dist/Util/CullingBox.js +104 -0
  403. package/build/dist/Util/CullingBox.js.map +1 -0
  404. package/build/dist/Util/Decorators.js +78 -0
  405. package/build/dist/Util/Decorators.js.map +1 -0
  406. package/build/dist/Util/Detector.js +167 -0
  407. package/build/dist/Util/Detector.js.map +1 -0
  408. package/build/dist/Util/DrawUtil.js +117 -0
  409. package/build/dist/Util/DrawUtil.js.map +1 -0
  410. package/build/dist/Util/EasingFunctions.js +118 -0
  411. package/build/dist/Util/EasingFunctions.js.map +1 -0
  412. package/build/dist/Util/Fps.js +47 -0
  413. package/build/dist/Util/Fps.js.map +1 -0
  414. package/build/dist/Util/Index.js +7 -0
  415. package/build/dist/Util/Index.js.map +1 -0
  416. package/build/dist/Util/Log.js +195 -0
  417. package/build/dist/Util/Log.js.map +1 -0
  418. package/build/dist/Util/Observable.js +60 -0
  419. package/build/dist/Util/Observable.js.map +1 -0
  420. package/build/dist/Util/Pool.js +66 -0
  421. package/build/dist/Util/Pool.js.map +1 -0
  422. package/build/dist/Util/SortedList.js +261 -0
  423. package/build/dist/Util/SortedList.js.map +1 -0
  424. package/build/dist/Util/Sound.js +22 -0
  425. package/build/dist/Util/Sound.js.map +1 -0
  426. package/build/dist/Util/Util.js +294 -0
  427. package/build/dist/Util/Util.js.map +1 -0
  428. package/build/dist/Util/Watch.js +67 -0
  429. package/build/dist/Util/Watch.js.map +1 -0
  430. package/build/dist/Util/WebAudio.js +62 -0
  431. package/build/dist/Util/WebAudio.js.map +1 -0
  432. package/build/dist/excalibur.js +101 -22
  433. package/build/dist/excalibur.js.map +1 -1
  434. package/build/dist/excalibur.min.js +1 -1
  435. package/build/dist/excalibur.min.js.LICENSE.txt +1 -1
  436. package/build/dist/excalibur.min.js.map +1 -1
  437. package/build/dist/index.js +74 -0
  438. package/build/dist/index.js.map +1 -0
  439. package/build/esm/Engine.d.ts +4 -1
  440. package/build/esm/Graphics/Context/texture-loader.d.ts +8 -0
  441. package/build/esm/excalibur.js +101 -22
  442. package/build/esm/excalibur.js.map +1 -1
  443. package/build/esm/excalibur.min.js +1 -1
  444. package/build/esm/excalibur.min.js.LICENSE.txt +1 -1
  445. package/build/esm/excalibur.min.js.map +1 -1
  446. package/package.json +23 -22
@@ -0,0 +1,831 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Texture } from './Drawing/Texture';
8
+ import { KillEvent, PreUpdateEvent, PreDrawEvent, PostKillEvent, PreKillEvent } from './Events';
9
+ import { Sprite } from './Drawing/Sprite';
10
+ import { Animation } from './Drawing/Animation';
11
+ import { Logger } from './Util/Log';
12
+ import { Vector, vec } from './Math/vector';
13
+ import { BodyComponent } from './Collision/BodyComponent';
14
+ import * as Traits from './Traits/Index';
15
+ import { CollisionType } from './Collision/CollisionType';
16
+ import { Entity } from './EntityComponentSystem/Entity';
17
+ import { CanvasDrawComponent } from './Drawing/CanvasDrawComponent';
18
+ import { CoordPlane, TransformComponent } from './EntityComponentSystem/Components/TransformComponent';
19
+ import { MotionComponent } from './EntityComponentSystem/Components/MotionComponent';
20
+ import { GraphicsComponent } from './Graphics/GraphicsComponent';
21
+ import { Rectangle } from './Graphics/Rectangle';
22
+ import { Flags, Legacy } from './Flags';
23
+ import { obsolete } from './Util/Decorators';
24
+ import { ColliderComponent } from './Collision/ColliderComponent';
25
+ import { Shape } from './Collision/Colliders/Shape';
26
+ import { watch } from './Util/Watch';
27
+ import { Circle } from './Graphics/Circle';
28
+ import { PointerComponent } from './Input/PointerComponent';
29
+ import { ActionsComponent } from './Actions/ActionsComponent';
30
+ import { Raster } from './Graphics/Raster';
31
+ import { Text } from './Graphics/Text';
32
+ /**
33
+ * Type guard for checking if something is an Actor
34
+ * @param x
35
+ */
36
+ export function isActor(x) {
37
+ return x instanceof Actor;
38
+ }
39
+ /**
40
+ * The most important primitive in Excalibur is an `Actor`. Anything that
41
+ * can move on the screen, collide with another `Actor`, respond to events,
42
+ * or interact with the current scene, must be an actor. An `Actor` **must**
43
+ * be part of a [[Scene]] for it to be drawn to the screen.
44
+ */
45
+ export class Actor extends Entity {
46
+ // #endregion
47
+ /**
48
+ *
49
+ * @param config
50
+ */
51
+ constructor(config) {
52
+ super();
53
+ /**
54
+ * The anchor to apply all actor related transformations like rotation,
55
+ * translation, and scaling. By default the anchor is in the center of
56
+ * the actor. By default it is set to the center of the actor (.5, .5)
57
+ *
58
+ * An anchor of (.5, .5) will ensure that drawings are centered.
59
+ *
60
+ * Use `anchor.setTo` to set the anchor to a different point using
61
+ * values between 0 and 1. For example, anchoring to the top-left would be
62
+ * `Actor.anchor.setTo(0, 0)` and top-right would be `Actor.anchor.setTo(0, 1)`.
63
+ */
64
+ this._anchor = watch(Vector.Half, (v) => this._handleAnchorChange(v));
65
+ /**
66
+ * Convenience reference to the global logger
67
+ */
68
+ this.logger = Logger.getInstance();
69
+ /**
70
+ * The scene that the actor is in
71
+ */
72
+ this.scene = null;
73
+ /**
74
+ * @deprecated will be removed in v0.26.0
75
+ */
76
+ this.frames = {};
77
+ /**
78
+ * Access to the current drawing for the actor, this can be
79
+ * an [[Animation]], [[Sprite]], or [[Polygon]].
80
+ * Set drawings with [[setDrawing]].
81
+ * @deprecated will be removed in v0.26.0
82
+ */
83
+ this.currentDrawing = null;
84
+ /**
85
+ * Draggable helper
86
+ */
87
+ this._draggable = false;
88
+ this._dragging = false;
89
+ this._pointerDragStartHandler = () => {
90
+ this._dragging = true;
91
+ };
92
+ this._pointerDragEndHandler = () => {
93
+ this._dragging = false;
94
+ };
95
+ this._pointerDragMoveHandler = (pe) => {
96
+ if (this._dragging) {
97
+ this.pos = pe.worldPos;
98
+ }
99
+ };
100
+ this._pointerDragLeaveHandler = (pe) => {
101
+ if (this._dragging) {
102
+ this.pos = pe.worldPos;
103
+ }
104
+ };
105
+ /**
106
+ * Modify the current actor update pipeline.
107
+ * @deprecated will be removed in v0.26.0
108
+ */
109
+ this.traits = [];
110
+ const { name, x, y, pos, coordPlane, scale, width, height, radius, collider, vel, acc, rotation, angularVelocity, z, color, visible, anchor, collisionType, collisionGroup } = {
111
+ ...config
112
+ };
113
+ this._setName(name);
114
+ this.anchor = anchor !== null && anchor !== void 0 ? anchor : Actor.defaults.anchor.clone();
115
+ const tx = new TransformComponent();
116
+ this.addComponent(tx);
117
+ this.pos = pos !== null && pos !== void 0 ? pos : vec(x !== null && x !== void 0 ? x : 0, y !== null && y !== void 0 ? y : 0);
118
+ this.rotation = rotation !== null && rotation !== void 0 ? rotation : 0;
119
+ this.scale = scale !== null && scale !== void 0 ? scale : vec(1, 1);
120
+ this.z = z !== null && z !== void 0 ? z : 0;
121
+ tx.coordPlane = coordPlane !== null && coordPlane !== void 0 ? coordPlane : CoordPlane.World;
122
+ this.addComponent(new PointerComponent);
123
+ this.addComponent(new GraphicsComponent({
124
+ anchor: this.anchor
125
+ }));
126
+ this.addComponent(new CanvasDrawComponent((ctx, delta) => this.draw(ctx, delta)));
127
+ this.addComponent(new MotionComponent());
128
+ this.vel = vel !== null && vel !== void 0 ? vel : Vector.Zero;
129
+ this.acc = acc !== null && acc !== void 0 ? acc : Vector.Zero;
130
+ this.angularVelocity = angularVelocity !== null && angularVelocity !== void 0 ? angularVelocity : 0;
131
+ this.addComponent(new ActionsComponent());
132
+ this.addComponent(new BodyComponent());
133
+ this.body.collisionType = collisionType !== null && collisionType !== void 0 ? collisionType : CollisionType.Passive;
134
+ if (collisionGroup) {
135
+ this.body.group = collisionGroup;
136
+ }
137
+ if (collider) {
138
+ this.addComponent(new ColliderComponent(collider));
139
+ }
140
+ else if (radius) {
141
+ this.addComponent(new ColliderComponent(Shape.Circle(radius, this.anchor)));
142
+ }
143
+ else {
144
+ if (width > 0 && height > 0) {
145
+ this.addComponent(new ColliderComponent(Shape.Box(width, height, this.anchor)));
146
+ }
147
+ else {
148
+ this.addComponent(new ColliderComponent()); // no collider
149
+ }
150
+ }
151
+ this.graphics.visible = visible !== null && visible !== void 0 ? visible : true;
152
+ if (color) {
153
+ this.color = color;
154
+ if (width && height) {
155
+ this.graphics.add(new Rectangle({
156
+ color: color,
157
+ width,
158
+ height
159
+ }));
160
+ }
161
+ else if (radius) {
162
+ this.graphics.add(new Circle({
163
+ color: color,
164
+ radius
165
+ }));
166
+ }
167
+ }
168
+ // Build default pipeline
169
+ if (Flags.isEnabled(Legacy.LegacyDrawing)) {
170
+ // TODO remove offscreen trait after legacy drawing removed
171
+ this.traits.push(new Traits.OffscreenCulling());
172
+ }
173
+ }
174
+ /**
175
+ * The physics body the is associated with this actor. The body is the container for all physical properties, like position, velocity,
176
+ * acceleration, mass, inertia, etc.
177
+ */
178
+ get body() {
179
+ return this.get(BodyComponent);
180
+ }
181
+ /**
182
+ * Access the Actor's built in [[TransformComponent]]
183
+ */
184
+ get transform() {
185
+ return this.get(TransformComponent);
186
+ }
187
+ /**
188
+ * Access the Actor's built in [[MotionComponent]]
189
+ */
190
+ get motion() {
191
+ return this.get(MotionComponent);
192
+ }
193
+ /**
194
+ * Access to the Actor's built in [[GraphicsComponent]]
195
+ */
196
+ get graphics() {
197
+ return this.get(GraphicsComponent);
198
+ }
199
+ /**
200
+ * Access to the Actor's built in [[ColliderComponent]]
201
+ */
202
+ get collider() {
203
+ return this.get(ColliderComponent);
204
+ }
205
+ /**
206
+ * Access to the Actor's built in [[PointerComponent]] config
207
+ */
208
+ get pointer() {
209
+ return this.get(PointerComponent);
210
+ }
211
+ /**
212
+ * Useful for quickly scripting actor behavior, like moving to a place, patrolling back and forth, blinking, etc.
213
+ *
214
+ * Access to the Actor's built in [[ActionsComponent]] which forwards to the
215
+ * [[ActionContext|Action context]] of the actor.
216
+ */
217
+ get actions() {
218
+ return this.get(ActionsComponent);
219
+ }
220
+ /**
221
+ * Gets the position vector of the actor in pixels
222
+ */
223
+ get pos() {
224
+ return this.transform.pos;
225
+ }
226
+ /**
227
+ * Sets the position vector of the actor in pixels
228
+ */
229
+ set pos(thePos) {
230
+ this.transform.pos = thePos.clone();
231
+ }
232
+ /**
233
+ * Gets the position vector of the actor from the last frame
234
+ */
235
+ get oldPos() {
236
+ return this.body.oldPos;
237
+ }
238
+ /**
239
+ * Sets the position vector of the actor in the last frame
240
+ */
241
+ set oldPos(thePos) {
242
+ this.body.oldPos.setTo(thePos.x, thePos.y);
243
+ }
244
+ /**
245
+ * Gets the velocity vector of the actor in pixels/sec
246
+ */
247
+ get vel() {
248
+ return this.motion.vel;
249
+ }
250
+ /**
251
+ * Sets the velocity vector of the actor in pixels/sec
252
+ */
253
+ set vel(theVel) {
254
+ this.motion.vel = theVel.clone();
255
+ }
256
+ /**
257
+ * Gets the velocity vector of the actor from the last frame
258
+ */
259
+ get oldVel() {
260
+ return this.body.oldVel;
261
+ }
262
+ /**
263
+ * Sets the velocity vector of the actor from the last frame
264
+ */
265
+ set oldVel(theVel) {
266
+ this.body.oldVel.setTo(theVel.x, theVel.y);
267
+ }
268
+ /**
269
+ * Gets the acceleration vector of the actor in pixels/second/second. An acceleration pointing down such as (0, 100) may be
270
+ * useful to simulate a gravitational effect.
271
+ */
272
+ get acc() {
273
+ return this.motion.acc;
274
+ }
275
+ /**
276
+ * Sets the acceleration vector of teh actor in pixels/second/second
277
+ */
278
+ set acc(theAcc) {
279
+ this.motion.acc = theAcc.clone();
280
+ }
281
+ /**
282
+ * Sets the acceleration of the actor from the last frame. This does not include the global acc [[Physics.acc]].
283
+ */
284
+ set oldAcc(theAcc) {
285
+ this.body.oldAcc.setTo(theAcc.x, theAcc.y);
286
+ }
287
+ /**
288
+ * Gets the acceleration of the actor from the last frame. This does not include the global acc [[Physics.acc]].
289
+ */
290
+ get oldAcc() {
291
+ return this.body.oldAcc;
292
+ }
293
+ /**
294
+ * Gets the rotation of the actor in radians. 1 radian = 180/PI Degrees.
295
+ */
296
+ get rotation() {
297
+ return this.transform.rotation;
298
+ }
299
+ /**
300
+ * Sets the rotation of the actor in radians. 1 radian = 180/PI Degrees.
301
+ */
302
+ set rotation(theAngle) {
303
+ this.transform.rotation = theAngle;
304
+ }
305
+ /**
306
+ * Gets the rotational velocity of the actor in radians/second
307
+ */
308
+ get angularVelocity() {
309
+ return this.motion.angularVelocity;
310
+ }
311
+ /**
312
+ * Sets the rotational velocity of the actor in radians/sec
313
+ */
314
+ set angularVelocity(angularVelocity) {
315
+ this.motion.angularVelocity = angularVelocity;
316
+ }
317
+ get scale() {
318
+ return this.get(TransformComponent).scale;
319
+ }
320
+ set scale(scale) {
321
+ this.get(TransformComponent).scale = scale;
322
+ }
323
+ get anchor() {
324
+ return this._anchor;
325
+ }
326
+ set anchor(vec) {
327
+ this._anchor = watch(vec, (v) => this._handleAnchorChange(v));
328
+ this._handleAnchorChange(vec);
329
+ }
330
+ _handleAnchorChange(v) {
331
+ if (this.graphics) {
332
+ this.graphics.anchor = v;
333
+ }
334
+ }
335
+ /**
336
+ * Indicates whether the actor is physically in the viewport
337
+ */
338
+ get isOffScreen() {
339
+ return this.hasTag('offscreen');
340
+ }
341
+ /**
342
+ * The visibility of an actor
343
+ * @deprecated Use [[GraphicsComponent.visible|Actor.graphics.visible]], will be removed in v0.26.0
344
+ */
345
+ get visible() {
346
+ return this.graphics.visible;
347
+ }
348
+ set visible(isVisible) {
349
+ this.graphics.visible = isVisible;
350
+ }
351
+ /**
352
+ * The opacity of an actor.
353
+ *
354
+ * @deprecated Actor.opacity will be removed in v0.26.0, use [[GraphicsComponent.opacity|Actor.graphics.opacity]].
355
+ */
356
+ get opacity() {
357
+ return this.graphics.opacity;
358
+ }
359
+ set opacity(opacity) {
360
+ this.graphics.opacity = opacity;
361
+ }
362
+ get draggable() {
363
+ return this._draggable;
364
+ }
365
+ set draggable(isDraggable) {
366
+ if (isDraggable) {
367
+ if (isDraggable && !this._draggable) {
368
+ this.on('pointerdragstart', this._pointerDragStartHandler);
369
+ this.on('pointerdragend', this._pointerDragEndHandler);
370
+ this.on('pointerdragmove', this._pointerDragMoveHandler);
371
+ this.on('pointerdragleave', this._pointerDragLeaveHandler);
372
+ }
373
+ else if (!isDraggable && this._draggable) {
374
+ this.off('pointerdragstart', this._pointerDragStartHandler);
375
+ this.off('pointerdragend', this._pointerDragEndHandler);
376
+ this.off('pointerdragmove', this._pointerDragMoveHandler);
377
+ this.off('pointerdragleave', this._pointerDragLeaveHandler);
378
+ }
379
+ this._draggable = isDraggable;
380
+ }
381
+ }
382
+ /**
383
+ * Sets the color of the actor's current graphic
384
+ */
385
+ get color() {
386
+ return this._color;
387
+ }
388
+ set color(v) {
389
+ var _a;
390
+ this._color = v.clone();
391
+ const defaultLayer = this.graphics.layers.default;
392
+ const currentGraphic = (_a = defaultLayer.graphics[0]) === null || _a === void 0 ? void 0 : _a.graphic;
393
+ if (currentGraphic instanceof Raster || currentGraphic instanceof Text) {
394
+ currentGraphic.color = this._color;
395
+ }
396
+ }
397
+ /**
398
+ * `onInitialize` is called before the first update of the actor. This method is meant to be
399
+ * overridden. This is where initialization of child actors should take place.
400
+ *
401
+ * Synonymous with the event handler `.on('initialize', (evt) => {...})`
402
+ */
403
+ onInitialize(_engine) {
404
+ // Override me
405
+ }
406
+ /**
407
+ * Initializes this actor and all it's child actors, meant to be called by the Scene before first update not by users of Excalibur.
408
+ *
409
+ * It is not recommended that internal excalibur methods be overridden, do so at your own risk.
410
+ *
411
+ * @internal
412
+ */
413
+ _initialize(engine) {
414
+ super._initialize(engine);
415
+ for (const child of this.children) {
416
+ child._initialize(engine);
417
+ }
418
+ }
419
+ on(eventName, handler) {
420
+ super.on(eventName, handler);
421
+ }
422
+ once(eventName, handler) {
423
+ super.once(eventName, handler);
424
+ }
425
+ off(eventName, handler) {
426
+ super.off(eventName, handler);
427
+ }
428
+ // #endregion
429
+ /**
430
+ * It is not recommended that internal excalibur methods be overridden, do so at your own risk.
431
+ *
432
+ * Internal _prekill handler for [[onPreKill]] lifecycle event
433
+ * @internal
434
+ */
435
+ _prekill(_scene) {
436
+ super.emit('prekill', new PreKillEvent(this));
437
+ this.onPreKill(_scene);
438
+ }
439
+ /**
440
+ * Safe to override onPreKill lifecycle event handler. Synonymous with `.on('prekill', (evt) =>{...})`
441
+ *
442
+ * `onPreKill` is called directly before an actor is killed and removed from its current [[Scene]].
443
+ */
444
+ onPreKill(_scene) {
445
+ // Override me
446
+ }
447
+ /**
448
+ * It is not recommended that internal excalibur methods be overridden, do so at your own risk.
449
+ *
450
+ * Internal _prekill handler for [[onPostKill]] lifecycle event
451
+ * @internal
452
+ */
453
+ _postkill(_scene) {
454
+ super.emit('postkill', new PostKillEvent(this));
455
+ this.onPostKill(_scene);
456
+ }
457
+ /**
458
+ * Safe to override onPostKill lifecycle event handler. Synonymous with `.on('postkill', (evt) => {...})`
459
+ *
460
+ * `onPostKill` is called directly after an actor is killed and remove from its current [[Scene]].
461
+ */
462
+ onPostKill(_scene) {
463
+ // Override me
464
+ }
465
+ /**
466
+ * If the current actor is a member of the scene, this will remove
467
+ * it from the scene graph. It will no longer be drawn or updated.
468
+ */
469
+ kill() {
470
+ if (this.scene) {
471
+ this._prekill(this.scene);
472
+ this.emit('kill', new KillEvent(this));
473
+ super.kill();
474
+ this._postkill(this.scene);
475
+ }
476
+ else {
477
+ this.logger.warn('Cannot kill actor, it was never added to the Scene');
478
+ }
479
+ }
480
+ /**
481
+ * If the current actor is killed, it will now not be killed.
482
+ */
483
+ unkill() {
484
+ this.active = true;
485
+ }
486
+ /**
487
+ * Indicates wether the actor has been killed.
488
+ */
489
+ isKilled() {
490
+ return !this.active;
491
+ }
492
+ setDrawing(key) {
493
+ key = key.toString();
494
+ if (this.currentDrawing !== this.frames[key]) {
495
+ if (this.frames[key] != null) {
496
+ this.frames[key].reset();
497
+ this.currentDrawing = this.frames[key];
498
+ }
499
+ else {
500
+ Logger.getInstance().error(`the specified drawing key ${key} does not exist`);
501
+ }
502
+ }
503
+ if (this.currentDrawing && this.currentDrawing instanceof Animation) {
504
+ this.currentDrawing.tick(0);
505
+ }
506
+ }
507
+ addDrawing() {
508
+ if (arguments.length === 2) {
509
+ this.frames[arguments[0]] = arguments[1];
510
+ if (!this.currentDrawing) {
511
+ this.currentDrawing = arguments[1];
512
+ }
513
+ }
514
+ else {
515
+ if (arguments[0] instanceof Sprite) {
516
+ this.addDrawing('default', arguments[0]);
517
+ }
518
+ if (arguments[0] instanceof Texture) {
519
+ this.addDrawing('default', arguments[0].asSprite());
520
+ }
521
+ }
522
+ }
523
+ /**
524
+ * Gets the z-index of an actor. The z-index determines the relative order an actor is drawn in.
525
+ * Actors with a higher z-index are drawn on top of actors with a lower z-index
526
+ */
527
+ get z() {
528
+ return this.get(TransformComponent).z;
529
+ }
530
+ /**
531
+ * @deprecated Use [[Actor.z]], will be removed in v0.26.0
532
+ */
533
+ getZIndex() {
534
+ return this.get(TransformComponent).z;
535
+ }
536
+ /**
537
+ * Sets the z-index of an actor and updates it in the drawing list for the scene.
538
+ * The z-index determines the relative order an actor is drawn in.
539
+ * Actors with a higher z-index are drawn on top of actors with a lower z-index
540
+ * @param newZ new z-index to assign
541
+ */
542
+ set z(newZ) {
543
+ this.get(TransformComponent).z = newZ;
544
+ }
545
+ /**
546
+ * @param newIndex new z-index to assign
547
+ * @deprecated Use [[Actor.z]], will be removed in v0.26.0
548
+ */
549
+ setZIndex(newIndex) {
550
+ this.get(TransformComponent).z = newIndex;
551
+ }
552
+ /**
553
+ * Get the center point of an actor (global position)
554
+ */
555
+ get center() {
556
+ const globalPos = this.getGlobalPos();
557
+ return new Vector(globalPos.x + this.width / 2 - this.anchor.x * this.width, globalPos.y + this.height / 2 - this.anchor.y * this.height);
558
+ }
559
+ /**
560
+ * Get the local center point of an actor
561
+ */
562
+ get localCenter() {
563
+ return new Vector(this.pos.x + this.width / 2 - this.anchor.x * this.width, this.pos.y + this.height / 2 - this.anchor.y * this.height);
564
+ }
565
+ get width() {
566
+ return this.collider.localBounds.width * this.getGlobalScale().x;
567
+ }
568
+ get height() {
569
+ return this.collider.localBounds.height * this.getGlobalScale().y;
570
+ }
571
+ /**
572
+ * Gets this actor's rotation taking into account any parent relationships
573
+ *
574
+ * @returns Rotation angle in radians
575
+ */
576
+ getGlobalRotation() {
577
+ return this.get(TransformComponent).globalRotation;
578
+ }
579
+ /**
580
+ * Gets an actor's world position taking into account parent relationships, scaling, rotation, and translation
581
+ *
582
+ * @returns Position in world coordinates
583
+ */
584
+ getGlobalPos() {
585
+ return this.get(TransformComponent).globalPos;
586
+ }
587
+ /**
588
+ * Gets the global scale of the Actor
589
+ */
590
+ getGlobalScale() {
591
+ return this.get(TransformComponent).globalScale;
592
+ }
593
+ // #region Collision
594
+ /**
595
+ * Tests whether the x/y specified are contained in the actor
596
+ * @param x X coordinate to test (in world coordinates)
597
+ * @param y Y coordinate to test (in world coordinates)
598
+ * @param recurse checks whether the x/y are contained in any child actors (if they exist).
599
+ */
600
+ contains(x, y, recurse = false) {
601
+ const point = vec(x, y);
602
+ const collider = this.get(ColliderComponent);
603
+ collider.update();
604
+ const geom = collider.get();
605
+ if (!geom) {
606
+ return false;
607
+ }
608
+ const containment = geom.contains(point);
609
+ if (recurse) {
610
+ return (containment ||
611
+ this.children.some((child) => {
612
+ return child.contains(x, y, true);
613
+ }));
614
+ }
615
+ return containment;
616
+ }
617
+ /**
618
+ * Returns true if the two actor.collider's surfaces are less than or equal to the distance specified from each other
619
+ * @param actor Actor to test
620
+ * @param distance Distance in pixels to test
621
+ */
622
+ within(actor, distance) {
623
+ const collider = this.get(ColliderComponent);
624
+ const otherCollider = actor.get(ColliderComponent);
625
+ const me = collider.get();
626
+ const other = otherCollider.get();
627
+ if (me && other) {
628
+ return me.getClosestLineBetween(other).getLength() <= distance;
629
+ }
630
+ return false;
631
+ }
632
+ // #endregion
633
+ // #region Update
634
+ /**
635
+ * Called by the Engine, updates the state of the actor
636
+ * @internal
637
+ * @param engine The reference to the current game engine
638
+ * @param delta The time elapsed since the last update in milliseconds
639
+ */
640
+ update(engine, delta) {
641
+ this._initialize(engine);
642
+ this._preupdate(engine, delta);
643
+ // Tick animations
644
+ const drawing = this.currentDrawing;
645
+ if (drawing && drawing instanceof Animation) {
646
+ drawing.tick(delta, engine.stats.currFrame.id);
647
+ }
648
+ // Update actor pipeline (movement, collision detection, event propagation, offscreen culling)
649
+ for (const trait of this.traits) {
650
+ trait.update(this, engine, delta);
651
+ }
652
+ this._postupdate(engine, delta);
653
+ }
654
+ /**
655
+ * Safe to override onPreUpdate lifecycle event handler. Synonymous with `.on('preupdate', (evt) =>{...})`
656
+ *
657
+ * `onPreUpdate` is called directly before an actor is updated.
658
+ */
659
+ onPreUpdate(_engine, _delta) {
660
+ // Override me
661
+ }
662
+ /**
663
+ * Safe to override onPostUpdate lifecycle event handler. Synonymous with `.on('postupdate', (evt) =>{...})`
664
+ *
665
+ * `onPostUpdate` is called directly after an actor is updated.
666
+ */
667
+ onPostUpdate(_engine, _delta) {
668
+ // Override me
669
+ }
670
+ /**
671
+ * It is not recommended that internal excalibur methods be overridden, do so at your own risk.
672
+ *
673
+ * Internal _preupdate handler for [[onPreUpdate]] lifecycle event
674
+ * @internal
675
+ */
676
+ _preupdate(engine, delta) {
677
+ this.emit('preupdate', new PreUpdateEvent(engine, delta, this));
678
+ this.onPreUpdate(engine, delta);
679
+ }
680
+ /**
681
+ * It is not recommended that internal excalibur methods be overridden, do so at your own risk.
682
+ *
683
+ * Internal _preupdate handler for [[onPostUpdate]] lifecycle event
684
+ * @internal
685
+ */
686
+ _postupdate(engine, delta) {
687
+ this.emit('postupdate', new PreUpdateEvent(engine, delta, this));
688
+ this.onPostUpdate(engine, delta);
689
+ }
690
+ // endregion
691
+ // #region Drawing
692
+ /**
693
+ * Called by the Engine, draws the actor to the screen
694
+ * @param ctx The rendering context
695
+ * @param delta The time since the last draw in milliseconds
696
+ *
697
+ * **Warning** only works with Flags.useLegacyDrawing() enabled
698
+ * @deprecated Use Actor.graphics, will be removed in v0.26.0
699
+ */
700
+ draw(ctx, delta) {
701
+ var _a;
702
+ // translate canvas by anchor offset
703
+ ctx.save();
704
+ if (this.currentDrawing) {
705
+ ctx.translate(-(this.width * this.anchor.x), -(this.height * this.anchor.y));
706
+ this._predraw(ctx, delta);
707
+ const drawing = this.currentDrawing;
708
+ // See https://github.com/excaliburjs/Excalibur/pull/619 for discussion on this formula
709
+ const offsetX = (this.width - drawing.width * drawing.scale.x) * this.anchor.x;
710
+ const offsetY = (this.height - drawing.height * drawing.scale.y) * this.anchor.y;
711
+ this.currentDrawing.draw({ ctx, x: offsetX, y: offsetY, opacity: this.graphics.opacity });
712
+ }
713
+ else {
714
+ this._predraw(ctx, delta);
715
+ if (this.color && this.collider) {
716
+ // update collider geometry based on transform
717
+ const collider = this.get(ColliderComponent);
718
+ collider.update();
719
+ if (collider && !collider.bounds.hasZeroDimensions()) {
720
+ // Colliders are already shifted by anchor, unshift
721
+ ctx.globalAlpha = this.graphics.opacity;
722
+ (_a = collider.get()) === null || _a === void 0 ? void 0 : _a.draw(ctx, this.color, vec(0, 0));
723
+ }
724
+ }
725
+ }
726
+ ctx.restore();
727
+ this._postdraw(ctx, delta);
728
+ }
729
+ /**
730
+ * Safe to override onPreDraw lifecycle event handler. Synonymous with `.on('predraw', (evt) =>{...})`
731
+ *
732
+ * `onPreDraw` is called directly before an actor is drawn, but after local transforms are made.
733
+ *
734
+ * **Warning** only works with Flags.useLegacyDrawing() enabled
735
+ * @deprecated Use Actor.graphics.onPostDraw, will be removed in v0.26.0
736
+ */
737
+ onPreDraw(_ctx, _delta) {
738
+ // Override me
739
+ }
740
+ /**
741
+ * Safe to override onPostDraw lifecycle event handler. Synonymous with `.on('postdraw', (evt) =>{...})`
742
+ *
743
+ * `onPostDraw` is called directly after an actor is drawn, and before local transforms are removed.
744
+ *
745
+ * **Warning** only works with Flags.useLegacyDrawing() enabled
746
+ * @deprecated Use Actor.graphics.onPostDraw, will be removed in v0.26.0
747
+ */
748
+ onPostDraw(_ctx, _delta) {
749
+ // Override me
750
+ }
751
+ /**
752
+ * It is not recommended that internal excalibur methods be overridden, do so at your own risk.
753
+ *
754
+ * Internal _predraw handler for [[onPreDraw]] lifecycle event
755
+ *
756
+ * **Warning** only works with Flags.useLegacyDrawing() enabled
757
+ * @deprecated Use Actor.graphics.onPreDraw, will be removed in v0.26.0
758
+ * @internal
759
+ */
760
+ _predraw(ctx, delta) {
761
+ this.emit('predraw', new PreDrawEvent(ctx, delta, this));
762
+ this.onPreDraw(ctx, delta);
763
+ }
764
+ /**
765
+ * It is not recommended that internal excalibur methods be overridden, do so at your own risk.
766
+ *
767
+ * Internal _postdraw handler for [[onPostDraw]] lifecycle event
768
+ *
769
+ * **Warning** only works with Flags.useLegacyDrawing() enabled
770
+ * @deprecated Use Actor.graphics.onPostDraw, will be removed in v0.26.0
771
+ * @internal
772
+ */
773
+ _postdraw(ctx, delta) {
774
+ this.emit('postdraw', new PreDrawEvent(ctx, delta, this));
775
+ this.onPostDraw(ctx, delta);
776
+ }
777
+ /**
778
+ * Called by the Engine, draws the actors debugging to the screen
779
+ * @param ctx The rendering context
780
+ *
781
+ *
782
+ * **Warning** only works with Flags.useLegacyDrawing() enabled
783
+ * @deprecated will be removed in v0.26.0
784
+ * @internal
785
+ */
786
+ /* istanbul ignore next */
787
+ debugDraw(_ctx) {
788
+ // pass
789
+ }
790
+ }
791
+ // #region Properties
792
+ /**
793
+ * Set defaults for all Actors
794
+ */
795
+ Actor.defaults = {
796
+ anchor: Vector.Half
797
+ };
798
+ __decorate([
799
+ obsolete({ message: 'Actor.visible will be removed in v0.26.0', alternateMethod: 'Use Actor.graphics.visible' })
800
+ ], Actor.prototype, "visible", null);
801
+ __decorate([
802
+ obsolete({
803
+ message: 'Actor.opacity will be removed in v0.26.0',
804
+ alternateMethod: 'Use Actor.graphics.opacity'
805
+ })
806
+ ], Actor.prototype, "opacity", null);
807
+ __decorate([
808
+ obsolete({
809
+ message: 'Actor.setDrawing will be removed in v0.26.0',
810
+ alternateMethod: 'Use Actor.graphics.show() or Actor.graphics.use()'
811
+ })
812
+ ], Actor.prototype, "setDrawing", null);
813
+ __decorate([
814
+ obsolete({
815
+ message: 'Actor.addDrawing will be removed in v0.26.0',
816
+ alternateMethod: 'Use Actor.graphics.add()'
817
+ })
818
+ ], Actor.prototype, "addDrawing", null);
819
+ __decorate([
820
+ obsolete({
821
+ message: 'Actor.getZIndex will be removed in v0.26.0',
822
+ alternateMethod: 'Use Actor.transform.z or Actor.z'
823
+ })
824
+ ], Actor.prototype, "getZIndex", null);
825
+ __decorate([
826
+ obsolete({
827
+ message: 'Actor.setZIndex will be removed in v0.26.0',
828
+ alternateMethod: 'Use Actor.transform.z or Actor.z'
829
+ })
830
+ ], Actor.prototype, "setZIndex", null);
831
+ //# sourceMappingURL=Actor.js.map