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,985 @@
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 { EX_VERSION } from './';
8
+ import { Flags, Legacy } from './Flags';
9
+ import { polyfill } from './Polyfill';
10
+ polyfill();
11
+ import { Screen, DisplayMode, Resolution } from './Screen';
12
+ import { Loader } from './Loader';
13
+ import { Detector } from './Util/Detector';
14
+ import { VisibleEvent, HiddenEvent, GameStartEvent, GameStopEvent, PreUpdateEvent, PostUpdateEvent, PreFrameEvent, PostFrameEvent, DeactivateEvent, ActivateEvent, PreDrawEvent, PostDrawEvent, InitializeEvent } from './Events';
15
+ import { Logger, LogLevel } from './Util/Log';
16
+ import { Color } from './Color';
17
+ import { Scene } from './Scene';
18
+ import { Entity } from './EntityComponentSystem/Entity';
19
+ import { Debug } from './Debug/Debug';
20
+ import { Class } from './Class';
21
+ import * as Input from './Input/Index';
22
+ import { BrowserEvents } from './Util/Browser';
23
+ import { obsolete } from './Util/Decorators';
24
+ import { ExcaliburGraphicsContext2DCanvas, ExcaliburGraphicsContextWebGL, TextureLoader } from './Graphics';
25
+ import { PointerEventReceiver } from './Input/PointerEventReceiver';
26
+ import { FpsSampler } from './Util/Fps';
27
+ import { StandardClock } from './Util/Clock';
28
+ import { ImageFiltering } from './Graphics/Filtering';
29
+ import { GraphicsDiagnostics } from './Graphics/GraphicsDiagnostics';
30
+ /**
31
+ * Enum representing the different mousewheel event bubble prevention
32
+ */
33
+ export var ScrollPreventionMode;
34
+ (function (ScrollPreventionMode) {
35
+ /**
36
+ * Do not prevent any page scrolling
37
+ */
38
+ ScrollPreventionMode[ScrollPreventionMode["None"] = 0] = "None";
39
+ /**
40
+ * Prevent page scroll if mouse is over the game canvas
41
+ */
42
+ ScrollPreventionMode[ScrollPreventionMode["Canvas"] = 1] = "Canvas";
43
+ /**
44
+ * Prevent all page scrolling via mouse wheel
45
+ */
46
+ ScrollPreventionMode[ScrollPreventionMode["All"] = 2] = "All";
47
+ })(ScrollPreventionMode || (ScrollPreventionMode = {}));
48
+ /**
49
+ * The Excalibur Engine
50
+ *
51
+ * The [[Engine]] is the main driver for a game. It is responsible for
52
+ * starting/stopping the game, maintaining state, transmitting events,
53
+ * loading resources, and managing the scene.
54
+ */
55
+ export class Engine extends Class {
56
+ /**
57
+ * Creates a new game using the given [[EngineOptions]]. By default, if no options are provided,
58
+ * the game will be rendered full screen (taking up all available browser window space).
59
+ * You can customize the game rendering through [[EngineOptions]].
60
+ *
61
+ * Example:
62
+ *
63
+ * ```js
64
+ * var game = new ex.Engine({
65
+ * width: 0, // the width of the canvas
66
+ * height: 0, // the height of the canvas
67
+ * enableCanvasTransparency: true, // the transparencySection of the canvas
68
+ * canvasElementId: '', // the DOM canvas element ID, if you are providing your own
69
+ * displayMode: ex.DisplayMode.FullScreen, // the display mode
70
+ * pointerScope: ex.Input.PointerScope.Document, // the scope of capturing pointer (mouse/touch) events
71
+ * backgroundColor: ex.Color.fromHex('#2185d0') // background color of the engine
72
+ * });
73
+ *
74
+ * // call game.start, which is a Promise
75
+ * game.start().then(function () {
76
+ * // ready, set, go!
77
+ * });
78
+ * ```
79
+ */
80
+ constructor(options) {
81
+ var _a, _b, _c, _d;
82
+ super();
83
+ /**
84
+ * Optionally set the maximum fps if not set Excalibur will go as fast as the device allows.
85
+ *
86
+ * You may want to constrain max fps if your game cannot maintain fps consistently, it can look and feel better to have a 30fps game than
87
+ * one that bounces between 30fps and 60fps
88
+ */
89
+ this.maxFps = Number.POSITIVE_INFINITY;
90
+ this._hasStarted = false;
91
+ /**
92
+ * Contains all the scenes currently registered with Excalibur
93
+ */
94
+ this.scenes = {};
95
+ /**
96
+ * @hidden
97
+ * @deprecated will be removed in v0.26.0
98
+ */
99
+ this._animations = [];
100
+ this._suppressPlayButton = false;
101
+ /**
102
+ * Indicates whether audio should be paused when the game is no longer visible.
103
+ */
104
+ this.pauseAudioWhenHidden = true;
105
+ /**
106
+ * Indicates whether the engine should draw with debug information
107
+ */
108
+ this._isDebug = false;
109
+ /**
110
+ * No longer used
111
+ * @deprecated will be removed in v0.26.0
112
+ */
113
+ this.debugColor = new Color(255, 255, 255);
114
+ /**
115
+ * Sets the Transparency for the engine.
116
+ */
117
+ this.enableCanvasTransparency = true;
118
+ /**
119
+ * The action to take when a fatal exception is thrown
120
+ */
121
+ this.onFatalException = (e) => {
122
+ Logger.getInstance().fatal(e);
123
+ };
124
+ this._timescale = 1.0;
125
+ this._isInitialized = false;
126
+ this._deferredGoTo = null;
127
+ this._loadingComplete = false;
128
+ this._isReady = false;
129
+ this._isReadyPromise = new Promise(resolve => {
130
+ this._isReadyResolve = resolve;
131
+ });
132
+ this._screenShotRequests = [];
133
+ options = { ...Engine._DEFAULT_ENGINE_OPTIONS, ...options };
134
+ Flags.freeze();
135
+ // Initialize browser events facade
136
+ this.browser = new BrowserEvents(window, document);
137
+ // Check compatibility
138
+ const detector = new Detector();
139
+ if (!options.suppressMinimumBrowserFeatureDetection && !(this._compatible = detector.test())) {
140
+ const message = document.createElement('div');
141
+ message.innerText = 'Sorry, your browser does not support all the features needed for Excalibur';
142
+ document.body.appendChild(message);
143
+ detector.failedTests.forEach(function (test) {
144
+ const testMessage = document.createElement('div');
145
+ testMessage.innerText = 'Browser feature missing ' + test;
146
+ document.body.appendChild(testMessage);
147
+ });
148
+ if (options.canvasElementId) {
149
+ const canvas = document.getElementById(options.canvasElementId);
150
+ if (canvas) {
151
+ canvas.parentElement.removeChild(canvas);
152
+ }
153
+ }
154
+ return;
155
+ }
156
+ else {
157
+ this._compatible = true;
158
+ }
159
+ // Use native console API for color fun
160
+ // eslint-disable-next-line no-console
161
+ if (console.log && !options.suppressConsoleBootMessage) {
162
+ // eslint-disable-next-line no-console
163
+ console.log(`%cPowered by Excalibur.js (v${EX_VERSION})`, 'background: #176BAA; color: white; border-radius: 5px; padding: 15px; font-size: 1.5em; line-height: 80px;');
164
+ // eslint-disable-next-line no-console
165
+ console.log('\n\
166
+ /| ________________\n\
167
+ O|===|* >________________>\n\
168
+ \\|');
169
+ // eslint-disable-next-line no-console
170
+ console.log('Visit', 'http://excaliburjs.com', 'for more information');
171
+ }
172
+ // Suppress play button
173
+ if (options.suppressPlayButton) {
174
+ this._suppressPlayButton = true;
175
+ }
176
+ this._logger = Logger.getInstance();
177
+ // If debug is enabled, let's log browser features to the console.
178
+ if (this._logger.defaultLevel === LogLevel.Debug) {
179
+ detector.logBrowserFeatures();
180
+ }
181
+ this._logger.debug('Building engine...');
182
+ this.canvasElementId = options.canvasElementId;
183
+ if (options.canvasElementId) {
184
+ this._logger.debug('Using Canvas element specified: ' + options.canvasElementId);
185
+ this.canvas = document.getElementById(options.canvasElementId);
186
+ }
187
+ else if (options.canvasElement) {
188
+ this._logger.debug('Using Canvas element specified:', options.canvasElement);
189
+ this.canvas = options.canvasElement;
190
+ }
191
+ else {
192
+ this._logger.debug('Using generated canvas element');
193
+ this.canvas = document.createElement('canvas');
194
+ }
195
+ let displayMode = (_a = options.displayMode) !== null && _a !== void 0 ? _a : DisplayMode.Fixed;
196
+ if ((options.width && options.height) || options.viewport) {
197
+ if (options.displayMode === undefined) {
198
+ displayMode = DisplayMode.Fixed;
199
+ }
200
+ this._logger.debug('Engine viewport is size ' + options.width + ' x ' + options.height);
201
+ }
202
+ else if (!options.displayMode) {
203
+ this._logger.debug('Engine viewport is fit');
204
+ displayMode = DisplayMode.FitScreen;
205
+ }
206
+ if (Flags.isEnabled(Legacy.Canvas)) {
207
+ const ex2dCtx = new ExcaliburGraphicsContext2DCanvas({
208
+ canvasElement: this.canvas,
209
+ enableTransparency: this.enableCanvasTransparency,
210
+ smoothing: options.antialiasing,
211
+ backgroundColor: options.backgroundColor,
212
+ snapToPixel: options.snapToPixel
213
+ });
214
+ this.graphicsContext = ex2dCtx;
215
+ this.ctx = ex2dCtx.__ctx;
216
+ }
217
+ else {
218
+ const exWebglCtx = new ExcaliburGraphicsContextWebGL({
219
+ canvasElement: this.canvas,
220
+ enableTransparency: this.enableCanvasTransparency,
221
+ smoothing: options.antialiasing,
222
+ backgroundColor: options.backgroundColor,
223
+ snapToPixel: options.snapToPixel
224
+ });
225
+ this.graphicsContext = exWebglCtx;
226
+ this.ctx = exWebglCtx.__ctx;
227
+ }
228
+ this.screen = new Screen({
229
+ canvas: this.canvas,
230
+ context: this.graphicsContext,
231
+ antialiasing: (_b = options.antialiasing) !== null && _b !== void 0 ? _b : true,
232
+ browser: this.browser,
233
+ viewport: (_c = options.viewport) !== null && _c !== void 0 ? _c : (options.width && options.height ? { width: options.width, height: options.height } : Resolution.SVGA),
234
+ resolution: options.resolution,
235
+ displayMode,
236
+ position: options.position,
237
+ pixelRatio: options.suppressHiDPIScaling ? 1 : null
238
+ });
239
+ TextureLoader.filtering = options.antialiasing ? ImageFiltering.Blended : ImageFiltering.Pixel;
240
+ if (options.backgroundColor) {
241
+ this.backgroundColor = options.backgroundColor.clone();
242
+ }
243
+ this.maxFps = (_d = options.maxFps) !== null && _d !== void 0 ? _d : this.maxFps;
244
+ this.clock = new StandardClock({
245
+ maxFps: this.maxFps,
246
+ tick: this._mainloop.bind(this),
247
+ onFatalException: (e) => this.onFatalException(e)
248
+ });
249
+ this.enableCanvasTransparency = options.enableCanvasTransparency;
250
+ this._loader = new Loader();
251
+ this._loader.wireEngine(this);
252
+ this.debug = new Debug(this);
253
+ this._initialize(options);
254
+ this.rootScene = this.currentScene = new Scene();
255
+ this.addScene('root', this.rootScene);
256
+ window.___EXCALIBUR_DEVTOOL = this;
257
+ }
258
+ /**
259
+ * The width of the game canvas in pixels (physical width component of the
260
+ * resolution of the canvas element)
261
+ */
262
+ get canvasWidth() {
263
+ return this.screen.canvasWidth;
264
+ }
265
+ /**
266
+ * Returns half width of the game canvas in pixels (half physical width component)
267
+ */
268
+ get halfCanvasWidth() {
269
+ return this.screen.halfCanvasWidth;
270
+ }
271
+ /**
272
+ * The height of the game canvas in pixels, (physical height component of
273
+ * the resolution of the canvas element)
274
+ */
275
+ get canvasHeight() {
276
+ return this.screen.canvasHeight;
277
+ }
278
+ /**
279
+ * Returns half height of the game canvas in pixels (half physical height component)
280
+ */
281
+ get halfCanvasHeight() {
282
+ return this.screen.halfCanvasHeight;
283
+ }
284
+ /**
285
+ * Returns the width of the engine's visible drawing surface in pixels including zoom and device pixel ratio.
286
+ */
287
+ get drawWidth() {
288
+ return this.screen.drawWidth;
289
+ }
290
+ /**
291
+ * Returns half the width of the engine's visible drawing surface in pixels including zoom and device pixel ratio.
292
+ */
293
+ get halfDrawWidth() {
294
+ return this.screen.halfDrawWidth;
295
+ }
296
+ /**
297
+ * Returns the height of the engine's visible drawing surface in pixels including zoom and device pixel ratio.
298
+ */
299
+ get drawHeight() {
300
+ return this.screen.drawHeight;
301
+ }
302
+ /**
303
+ * Returns half the height of the engine's visible drawing surface in pixels including zoom and device pixel ratio.
304
+ */
305
+ get halfDrawHeight() {
306
+ return this.screen.halfDrawHeight;
307
+ }
308
+ /**
309
+ * Returns whether excalibur detects the current screen to be HiDPI
310
+ */
311
+ get isHiDpi() {
312
+ return this.screen.isHiDpi;
313
+ }
314
+ /**
315
+ * Access [[stats]] that holds frame statistics.
316
+ */
317
+ get stats() {
318
+ return this.debug.stats;
319
+ }
320
+ /**
321
+ * Indicates whether the engine is set to fullscreen or not
322
+ */
323
+ get isFullscreen() {
324
+ return this.screen.isFullScreen;
325
+ }
326
+ /**
327
+ * Indicates the current [[DisplayMode]] of the engine.
328
+ */
329
+ get displayMode() {
330
+ return this.screen.displayMode;
331
+ }
332
+ /**
333
+ * Returns the calculated pixel ration for use in rendering
334
+ */
335
+ get pixelRatio() {
336
+ return this.screen.pixelRatio;
337
+ }
338
+ get isDebug() {
339
+ return this._isDebug;
340
+ }
341
+ /**
342
+ * Hints the graphics context to truncate fractional world space coordinates
343
+ */
344
+ get snapToPixel() {
345
+ return this.graphicsContext.snapToPixel;
346
+ }
347
+ ;
348
+ set snapToPixel(shouldSnapToPixel) {
349
+ this.graphicsContext.snapToPixel = shouldSnapToPixel;
350
+ }
351
+ ;
352
+ on(eventName, handler) {
353
+ super.on(eventName, handler);
354
+ }
355
+ once(eventName, handler) {
356
+ super.once(eventName, handler);
357
+ }
358
+ off(eventName, handler) {
359
+ super.off(eventName, handler);
360
+ }
361
+ /**
362
+ * Returns a BoundingBox of the top left corner of the screen
363
+ * and the bottom right corner of the screen.
364
+ */
365
+ getWorldBounds() {
366
+ return this.screen.getWorldBounds();
367
+ }
368
+ /**
369
+ * Gets the current engine timescale factor (default is 1.0 which is 1:1 time)
370
+ */
371
+ get timescale() {
372
+ return this._timescale;
373
+ }
374
+ /**
375
+ * Sets the current engine timescale factor. Useful for creating slow-motion effects or fast-forward effects
376
+ * when using time-based movement.
377
+ */
378
+ set timescale(value) {
379
+ if (value <= 0) {
380
+ Logger.getInstance().error('Cannot set engine.timescale to a value of 0 or less than 0.');
381
+ return;
382
+ }
383
+ this._timescale = value;
384
+ }
385
+ /**
386
+ * Plays a sprite animation on the screen at the specified `x` and `y`
387
+ * (in game coordinates, not screen pixels). These animations play
388
+ * independent of actors, and will be cleaned up internally as soon
389
+ * as they are complete. Note animations that loop will never be
390
+ * cleaned up.
391
+ *
392
+ * @param animation Animation to play
393
+ * @param x x game coordinate to play the animation
394
+ * @param y y game coordinate to play the animation
395
+ * @deprecated
396
+ */
397
+ playAnimation(animation, x, y) {
398
+ this._animations.push(new AnimationNode(animation, x, y));
399
+ }
400
+ /**
401
+ * Adds a [[TileMap]] to the [[currentScene]], once this is done the TileMap
402
+ * will be drawn and updated.
403
+ */
404
+ addTileMap(tileMap) {
405
+ this.currentScene.addTileMap(tileMap);
406
+ }
407
+ /**
408
+ * Removes a [[TileMap]] from the [[currentScene]], it will no longer be drawn or updated.
409
+ */
410
+ removeTileMap(tileMap) {
411
+ this.currentScene.removeTileMap(tileMap);
412
+ }
413
+ /**
414
+ * Adds a [[Timer]] to the [[currentScene]].
415
+ * @param timer The timer to add to the [[currentScene]].
416
+ */
417
+ addTimer(timer) {
418
+ return this.currentScene.addTimer(timer);
419
+ }
420
+ /**
421
+ * Removes a [[Timer]] from the [[currentScene]].
422
+ * @param timer The timer to remove to the [[currentScene]].
423
+ */
424
+ removeTimer(timer) {
425
+ return this.currentScene.removeTimer(timer);
426
+ }
427
+ /**
428
+ * Adds a [[Scene]] to the engine, think of scenes in Excalibur as you
429
+ * would levels or menus.
430
+ *
431
+ * @param key The name of the scene, must be unique
432
+ * @param scene The scene to add to the engine
433
+ */
434
+ addScene(key, scene) {
435
+ if (this.scenes[key]) {
436
+ this._logger.warn('Scene', key, 'already exists overwriting');
437
+ }
438
+ this.scenes[key] = scene;
439
+ }
440
+ /**
441
+ * @internal
442
+ */
443
+ removeScene(entity) {
444
+ if (entity instanceof Scene) {
445
+ // remove scene
446
+ for (const key in this.scenes) {
447
+ if (this.scenes.hasOwnProperty(key)) {
448
+ if (this.scenes[key] === entity) {
449
+ delete this.scenes[key];
450
+ }
451
+ }
452
+ }
453
+ }
454
+ if (typeof entity === 'string') {
455
+ // remove scene
456
+ delete this.scenes[entity];
457
+ }
458
+ }
459
+ add(entity) {
460
+ if (arguments.length === 2) {
461
+ this.addScene(arguments[0], arguments[1]);
462
+ return;
463
+ }
464
+ if (this._deferredGoTo && this.scenes[this._deferredGoTo]) {
465
+ this.scenes[this._deferredGoTo].add(entity);
466
+ }
467
+ else {
468
+ this.currentScene.add(entity);
469
+ }
470
+ }
471
+ remove(entity) {
472
+ if (entity instanceof Entity) {
473
+ this.currentScene.remove(entity);
474
+ }
475
+ if (entity instanceof Scene) {
476
+ this.removeScene(entity);
477
+ }
478
+ if (typeof entity === 'string') {
479
+ this.removeScene(entity);
480
+ }
481
+ }
482
+ /**
483
+ * Changes the currently updating and drawing scene to a different,
484
+ * named scene. Calls the [[Scene]] lifecycle events.
485
+ * @param key The key of the scene to transition to.
486
+ */
487
+ goToScene(key) {
488
+ // if not yet initialized defer goToScene
489
+ if (!this.isInitialized) {
490
+ this._deferredGoTo = key;
491
+ return;
492
+ }
493
+ if (this.scenes[key]) {
494
+ const oldScene = this.currentScene;
495
+ const newScene = this.scenes[key];
496
+ this._logger.debug('Going to scene:', key);
497
+ // only deactivate when initialized
498
+ if (this.currentScene.isInitialized) {
499
+ this.currentScene._deactivate.apply(this.currentScene, [oldScene, newScene]);
500
+ this.currentScene.eventDispatcher.emit('deactivate', new DeactivateEvent(newScene, this.currentScene));
501
+ }
502
+ // set current scene to new one
503
+ this.currentScene = newScene;
504
+ this.screen.setCurrentCamera(newScene.camera);
505
+ // initialize the current scene if has not been already
506
+ this.currentScene._initialize(this);
507
+ this.currentScene._activate.apply(this.currentScene, [oldScene, newScene]);
508
+ this.currentScene.eventDispatcher.emit('activate', new ActivateEvent(oldScene, this.currentScene));
509
+ }
510
+ else {
511
+ this._logger.error('Scene', key, 'does not exist!');
512
+ }
513
+ }
514
+ /**
515
+ * Transforms the current x, y from screen coordinates to world coordinates
516
+ * @param point Screen coordinate to convert
517
+ */
518
+ screenToWorldCoordinates(point) {
519
+ return this.screen.screenToWorldCoordinates(point);
520
+ }
521
+ /**
522
+ * Transforms a world coordinate, to a screen coordinate
523
+ * @param point World coordinate to convert
524
+ */
525
+ worldToScreenCoordinates(point) {
526
+ return this.screen.worldToScreenCoordinates(point);
527
+ }
528
+ /**
529
+ * Initializes the internal canvas, rendering context, display mode, and native event listeners
530
+ */
531
+ _initialize(options) {
532
+ this.pageScrollPreventionMode = options.scrollPreventionMode;
533
+ // initialize inputs
534
+ const pointerTarget = options && options.pointerScope === Input.PointerScope.Document ? document : this.canvas;
535
+ this.input = {
536
+ keyboard: new Input.Keyboard(),
537
+ pointers: new PointerEventReceiver(pointerTarget, this),
538
+ gamepads: new Input.Gamepads()
539
+ };
540
+ this.input.keyboard.init();
541
+ this.input.pointers.init();
542
+ this.input.gamepads.init();
543
+ // Issue #385 make use of the visibility api
544
+ // https://developer.mozilla.org/en-US/docs/Web/Guide/User_experience/Using_the_Page_Visibility_API
545
+ let hidden, visibilityChange;
546
+ if (typeof document.hidden !== 'undefined') {
547
+ // Opera 12.10 and Firefox 18 and later support
548
+ hidden = 'hidden';
549
+ visibilityChange = 'visibilitychange';
550
+ }
551
+ else if ('msHidden' in document) {
552
+ hidden = 'msHidden';
553
+ visibilityChange = 'msvisibilitychange';
554
+ }
555
+ else if ('webkitHidden' in document) {
556
+ hidden = 'webkitHidden';
557
+ visibilityChange = 'webkitvisibilitychange';
558
+ }
559
+ this.browser.document.on(visibilityChange, () => {
560
+ if (document[hidden]) {
561
+ this.eventDispatcher.emit('hidden', new HiddenEvent(this));
562
+ this._logger.debug('Window hidden');
563
+ }
564
+ else {
565
+ this.eventDispatcher.emit('visible', new VisibleEvent(this));
566
+ this._logger.debug('Window visible');
567
+ }
568
+ });
569
+ if (!this.canvasElementId && !options.canvasElement) {
570
+ document.body.appendChild(this.canvas);
571
+ }
572
+ }
573
+ onInitialize(_engine) {
574
+ // Override me
575
+ }
576
+ /**
577
+ * If supported by the browser, this will set the antialiasing flag on the
578
+ * canvas. Set this to `false` if you want a 'jagged' pixel art look to your
579
+ * image resources.
580
+ * @param isSmooth Set smoothing to true or false
581
+ */
582
+ setAntialiasing(isSmooth) {
583
+ this.screen.antialiasing = isSmooth;
584
+ }
585
+ /**
586
+ * Return the current smoothing status of the canvas
587
+ */
588
+ getAntialiasing() {
589
+ return this.screen.antialiasing;
590
+ }
591
+ /**
592
+ * Gets whether the actor is Initialized
593
+ */
594
+ get isInitialized() {
595
+ return this._isInitialized;
596
+ }
597
+ _overrideInitialize(engine) {
598
+ if (!this.isInitialized) {
599
+ this.onInitialize(engine);
600
+ super.emit('initialize', new InitializeEvent(engine, this));
601
+ this._isInitialized = true;
602
+ if (this._deferredGoTo) {
603
+ this.goToScene(this._deferredGoTo);
604
+ }
605
+ else {
606
+ this.goToScene('root');
607
+ }
608
+ }
609
+ }
610
+ /**
611
+ * Updates the entire state of the game
612
+ * @param delta Number of milliseconds elapsed since the last update.
613
+ */
614
+ _update(delta) {
615
+ if (!this.ready) {
616
+ // suspend updates until loading is finished
617
+ this._loader.update(this, delta);
618
+ // Update input listeners
619
+ this.input.keyboard.update();
620
+ this.input.gamepads.update();
621
+ return;
622
+ }
623
+ // Publish preupdate events
624
+ this._preupdate(delta);
625
+ // process engine level events
626
+ this.currentScene.update(this, delta);
627
+ // update animations
628
+ // TODO remove
629
+ this._animations = this._animations.filter(function (a) {
630
+ return !a.animation.isDone();
631
+ });
632
+ // Update input listeners
633
+ this.input.keyboard.update();
634
+ this.input.gamepads.update();
635
+ // Publish update event
636
+ this._postupdate(delta);
637
+ }
638
+ /**
639
+ * @internal
640
+ */
641
+ _preupdate(delta) {
642
+ this.emit('preupdate', new PreUpdateEvent(this, delta, this));
643
+ this.onPreUpdate(this, delta);
644
+ }
645
+ onPreUpdate(_engine, _delta) {
646
+ // Override me
647
+ }
648
+ /**
649
+ * @internal
650
+ */
651
+ _postupdate(delta) {
652
+ this.emit('postupdate', new PostUpdateEvent(this, delta, this));
653
+ this.onPostUpdate(this, delta);
654
+ }
655
+ onPostUpdate(_engine, _delta) {
656
+ // Override me
657
+ }
658
+ /**
659
+ * Draws the entire game
660
+ * @param delta Number of milliseconds elapsed since the last draw.
661
+ */
662
+ _draw(delta) {
663
+ const ctx = this.ctx;
664
+ this.graphicsContext.beginDrawLifecycle();
665
+ this.graphicsContext.clear();
666
+ this._predraw(ctx, delta);
667
+ // Drawing nothing else while loading
668
+ if (!this._isReady) {
669
+ this._loader.canvas.draw(this.graphicsContext, 0, 0);
670
+ this.graphicsContext.flush();
671
+ return;
672
+ }
673
+ // TODO move to graphics systems?
674
+ this.graphicsContext.backgroundColor = this.backgroundColor;
675
+ this.currentScene.draw(this.ctx, delta);
676
+ // todo needs to be a better way of doing this
677
+ let a = 0;
678
+ const len = this._animations.length;
679
+ for (a; a < len; a++) {
680
+ this._animations[a].animation.draw(ctx, this._animations[a].x, this._animations[a].y);
681
+ }
682
+ // Draw debug information
683
+ // TODO don't access ctx directly
684
+ if (this.isDebug) {
685
+ this.ctx.font = 'Consolas';
686
+ this.ctx.fillStyle = this.debugColor.toString();
687
+ const keys = this.input.keyboard.getKeys();
688
+ for (let j = 0; j < keys.length; j++) {
689
+ this.ctx.fillText(keys[j].toString() + ' : ' + (Input.Keys[keys[j]] ? Input.Keys[keys[j]] : 'Not Mapped'), 100, 10 * j + 10);
690
+ }
691
+ this.ctx.fillText('FPS:' + this.stats.currFrame.fps.toFixed(2).toString(), 10, 10);
692
+ }
693
+ this._postdraw(ctx, delta);
694
+ // Flush any pending drawings
695
+ this.graphicsContext.flush();
696
+ this.graphicsContext.endDrawLifecycle();
697
+ this._checkForScreenShots();
698
+ }
699
+ /**
700
+ * @internal
701
+ */
702
+ _predraw(_ctx, delta) {
703
+ this.emit('predraw', new PreDrawEvent(_ctx, delta, this));
704
+ this.onPreDraw(_ctx, delta);
705
+ }
706
+ onPreDraw(_ctx, _delta) {
707
+ // Override me
708
+ }
709
+ /**
710
+ * @internal
711
+ */
712
+ _postdraw(_ctx, delta) {
713
+ this.emit('postdraw', new PostDrawEvent(_ctx, delta, this));
714
+ this.onPostDraw(_ctx, delta);
715
+ }
716
+ onPostDraw(_ctx, _delta) {
717
+ // Override me
718
+ }
719
+ /**
720
+ * Enable or disable Excalibur debugging functionality.
721
+ * @param toggle a value that debug drawing will be changed to
722
+ */
723
+ showDebug(toggle) {
724
+ this._isDebug = toggle;
725
+ }
726
+ /**
727
+ * Toggle Excalibur debugging functionality.
728
+ */
729
+ toggleDebug() {
730
+ this._isDebug = !this._isDebug;
731
+ return this._isDebug;
732
+ }
733
+ /**
734
+ * Returns true when loading is totally complete and the player has clicked start
735
+ */
736
+ get loadingComplete() {
737
+ return this._loadingComplete;
738
+ }
739
+ get ready() {
740
+ return this._isReady;
741
+ }
742
+ isReady() {
743
+ return this._isReadyPromise;
744
+ }
745
+ /**
746
+ * Starts the internal game loop for Excalibur after loading
747
+ * any provided assets.
748
+ * @param loader Optional [[Loader]] to use to load resources. The default loader is [[Loader]], override to provide your own
749
+ * custom loader.
750
+ *
751
+ * Note: start() only resolves AFTER the user has clicked the play button
752
+ */
753
+ async start(loader) {
754
+ if (!this._compatible) {
755
+ throw new Error('Excalibur is incompatible with your browser');
756
+ }
757
+ // Wire loader if we have it
758
+ if (loader) {
759
+ // Push the current user entered resolution/viewport
760
+ this.screen.pushResolutionAndViewport();
761
+ // Configure resolution for loader, it expects resolution === viewport
762
+ this.screen.resolution = this.screen.viewport;
763
+ this.screen.applyResolutionAndViewport();
764
+ this._loader = loader;
765
+ this._loader.suppressPlayButton = this._suppressPlayButton || this._loader.suppressPlayButton;
766
+ this._loader.wireEngine(this);
767
+ }
768
+ // Start the excalibur clock which drives the mainloop
769
+ // has started is a slight misnomer, it's really mainloop started
770
+ this._logger.debug('Starting game clock...');
771
+ this.browser.resume();
772
+ this.clock.start();
773
+ this._logger.debug('Game clock started');
774
+ if (loader) {
775
+ await this.load(this._loader);
776
+ this._loadingComplete = true;
777
+ // reset back to previous user resolution/viewport
778
+ this.screen.popResolutionAndViewport();
779
+ this.screen.applyResolutionAndViewport();
780
+ }
781
+ this._loadingComplete = true;
782
+ // Initialize before ready
783
+ this._overrideInitialize(this);
784
+ this._isReady = true;
785
+ this._isReadyResolve();
786
+ this.emit('start', new GameStartEvent(this));
787
+ return this._isReadyPromise;
788
+ }
789
+ _mainloop(elapsed) {
790
+ this.emit('preframe', new PreFrameEvent(this, this.stats.prevFrame));
791
+ const delta = elapsed * this.timescale;
792
+ // reset frame stats (reuse existing instances)
793
+ const frameId = this.stats.prevFrame.id + 1;
794
+ this.stats.currFrame.reset();
795
+ this.stats.currFrame.id = frameId;
796
+ this.stats.currFrame.delta = delta;
797
+ this.stats.currFrame.fps = this.clock.fpsSampler.fps;
798
+ GraphicsDiagnostics.clear();
799
+ const beforeUpdate = this.clock.now();
800
+ this._update(delta);
801
+ const afterUpdate = this.clock.now();
802
+ this._draw(delta);
803
+ const afterDraw = this.clock.now();
804
+ this.stats.currFrame.duration.update = afterUpdate - beforeUpdate;
805
+ this.stats.currFrame.duration.draw = afterDraw - afterUpdate;
806
+ this.stats.currFrame.graphics.drawnImages = GraphicsDiagnostics.DrawnImagesCount;
807
+ this.stats.currFrame.graphics.drawCalls = GraphicsDiagnostics.DrawCallCount;
808
+ this.emit('postframe', new PostFrameEvent(this, this.stats.currFrame));
809
+ this.stats.prevFrame.reset(this.stats.currFrame);
810
+ }
811
+ /**
812
+ *
813
+ * @param game
814
+ * @param raf
815
+ * @param nowFn
816
+ * @deprecated Use [[Clock]] to run the mainloop, will be removed in v0.26.0
817
+ */
818
+ static createMainLoop(game, raf, nowFn) {
819
+ let lastTime = nowFn();
820
+ const fpsSampler = new FpsSampler({
821
+ nowFn,
822
+ initialFps: game.maxFps === Infinity ? 60 : game.maxFps
823
+ });
824
+ return function mainloop() {
825
+ if (!game._hasStarted) {
826
+ return;
827
+ }
828
+ try {
829
+ game._requestId = raf(mainloop);
830
+ fpsSampler.start();
831
+ game.emit('preframe', new PreFrameEvent(game, game.stats.prevFrame));
832
+ // Get the time to calculate time-elapsed
833
+ const now = nowFn();
834
+ let elapsed = now - lastTime || 1; // first frame
835
+ // Constrain fps
836
+ const fpsInterval = game.maxFps === Number.POSITIVE_INFINITY ? 0 : 1000 / game.maxFps;
837
+ if (elapsed <= fpsInterval) {
838
+ return; // too fast 😎 skip this frame
839
+ }
840
+ // Resolves issue #138 if the game has been paused, or blurred for
841
+ // more than a 200 milliseconds, reset elapsed time to 1. This improves reliability
842
+ // and provides more expected behavior when the engine comes back
843
+ // into focus
844
+ if (elapsed > 200) {
845
+ elapsed = 1;
846
+ }
847
+ const delta = elapsed * game.timescale;
848
+ // reset frame stats (reuse existing instances)
849
+ const frameId = game.stats.prevFrame.id + 1;
850
+ game.stats.currFrame.reset();
851
+ game.stats.currFrame.id = frameId;
852
+ game.stats.currFrame.delta = delta;
853
+ game.stats.currFrame.fps = fpsSampler.fps;
854
+ const beforeUpdate = nowFn();
855
+ game._update(delta);
856
+ const afterUpdate = nowFn();
857
+ game._draw(delta);
858
+ const afterDraw = nowFn();
859
+ game.stats.currFrame.duration.update = afterUpdate - beforeUpdate;
860
+ game.stats.currFrame.duration.draw = afterDraw - afterUpdate;
861
+ // if fps interval is not a multiple
862
+ if (fpsInterval > 0) {
863
+ lastTime = now - (elapsed % fpsInterval);
864
+ }
865
+ else {
866
+ lastTime = now;
867
+ }
868
+ game.emit('postframe', new PostFrameEvent(game, game.stats.currFrame));
869
+ fpsSampler.end();
870
+ game.stats.prevFrame.reset(game.stats.currFrame);
871
+ }
872
+ catch (e) {
873
+ window.cancelAnimationFrame(game._requestId);
874
+ game.stop();
875
+ game.onFatalException(e);
876
+ }
877
+ };
878
+ }
879
+ /**
880
+ * Stops Excalibur's main loop, useful for pausing the game.
881
+ */
882
+ stop() {
883
+ if (this.clock.isRunning()) {
884
+ this.emit('stop', new GameStopEvent(this));
885
+ this.browser.pause();
886
+ this.clock.stop();
887
+ this._logger.debug('Game stopped');
888
+ }
889
+ }
890
+ /**
891
+ * Returns the Engine's Running status, Useful for checking whether engine is running or paused.
892
+ * @deprecated will be removed in v0.26.0, use isRunning()
893
+ */
894
+ isPaused() {
895
+ return !this.clock.isRunning();
896
+ }
897
+ /**
898
+ * Returns the Engine's running status, Useful for checking whether engine is running or paused.
899
+ */
900
+ isRunning() {
901
+ return this.clock.isRunning();
902
+ }
903
+ /**
904
+ * Takes a screen shot of the current viewport and returns it as an
905
+ * HTML Image Element.
906
+ * @param preserveHiDPIResolution in the case of HiDPI return the full scaled backing image, by default false
907
+ */
908
+ screenshot(preserveHiDPIResolution = false) {
909
+ const screenShotPromise = new Promise((resolve) => {
910
+ this._screenShotRequests.push({ preserveHiDPIResolution, resolve });
911
+ });
912
+ return screenShotPromise;
913
+ }
914
+ _checkForScreenShots() {
915
+ // We must grab the draw buffer before we yield to the browser
916
+ // the draw buffer is cleared after compositing
917
+ // the reason for the asynchrony is setting `preserveDrawingBuffer: true`
918
+ // forces the browser to copy buffers which can have a mass perf impact on mobile
919
+ for (const request of this._screenShotRequests) {
920
+ const finalWidth = request.preserveHiDPIResolution ? this.canvas.width : this.screen.resolution.width;
921
+ const finalHeight = request.preserveHiDPIResolution ? this.canvas.height : this.screen.resolution.height;
922
+ const screenshot = document.createElement('canvas');
923
+ screenshot.width = finalWidth;
924
+ screenshot.height = finalHeight;
925
+ const ctx = screenshot.getContext('2d');
926
+ ctx.drawImage(this.canvas, 0, 0, finalWidth, finalHeight);
927
+ const result = new Image();
928
+ const raw = screenshot.toDataURL('image/png');
929
+ result.src = raw;
930
+ request.resolve(result);
931
+ }
932
+ // Reset state
933
+ this._screenShotRequests.length = 0;
934
+ }
935
+ /**
936
+ * Another option available to you to load resources into the game.
937
+ * Immediately after calling this the game will pause and the loading screen
938
+ * will appear.
939
+ * @param loader Some [[Loadable]] such as a [[Loader]] collection, [[Sound]], or [[Texture]].
940
+ */
941
+ async load(loader) {
942
+ try {
943
+ await loader.load();
944
+ }
945
+ catch (_a) {
946
+ await Promise.resolve();
947
+ }
948
+ }
949
+ }
950
+ /**
951
+ * Default [[EngineOptions]]
952
+ */
953
+ Engine._DEFAULT_ENGINE_OPTIONS = {
954
+ width: 0,
955
+ height: 0,
956
+ enableCanvasTransparency: true,
957
+ canvasElementId: '',
958
+ canvasElement: undefined,
959
+ snapToPixel: false,
960
+ pointerScope: Input.PointerScope.Canvas,
961
+ suppressConsoleBootMessage: null,
962
+ suppressMinimumBrowserFeatureDetection: null,
963
+ suppressHiDPIScaling: null,
964
+ suppressPlayButton: null,
965
+ scrollPreventionMode: ScrollPreventionMode.Canvas,
966
+ backgroundColor: Color.fromHex('#2185d0') // Excalibur blue
967
+ };
968
+ __decorate([
969
+ obsolete({ message: 'Will be removed in excalibur v0.26.0', alternateMethod: 'Use Actor.graphics' })
970
+ ], Engine.prototype, "playAnimation", null);
971
+ /**
972
+ * @internal
973
+ * @deprecated
974
+ */
975
+ let AnimationNode = class AnimationNode {
976
+ constructor(animation, x, y) {
977
+ this.animation = animation;
978
+ this.x = x;
979
+ this.y = y;
980
+ }
981
+ };
982
+ AnimationNode = __decorate([
983
+ obsolete({ message: 'Will be removed in excalibur v0.26.0' })
984
+ ], AnimationNode);
985
+ //# sourceMappingURL=Engine.js.map