melonjs 14.3.0 → 14.5.0

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 (323) hide show
  1. package/README.md +11 -55
  2. package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +2 -2
  3. package/dist/melonjs.mjs/_virtual/arraymultimap.js +2 -2
  4. package/dist/melonjs.mjs/_virtual/earcut.js +2 -2
  5. package/dist/melonjs.mjs/_virtual/howler.js +2 -2
  6. package/dist/melonjs.mjs/_virtual/index.js +2 -2
  7. package/dist/melonjs.mjs/_virtual/index2.js +2 -2
  8. package/dist/melonjs.mjs/_virtual/multimap.js +2 -2
  9. package/dist/melonjs.mjs/_virtual/setmultimap.js +2 -2
  10. package/dist/melonjs.mjs/application/application.js +8 -21
  11. package/dist/melonjs.mjs/application/header.js +2 -2
  12. package/dist/melonjs.mjs/application/resize.js +4 -2
  13. package/dist/melonjs.mjs/application/settings.js +2 -2
  14. package/dist/melonjs.mjs/audio/audio.js +5 -5
  15. package/dist/melonjs.mjs/camera/camera2d.js +2 -2
  16. package/dist/melonjs.mjs/const.js +32 -0
  17. package/dist/melonjs.mjs/entity/entity.js +44 -10
  18. package/dist/melonjs.mjs/geometries/ellipse.js +3 -4
  19. package/dist/melonjs.mjs/geometries/line.js +2 -2
  20. package/dist/melonjs.mjs/geometries/path2d.js +19 -43
  21. package/dist/melonjs.mjs/geometries/point.js +2 -7
  22. package/dist/melonjs.mjs/geometries/poly.js +3 -6
  23. package/dist/melonjs.mjs/geometries/rectangle.js +14 -10
  24. package/dist/melonjs.mjs/geometries/roundrect.js +2 -2
  25. package/dist/melonjs.mjs/index.js +11 -9
  26. package/dist/melonjs.mjs/input/gamepad.js +11 -17
  27. package/dist/melonjs.mjs/input/input.js +2 -2
  28. package/dist/melonjs.mjs/input/keyboard.js +2 -2
  29. package/dist/melonjs.mjs/input/pointer.js +2 -2
  30. package/dist/melonjs.mjs/input/pointerevent.js +3 -17
  31. package/dist/melonjs.mjs/lang/console.js +44 -0
  32. package/dist/melonjs.mjs/lang/deprecated.js +4 -40
  33. package/dist/melonjs.mjs/level/level.js +4 -4
  34. package/dist/melonjs.mjs/level/tiled/TMXGroup.js +2 -23
  35. package/dist/melonjs.mjs/level/tiled/TMXLayer.js +67 -64
  36. package/dist/melonjs.mjs/level/tiled/TMXObject.js +2 -64
  37. package/dist/melonjs.mjs/level/tiled/TMXTile.js +10 -26
  38. package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +21 -83
  39. package/dist/melonjs.mjs/level/tiled/TMXTileset.js +6 -20
  40. package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +3 -10
  41. package/dist/melonjs.mjs/level/tiled/TMXUtils.js +37 -14
  42. package/dist/melonjs.mjs/level/tiled/constants.js +17 -0
  43. package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +7 -8
  44. package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +3 -6
  45. package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -2
  46. package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +2 -14
  47. package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +2 -2
  48. package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +38 -0
  49. package/dist/melonjs.mjs/loader/cache.js +24 -0
  50. package/dist/melonjs.mjs/loader/loader.js +332 -715
  51. package/dist/melonjs.mjs/loader/loadingscreen.js +5 -5
  52. package/dist/melonjs.mjs/loader/melonjs_logo.png.js +2 -2
  53. package/dist/melonjs.mjs/loader/parser.js +281 -0
  54. package/dist/melonjs.mjs/loader/settings.js +91 -0
  55. package/dist/melonjs.mjs/math/color.js +2 -2
  56. package/dist/melonjs.mjs/math/math.js +2 -2
  57. package/dist/melonjs.mjs/math/matrix2.js +8 -10
  58. package/dist/melonjs.mjs/math/matrix3.js +19 -22
  59. package/dist/melonjs.mjs/math/observable_vector2.js +4 -4
  60. package/dist/melonjs.mjs/math/observable_vector3.js +4 -5
  61. package/dist/melonjs.mjs/math/vector2.js +4 -4
  62. package/dist/melonjs.mjs/math/vector3.js +4 -5
  63. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/arraymultimap.js +2 -2
  64. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/index.js +2 -2
  65. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/multimap.js +2 -2
  66. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/setmultimap.js +2 -2
  67. package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +2 -2
  68. package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +2 -2
  69. package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +2 -2
  70. package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +2 -2
  71. package/dist/melonjs.mjs/particles/emitter.js +4 -4
  72. package/dist/melonjs.mjs/particles/particle.js +2 -2
  73. package/dist/melonjs.mjs/particles/settings.js +2 -2
  74. package/dist/melonjs.mjs/physics/body.js +19 -15
  75. package/dist/melonjs.mjs/physics/bounds.js +19 -71
  76. package/dist/melonjs.mjs/physics/collision.js +3 -3
  77. package/dist/melonjs.mjs/physics/detector.js +2 -2
  78. package/dist/melonjs.mjs/physics/quadtree.js +2 -2
  79. package/dist/melonjs.mjs/physics/response.js +2 -2
  80. package/dist/melonjs.mjs/physics/sat.js +2 -2
  81. package/dist/melonjs.mjs/physics/world.js +2 -2
  82. package/dist/melonjs.mjs/plugin/plugin.js +4 -4
  83. package/dist/melonjs.mjs/renderable/collectable.js +2 -2
  84. package/dist/melonjs.mjs/renderable/colorlayer.js +2 -2
  85. package/dist/melonjs.mjs/renderable/container.js +26 -20
  86. package/dist/melonjs.mjs/renderable/dragndrop.js +2 -2
  87. package/dist/melonjs.mjs/renderable/imagelayer.js +8 -2
  88. package/dist/melonjs.mjs/renderable/light2d.js +2 -2
  89. package/dist/melonjs.mjs/renderable/nineslicesprite.js +2 -2
  90. package/dist/melonjs.mjs/renderable/renderable.js +127 -106
  91. package/dist/melonjs.mjs/renderable/sprite.js +34 -55
  92. package/dist/melonjs.mjs/renderable/trigger.js +2 -2
  93. package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +2 -2
  94. package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +2 -2
  95. package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +2 -2
  96. package/dist/melonjs.mjs/state/stage.js +2 -2
  97. package/dist/melonjs.mjs/state/state.js +3 -3
  98. package/dist/melonjs.mjs/system/device.js +2 -2
  99. package/dist/melonjs.mjs/system/dom.js +2 -2
  100. package/dist/melonjs.mjs/system/event.js +2 -2
  101. package/dist/melonjs.mjs/system/platform.js +2 -2
  102. package/dist/melonjs.mjs/system/pooling.js +9 -19
  103. package/dist/melonjs.mjs/system/save.js +2 -2
  104. package/dist/melonjs.mjs/system/timer.js +2 -2
  105. package/dist/melonjs.mjs/text/bitmaptext.js +67 -9
  106. package/dist/melonjs.mjs/text/bitmaptextdata.js +2 -2
  107. package/dist/melonjs.mjs/text/glyph.js +2 -2
  108. package/dist/melonjs.mjs/text/text.js +2 -2
  109. package/dist/melonjs.mjs/text/textmetrics.js +2 -2
  110. package/dist/melonjs.mjs/text/textstyle.js +2 -2
  111. package/dist/melonjs.mjs/tweens/easing.js +2 -2
  112. package/dist/melonjs.mjs/tweens/interpolation.js +2 -2
  113. package/dist/melonjs.mjs/tweens/tween.js +2 -2
  114. package/dist/melonjs.mjs/utils/agent.js +2 -2
  115. package/dist/melonjs.mjs/utils/array.js +2 -2
  116. package/dist/melonjs.mjs/utils/file.js +2 -2
  117. package/dist/melonjs.mjs/utils/function.js +2 -2
  118. package/dist/melonjs.mjs/utils/string.js +3 -3
  119. package/dist/melonjs.mjs/utils/utils.js +3 -5
  120. package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +2 -2
  121. package/dist/melonjs.mjs/video/renderer.js +2 -2
  122. package/dist/melonjs.mjs/video/texture/atlas.js +11 -10
  123. package/dist/melonjs.mjs/video/texture/cache.js +4 -4
  124. package/dist/melonjs.mjs/video/texture/canvas_texture.js +2 -2
  125. package/dist/melonjs.mjs/video/utils/autodetect.js +2 -2
  126. package/dist/melonjs.mjs/video/video.js +17 -14
  127. package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +2 -2
  128. package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +235 -0
  129. package/{src/video/webgl → dist/melonjs.mjs/video/webgl/compositors}/webgl_compositor.js +28 -205
  130. package/dist/melonjs.mjs/video/webgl/glshader.js +2 -2
  131. package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +2 -2
  132. package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +2 -2
  133. package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +2 -2
  134. package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +2 -2
  135. package/dist/melonjs.mjs/video/webgl/utils/attributes.js +2 -2
  136. package/dist/melonjs.mjs/video/webgl/utils/precision.js +2 -2
  137. package/dist/melonjs.mjs/video/webgl/utils/program.js +2 -2
  138. package/dist/melonjs.mjs/video/webgl/utils/string.js +2 -2
  139. package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +2 -2
  140. package/dist/melonjs.mjs/video/webgl/webgl_compositor.js +3 -3
  141. package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +3 -3
  142. package/dist/melonjs.module.js +19807 -19896
  143. package/dist/types/application/application.d.ts +5 -1
  144. package/dist/types/application/resize.d.ts +1 -0
  145. package/dist/types/const.d.ts +21 -0
  146. package/dist/types/entity/entity.d.ts +2 -2
  147. package/dist/types/geometries/path2d.d.ts +5 -31
  148. package/dist/types/geometries/point.d.ts +2 -7
  149. package/dist/types/geometries/poly.d.ts +0 -1
  150. package/dist/types/index.d.ts +3 -2
  151. package/dist/types/lang/console.d.ts +7 -0
  152. package/dist/types/lang/deprecated.d.ts +0 -8
  153. package/dist/types/level/tiled/TMXGroup.d.ts +7 -28
  154. package/dist/types/level/tiled/TMXLayer.d.ts +25 -47
  155. package/dist/types/level/tiled/TMXObject.d.ts +20 -82
  156. package/dist/types/level/tiled/TMXTile.d.ts +11 -25
  157. package/dist/types/level/tiled/TMXTileMap.d.ts +18 -56
  158. package/dist/types/level/tiled/TMXTileset.d.ts +7 -21
  159. package/dist/types/level/tiled/TMXTilesetGroup.d.ts +3 -9
  160. package/dist/types/level/tiled/constants.d.ts +5 -0
  161. package/dist/types/level/tiled/renderer/TMXHexagonalRenderer.d.ts +2 -6
  162. package/dist/types/level/tiled/renderer/TMXIsometricRenderer.d.ts +2 -6
  163. package/dist/types/level/tiled/renderer/TMXRenderer.d.ts +6 -18
  164. package/dist/types/level/tiled/renderer/autodetect.d.ts +9 -0
  165. package/dist/types/loader/cache.d.ts +7 -0
  166. package/dist/types/loader/loader.d.ts +166 -181
  167. package/dist/types/loader/parser.d.ts +41 -0
  168. package/dist/types/loader/settings.d.ts +57 -0
  169. package/dist/types/particles/emitter.d.ts +4 -4
  170. package/dist/types/physics/bounds.d.ts +29 -84
  171. package/dist/types/renderable/container.d.ts +0 -11
  172. package/dist/types/renderable/renderable.d.ts +37 -31
  173. package/dist/types/renderable/sprite.d.ts +3 -3
  174. package/dist/types/state/state.d.ts +1 -1
  175. package/dist/types/system/pooling.d.ts +2 -2
  176. package/dist/types/video/renderer.d.ts +1 -1
  177. package/dist/types/video/video.d.ts +7 -6
  178. package/dist/types/video/webgl/compositors/compositor.d.ts +101 -0
  179. package/dist/types/video/webgl/compositors/webgl_compositor.d.ts +86 -0
  180. package/dist/types/video/webgl/webgl_compositor.d.ts +2 -3
  181. package/dist/types/video/webgl/webgl_renderer.d.ts +1 -1
  182. package/package.json +17 -16
  183. package/src/application/application.js +6 -19
  184. package/src/application/resize.js +2 -0
  185. package/src/audio/audio.js +3 -3
  186. package/src/const.js +23 -0
  187. package/src/entity/entity.js +42 -8
  188. package/src/geometries/ellipse.js +1 -2
  189. package/src/geometries/path2d.js +17 -41
  190. package/src/geometries/point.js +0 -5
  191. package/src/geometries/poly.js +1 -4
  192. package/src/geometries/rectangle.js +12 -8
  193. package/src/index.js +4 -2
  194. package/src/input/gamepad.js +9 -15
  195. package/src/input/pointerevent.js +1 -15
  196. package/src/lang/console.js +36 -0
  197. package/src/lang/deprecated.js +2 -37
  198. package/src/level/level.js +2 -2
  199. package/src/level/tiled/TMXGroup.js +0 -21
  200. package/src/level/tiled/TMXLayer.js +65 -62
  201. package/src/level/tiled/TMXObject.js +0 -62
  202. package/src/level/tiled/TMXTile.js +8 -24
  203. package/src/level/tiled/TMXTileMap.js +19 -81
  204. package/src/level/tiled/TMXTileset.js +4 -18
  205. package/src/level/tiled/TMXTilesetGroup.js +1 -9
  206. package/src/level/tiled/TMXUtils.js +38 -15
  207. package/src/level/tiled/constants.js +8 -0
  208. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +5 -6
  209. package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -4
  210. package/src/level/tiled/renderer/TMXRenderer.js +0 -12
  211. package/src/level/tiled/renderer/autodetect.js +29 -0
  212. package/src/loader/cache.js +16 -0
  213. package/src/loader/loader.js +339 -709
  214. package/src/loader/loadingscreen.js +3 -3
  215. package/src/loader/parser.js +279 -0
  216. package/src/loader/settings.js +85 -0
  217. package/src/math/matrix2.js +6 -8
  218. package/src/math/matrix3.js +17 -20
  219. package/src/math/observable_vector2.js +2 -2
  220. package/src/math/observable_vector3.js +2 -3
  221. package/src/math/vector2.js +2 -2
  222. package/src/math/vector3.js +2 -3
  223. package/src/particles/emitter.js +2 -2
  224. package/src/physics/body.js +17 -13
  225. package/src/physics/bounds.js +17 -69
  226. package/src/physics/collision.js +1 -1
  227. package/src/renderable/container.js +24 -18
  228. package/src/renderable/imagelayer.js +6 -0
  229. package/src/renderable/renderable.js +125 -104
  230. package/src/renderable/sprite.js +32 -53
  231. package/src/state/state.js +1 -1
  232. package/src/system/pooling.js +7 -17
  233. package/src/text/bitmaptext.js +65 -7
  234. package/src/utils/string.js +1 -1
  235. package/src/utils/utils.js +1 -3
  236. package/src/video/texture/atlas.js +9 -8
  237. package/src/video/texture/cache.js +2 -2
  238. package/src/video/video.js +15 -12
  239. package/src/video/webgl/compositors/compositor.js +227 -0
  240. package/src/video/webgl/compositors/webgl_compositor.js +300 -0
  241. package/src/video/webgl/webgl_renderer.js +1 -1
  242. package/dist/melonjs.mjs/node_modules/core-js/es/string/trim-end.js +0 -13
  243. package/dist/melonjs.mjs/node_modules/core-js/es/string/trim-start.js +0 -13
  244. package/dist/melonjs.mjs/node_modules/core-js/internals/a-callable.js +0 -22
  245. package/dist/melonjs.mjs/node_modules/core-js/internals/an-object.js +0 -21
  246. package/dist/melonjs.mjs/node_modules/core-js/internals/array-includes.js +0 -45
  247. package/dist/melonjs.mjs/node_modules/core-js/internals/classof-raw.js +0 -19
  248. package/dist/melonjs.mjs/node_modules/core-js/internals/classof.js +0 -43
  249. package/dist/melonjs.mjs/node_modules/core-js/internals/copy-constructor-properties.js +0 -32
  250. package/dist/melonjs.mjs/node_modules/core-js/internals/create-non-enumerable-property.js +0 -24
  251. package/dist/melonjs.mjs/node_modules/core-js/internals/create-property-descriptor.js +0 -17
  252. package/dist/melonjs.mjs/node_modules/core-js/internals/define-built-in.js +0 -43
  253. package/dist/melonjs.mjs/node_modules/core-js/internals/define-global-property.js +0 -23
  254. package/dist/melonjs.mjs/node_modules/core-js/internals/descriptors.js +0 -18
  255. package/dist/melonjs.mjs/node_modules/core-js/internals/document-all.js +0 -18
  256. package/dist/melonjs.mjs/node_modules/core-js/internals/document-create-element.js +0 -22
  257. package/dist/melonjs.mjs/node_modules/core-js/internals/engine-user-agent.js +0 -14
  258. package/dist/melonjs.mjs/node_modules/core-js/internals/engine-v8-version.js +0 -39
  259. package/dist/melonjs.mjs/node_modules/core-js/internals/entry-unbind.js +0 -18
  260. package/dist/melonjs.mjs/node_modules/core-js/internals/enum-bug-keys.js +0 -19
  261. package/dist/melonjs.mjs/node_modules/core-js/internals/export.js +0 -72
  262. package/dist/melonjs.mjs/node_modules/core-js/internals/fails.js +0 -16
  263. package/dist/melonjs.mjs/node_modules/core-js/internals/function-bind-native.js +0 -19
  264. package/dist/melonjs.mjs/node_modules/core-js/internals/function-call.js +0 -18
  265. package/dist/melonjs.mjs/node_modules/core-js/internals/function-name.js +0 -29
  266. package/dist/melonjs.mjs/node_modules/core-js/internals/function-uncurry-this.js +0 -22
  267. package/dist/melonjs.mjs/node_modules/core-js/internals/get-built-in.js +0 -22
  268. package/dist/melonjs.mjs/node_modules/core-js/internals/get-method.js +0 -21
  269. package/dist/melonjs.mjs/node_modules/core-js/internals/global.js +0 -25
  270. package/dist/melonjs.mjs/node_modules/core-js/internals/has-own-property.js +0 -23
  271. package/dist/melonjs.mjs/node_modules/core-js/internals/hidden-keys.js +0 -10
  272. package/dist/melonjs.mjs/node_modules/core-js/internals/ie8-dom-define.js +0 -24
  273. package/dist/melonjs.mjs/node_modules/core-js/internals/indexed-object.js +0 -28
  274. package/dist/melonjs.mjs/node_modules/core-js/internals/inspect-source.js +0 -27
  275. package/dist/melonjs.mjs/node_modules/core-js/internals/internal-state.js +0 -88
  276. package/dist/melonjs.mjs/node_modules/core-js/internals/is-callable.js +0 -22
  277. package/dist/melonjs.mjs/node_modules/core-js/internals/is-forced.js +0 -34
  278. package/dist/melonjs.mjs/node_modules/core-js/internals/is-null-or-undefined.js +0 -14
  279. package/dist/melonjs.mjs/node_modules/core-js/internals/is-object.js +0 -22
  280. package/dist/melonjs.mjs/node_modules/core-js/internals/is-symbol.js +0 -27
  281. package/dist/melonjs.mjs/node_modules/core-js/internals/length-of-array-like.js +0 -18
  282. package/dist/melonjs.mjs/node_modules/core-js/internals/make-built-in.js +0 -68
  283. package/dist/melonjs.mjs/node_modules/core-js/internals/math-trunc.js +0 -19
  284. package/dist/melonjs.mjs/node_modules/core-js/internals/object-define-property.js +0 -58
  285. package/dist/melonjs.mjs/node_modules/core-js/internals/object-get-own-property-descriptor.js +0 -41
  286. package/dist/melonjs.mjs/node_modules/core-js/internals/object-get-own-property-names.js +0 -23
  287. package/dist/melonjs.mjs/node_modules/core-js/internals/object-get-own-property-symbols.js +0 -12
  288. package/dist/melonjs.mjs/node_modules/core-js/internals/object-is-prototype-of.js +0 -14
  289. package/dist/melonjs.mjs/node_modules/core-js/internals/object-keys-internal.js +0 -35
  290. package/dist/melonjs.mjs/node_modules/core-js/internals/object-property-is-enumerable.js +0 -23
  291. package/dist/melonjs.mjs/node_modules/core-js/internals/ordinary-to-primitive.js +0 -28
  292. package/dist/melonjs.mjs/node_modules/core-js/internals/own-keys.js +0 -31
  293. package/dist/melonjs.mjs/node_modules/core-js/internals/require-object-coercible.js +0 -21
  294. package/dist/melonjs.mjs/node_modules/core-js/internals/shared-key.js +0 -21
  295. package/dist/melonjs.mjs/node_modules/core-js/internals/shared-store.js +0 -19
  296. package/dist/melonjs.mjs/node_modules/core-js/internals/shared.js +0 -24
  297. package/dist/melonjs.mjs/node_modules/core-js/internals/string-trim-end.js +0 -22
  298. package/dist/melonjs.mjs/node_modules/core-js/internals/string-trim-forced.js +0 -28
  299. package/dist/melonjs.mjs/node_modules/core-js/internals/string-trim-start.js +0 -22
  300. package/dist/melonjs.mjs/node_modules/core-js/internals/string-trim.js +0 -45
  301. package/dist/melonjs.mjs/node_modules/core-js/internals/symbol-constructor-detection.js +0 -26
  302. package/dist/melonjs.mjs/node_modules/core-js/internals/to-absolute-index.js +0 -23
  303. package/dist/melonjs.mjs/node_modules/core-js/internals/to-indexed-object.js +0 -19
  304. package/dist/melonjs.mjs/node_modules/core-js/internals/to-integer-or-infinity.js +0 -20
  305. package/dist/melonjs.mjs/node_modules/core-js/internals/to-length.js +0 -20
  306. package/dist/melonjs.mjs/node_modules/core-js/internals/to-object.js +0 -20
  307. package/dist/melonjs.mjs/node_modules/core-js/internals/to-primitive.js +0 -41
  308. package/dist/melonjs.mjs/node_modules/core-js/internals/to-property-key.js +0 -21
  309. package/dist/melonjs.mjs/node_modules/core-js/internals/to-string-tag-support.js +0 -19
  310. package/dist/melonjs.mjs/node_modules/core-js/internals/to-string.js +0 -19
  311. package/dist/melonjs.mjs/node_modules/core-js/internals/try-to-string.js +0 -18
  312. package/dist/melonjs.mjs/node_modules/core-js/internals/uid.js +0 -20
  313. package/dist/melonjs.mjs/node_modules/core-js/internals/use-symbol-as-uid.js +0 -18
  314. package/dist/melonjs.mjs/node_modules/core-js/internals/v8-prototype-define-bug.js +0 -24
  315. package/dist/melonjs.mjs/node_modules/core-js/internals/weak-map-basic-detection.js +0 -18
  316. package/dist/melonjs.mjs/node_modules/core-js/internals/well-known-symbol.js +0 -41
  317. package/dist/melonjs.mjs/node_modules/core-js/internals/whitespaces.js +0 -12
  318. package/dist/melonjs.mjs/node_modules/core-js/modules/es.global-this.js +0 -18
  319. package/dist/melonjs.mjs/node_modules/core-js/modules/es.string.trim-end.js +0 -22
  320. package/dist/melonjs.mjs/node_modules/core-js/modules/es.string.trim-left.js +0 -19
  321. package/dist/melonjs.mjs/node_modules/core-js/modules/es.string.trim-right.js +0 -19
  322. package/dist/melonjs.mjs/node_modules/core-js/modules/es.string.trim-start.js +0 -22
  323. package/dist/melonjs.mjs/node_modules/eventemitter3/index.mjs.js +0 -9
@@ -23,18 +23,42 @@ import Color from "./../math/color.js";
23
23
  // parent constructor
24
24
  super(x, y, width, height);
25
25
 
26
- /**
27
- * to identify the object as a renderable object
28
- * @ignore
29
- */
30
- this.isRenderable = true;
26
+ if (this.pos instanceof ObservableVector3d) {
27
+ this.pos.setMuted(x, y, 0).setCallback(this.updateBoundsPos, this);
28
+ } else {
29
+ /**
30
+ * Position of the Renderable relative to its parent container
31
+ * @public
32
+ * @type {ObservableVector3d}
33
+ */
34
+ this.pos = pool.pull("ObservableVector3d", x, y, 0, { onUpdate: this.updateBoundsPos, scope: this});
35
+ }
31
36
 
32
- /**
33
- * If true then physic collision and input events will not impact this renderable
34
- * @type {boolean}
35
- * @default true
36
- */
37
- this.isKinematic = true;
37
+ if (this.anchorPoint instanceof ObservableVector2d) {
38
+ this.anchorPoint.setMuted(0.5, 0.5).setCallback(this.onAnchorUpdate, this);
39
+ } else {
40
+ /**
41
+ * The anchor point is used for attachment behavior, and/or when applying transformations.<br>
42
+ * The coordinate system places the origin at the top left corner of the frame (0, 0) and (1, 1) means the bottom-right corner<br>
43
+ * <img src="images/anchor_point.png"/><br>
44
+ * a Renderable's anchor point defaults to (0.5,0.5), which corresponds to the center position.<br>
45
+ * <br>
46
+ * <i><b>Note:</b> Object created through Tiled will have their anchorPoint set to (0, 0) to match Tiled Level editor implementation.
47
+ * To specify a value through Tiled, use a json expression like `json:{"x":0.5,"y":0.5}`. </i>
48
+ * @type {ObservableVector2d}
49
+ * @default <0.5,0.5>
50
+ */
51
+ this.anchorPoint = pool.pull("ObservableVector2d", 0.5, 0.5, { onUpdate: this.onAnchorUpdate, scope: this });
52
+ }
53
+
54
+ if (typeof this.currentTransform === "undefined") {
55
+ /**
56
+ * the renderable default transformation matrix
57
+ * @type {Matrix2d}
58
+ */
59
+ this.currentTransform = pool.pull("Matrix2d");
60
+ }
61
+ this.currentTransform.identity();
38
62
 
39
63
  /**
40
64
  * the renderable physic body
@@ -73,15 +97,6 @@ import Color from "./../math/color.js";
73
97
  */
74
98
  this.body = undefined;
75
99
 
76
- if (typeof this.currentTransform === "undefined") {
77
- /**
78
- * the renderable default transformation matrix
79
- * @type {Matrix2d}
80
- */
81
- this.currentTransform = pool.pull("Matrix2d");
82
- }
83
- this.currentTransform.identity();
84
-
85
100
  /**
86
101
  * (G)ame (U)nique (Id)entifier" <br>
87
102
  * a GUID will be allocated for any renderable object added <br>
@@ -132,23 +147,6 @@ import Color from "./../math/color.js";
132
147
  */
133
148
  this.floating = false;
134
149
 
135
- if (this.anchorPoint instanceof ObservableVector2d) {
136
- this.anchorPoint.setMuted(0.5, 0.5).setCallback(this.onAnchorUpdate, this);
137
- } else {
138
- /**
139
- * The anchor point is used for attachment behavior, and/or when applying transformations.<br>
140
- * The coordinate system places the origin at the top left corner of the frame (0, 0) and (1, 1) means the bottom-right corner<br>
141
- * <img src="images/anchor_point.png"/><br>
142
- * a Renderable's anchor point defaults to (0.5,0.5), which corresponds to the center position.<br>
143
- * <br>
144
- * <i><b>Note:</b> Object created through Tiled will have their anchorPoint set to (0, 0) to match Tiled Level editor implementation.
145
- * To specify a value through Tiled, use a json expression like `json:{"x":0.5,"y":0.5}`. </i>
146
- * @type {ObservableVector2d}
147
- * @default <0.5,0.5>
148
- */
149
- this.anchorPoint = pool.pull("ObservableVector2d", 0.5, 0.5, { onUpdate: this.onAnchorUpdate, scope: this });
150
- }
151
-
152
150
  /**
153
151
  * When enabled, an object container will automatically apply
154
152
  * any defined transformation before calling the child draw method.
@@ -224,23 +222,25 @@ import Color from "./../math/color.js";
224
222
  */
225
223
  this.name = "";
226
224
 
227
- if (this.pos instanceof ObservableVector3d) {
228
- this.pos.setMuted(x, y, 0).setCallback(this.updateBoundsPos, this);
229
- } else {
230
- /**
231
- * Position of the Renderable relative to its parent container
232
- * @public
233
- * @type {ObservableVector3d}
234
- */
235
- this.pos = pool.pull("ObservableVector3d", x, y, 0, { onUpdate: this.updateBoundsPos, scope: this});
236
- }
225
+ /**
226
+ * to identify the object as a renderable object
227
+ * @ignore
228
+ */
229
+ this.isRenderable = true;
230
+
231
+ /**
232
+ * If true then physic collision and input events will not impact this renderable
233
+ * @type {boolean}
234
+ * @default true
235
+ */
236
+ this.isKinematic = true;
237
237
 
238
238
  /**
239
239
  * when true the renderable will be redrawn during the next update cycle
240
240
  * @type {boolean}
241
- * @default false
241
+ * @default true
242
242
  */
243
- this.isDirty = false;
243
+ this.isDirty = true;
244
244
 
245
245
  // keep track of when we flip
246
246
  this._flip = {
@@ -337,7 +337,7 @@ import Color from "./../math/color.js";
337
337
  if (typeof this._bounds === "undefined") {
338
338
  super.getBounds();
339
339
  if (this.isFinite()) {
340
- this._bounds.setMinMax(this.pos.x, this.pos.y, this.pos.x + this.width, this.pos.y + this.height);
340
+ this.updateBounds();
341
341
  } else {
342
342
  // e.g. containers or game world can have infinite size
343
343
  this._bounds.setMinMax(this.pos.x, this.pos.y, this.width, this.height);
@@ -377,8 +377,11 @@ import Color from "./../math/color.js";
377
377
  * @returns {Renderable} Reference to this object for method chaining
378
378
  */
379
379
  flipX(flip = true) {
380
- this._flip.x = !!flip;
381
- this.isDirty = true;
380
+ if (this.isFlippedX !== flip) {
381
+ this._flip.x = !!flip;
382
+ this.scale(-1, 1);
383
+ this.isDirty = true;
384
+ }
382
385
  return this;
383
386
  }
384
387
 
@@ -389,8 +392,11 @@ import Color from "./../math/color.js";
389
392
  * @returns {Renderable} Reference to this object for method chaining
390
393
  */
391
394
  flipY(flip = true) {
392
- this._flip.y = !!flip;
393
- this.isDirty = true;
395
+ if (this.isFlippedY !== flip) {
396
+ this._flip.y = !!flip;
397
+ this.scale(1, -1);
398
+ this.isDirty = true;
399
+ }
394
400
  return this;
395
401
  }
396
402
 
@@ -402,8 +408,7 @@ import Color from "./../math/color.js";
402
408
  */
403
409
  transform(m) {
404
410
  this.currentTransform.multiply(m);
405
- //super.transform(m);
406
- this.updateBoundsPos(this.pos.x, this.pos.y);
411
+ this.updateBounds();
407
412
  this.isDirty = true;
408
413
  return this;
409
414
  }
@@ -478,9 +483,9 @@ import Color from "./../math/color.js";
478
483
  * @returns {Renderable} Reference to this object for method chaining
479
484
  */
480
485
  rotate(angle, v) {
481
- if (!isNaN(angle)) {
486
+ if (angle !== 0) {
482
487
  this.currentTransform.rotate(angle, v);
483
- //this.updateBoundsPos(this.pos.x, this.pos.y);
488
+ this.updateBounds();
484
489
  this.isDirty = true;
485
490
  }
486
491
  return this;
@@ -496,9 +501,9 @@ import Color from "./../math/color.js";
496
501
  * @param {number} [y=x] - a number representing the ordinate of the scaling vector.
497
502
  * @returns {Renderable} Reference to this object for method chaining
498
503
  */
499
- scale(x, y) {
504
+ scale(x, y = x) {
500
505
  this.currentTransform.scale(x, y);
501
- super.scale(x, y);
506
+ this.updateBounds();
502
507
  this.isDirty = true;
503
508
  return this;
504
509
  }
@@ -524,44 +529,68 @@ import Color from "./../math/color.js";
524
529
 
525
530
  /**
526
531
  * update the bounding box for this shape.
527
- * @ignore
532
+ * @param {boolean} [absolute=true] - update the bounds size and position in (world) absolute coordinates
528
533
  * @returns {Bounds} this shape bounding box Rectangle object
529
534
  */
530
- updateBounds() {
531
- super.updateBounds();
532
- this.updateBoundsPos(this.pos.x, this.pos.y);
533
- return this.getBounds();
535
+ updateBounds(absolute = true) {
536
+ if (this.isRenderable) {
537
+ var bounds = this.getBounds();
538
+
539
+ bounds.clear();
540
+
541
+ if ((this.autoTransform === true) && (!this.currentTransform.isIdentity())) {
542
+ // temporarly translate the matrix based on the anchor point
543
+ this.currentTransform.translate(
544
+ -this.width * this.anchorPoint.x,
545
+ -this.height * this.anchorPoint.y
546
+ );
547
+ bounds.addFrame(
548
+ 0,
549
+ 0,
550
+ this.width,
551
+ this.height,
552
+ this.currentTransform
553
+ );
554
+ this.currentTransform.translate(
555
+ this.width * this.anchorPoint.x,
556
+ this.height * this.anchorPoint.y
557
+ );
558
+ } else {
559
+ bounds.addFrame(
560
+ 0,
561
+ 0,
562
+ this.width,
563
+ this.height
564
+ );
565
+ // translate the bounds based on the anchor point
566
+ bounds.translate(
567
+ -this.width * this.anchorPoint.x,
568
+ -this.height * this.anchorPoint.y
569
+ );
570
+ }
571
+
572
+ if (absolute === true) {
573
+ bounds.centerOn(this.pos.x + bounds.x + bounds.width / 2, this.pos.y + bounds.y + bounds.height / 2);
574
+ if (typeof this.ancestor !== "undefined" && typeof this.ancestor.addChild === "function" && this.floating !== true) {
575
+ bounds.translate(this.ancestor.getAbsolutePosition());
576
+ }
577
+
578
+ }
579
+ return bounds;
580
+
581
+ } else {
582
+ // manage the case where updateBounds is called
583
+ // before the object being yet properly initialized
584
+ return super.updateBounds(absolute);
585
+ }
534
586
  }
535
587
 
536
588
  /**
537
589
  * update the renderable's bounding rect (private)
538
590
  * @ignore
539
591
  */
540
- updateBoundsPos(newX, newY) {
541
- var bounds = this.getBounds();
542
-
543
- bounds.shift(newX, newY);
544
-
545
- if (typeof this.anchorPoint !== "undefined" && bounds.isFinite()) {
546
- bounds.translate(
547
- -(this.anchorPoint.x * bounds.width),
548
- -(this.anchorPoint.y * bounds.height)
549
- );
550
- }
551
-
552
- /*
553
- if (typeof this.body !== "undefined") {
554
- var bodyBounds = this.body.getBounds();
555
- bounds.translate(bodyBounds.x, bodyBounds.y);
556
- }
557
- */
558
-
559
- // XXX: This is called from the constructor, before it gets an ancestor
560
- if (typeof this.ancestor !== "undefined" && typeof this.ancestor.addChild === "function" && this.floating !== true) {
561
- bounds.translate(this.ancestor.getAbsolutePosition());
562
- }
563
-
564
- this.isDirty = true;
592
+ updateBoundsPos(newX = this.pos.x, newY = this.pos.y) {
593
+ this.getBounds().translate(newX - this.pos.x, newY - this.pos.y);
565
594
  }
566
595
 
567
596
  /**
@@ -591,7 +620,10 @@ import Color from "./../math/color.js";
591
620
  // manually update the anchor point (required for updateBoundsPos)
592
621
  this.anchorPoint.setMuted(x, y);
593
622
  // then call updateBounds
594
- this.updateBoundsPos(this.pos.x, this.pos.y);
623
+ //this.updateBoundsPos(this.pos.x, this.pos.y);
624
+ this.updateBounds();
625
+ //console.log("hello");
626
+ this.isDirty = true;
595
627
  }
596
628
 
597
629
  /**
@@ -602,9 +634,8 @@ import Color from "./../math/color.js";
602
634
  * @param {CanvasRenderer|WebGLRenderer} renderer - a renderer object
603
635
  */
604
636
  preDraw(renderer) {
605
- var bounds = this.getBounds();
606
- var ax = bounds.width * this.anchorPoint.x,
607
- ay = bounds.height * this.anchorPoint.y;
637
+ var ax = this.width * this.anchorPoint.x,
638
+ ay = this.height * this.anchorPoint.y;
608
639
 
609
640
  // save renderer context
610
641
  renderer.save();
@@ -612,16 +643,6 @@ import Color from "./../math/color.js";
612
643
  // apply the defined alpha value
613
644
  renderer.setGlobalAlpha(renderer.globalAlpha() * this.getOpacity());
614
645
 
615
- // apply flip
616
- if (this._flip.x || this._flip.y) {
617
- var dx = this._flip.x ? this.centerX - ax : 0,
618
- dy = this._flip.y ? this.centerY - ay : 0;
619
-
620
- renderer.translate(dx, dy);
621
- renderer.scale(this._flip.x ? -1 : 1, this._flip.y ? -1 : 1);
622
- renderer.translate(-dx, -dy);
623
- }
624
-
625
646
  // apply stencil mask if defined
626
647
  if (typeof this.mask !== "undefined") {
627
648
  renderer.translate(this.pos.x, this.pos.y);
@@ -1,6 +1,6 @@
1
1
  import { renderer } from "./../video/video.js";
2
2
  import pool from "./../system/pooling.js";
3
- import loader from "./../loader/loader.js";
3
+ import { getImage } from "./../loader/loader.js";
4
4
  import { TextureAtlas } from "./../video/texture/atlas.js";
5
5
  import Renderable from "./renderable.js";
6
6
  import Color from "../math/color.js";
@@ -95,7 +95,7 @@ import Color from "../math/color.js";
95
95
  // (reusing current, any better/cleaner place?)
96
96
  this.current = {
97
97
  // the current animation name
98
- name : "default",
98
+ name : undefined,
99
99
  // length of the current animation name
100
100
  length : 0,
101
101
  //current frame texture offset
@@ -132,9 +132,6 @@ import Color from "../math/color.js";
132
132
  if (region) {
133
133
  // set the sprite region within the texture
134
134
  this.setRegion(region);
135
- // update the default "current" frame size
136
- this.current.width = settings.framewidth || region.width;
137
- this.current.height = settings.frameheight || region.height;
138
135
  } else {
139
136
  // throw an error
140
137
  throw new Error("Texture - region for " + settings.region + " not found");
@@ -142,14 +139,14 @@ import Color from "../math/color.js";
142
139
  }
143
140
  } else {
144
141
  // HTMLImageElement/Canvas or {string}
145
- this.image = (typeof settings.image === "object") ? settings.image : loader.getImage(settings.image);
142
+ this.image = (typeof settings.image === "object") ? settings.image : getImage(settings.image);
146
143
  // throw an error if image ends up being null/undefined
147
144
  if (!this.image) {
148
145
  throw new Error("me.Sprite: '" + settings.image + "' image/texture not found!");
149
146
  }
150
147
  // update the default "current" frame size
151
- this.current.width = settings.framewidth = settings.framewidth || this.image.width;
152
- this.current.height = settings.frameheight = settings.frameheight || this.image.height;
148
+ this.width = this.current.width = settings.framewidth = settings.framewidth || this.image.width;
149
+ this.height = this.current.height = settings.frameheight = settings.frameheight || this.image.height;
153
150
  this.source = renderer.cache.get(this.image, settings);
154
151
  this.textureAtlas = this.source.getAtlas();
155
152
  }
@@ -160,10 +157,6 @@ import Color from "../math/color.js";
160
157
  this.atlasIndices = settings.atlasIndices;
161
158
  }
162
159
 
163
- // resize based on the active frame
164
- this.width = this.current.width;
165
- this.height = this.current.height;
166
-
167
160
  // apply flip flags if specified
168
161
  if (typeof (settings.flipX) !== "undefined") {
169
162
  this.flipX(!!settings.flipX);
@@ -202,14 +195,11 @@ import Color from "../math/color.js";
202
195
  this.pos.z = settings.z;
203
196
  }
204
197
 
205
- // for sprite, addAnimation will return !=0
198
+ // addAnimation will return 0 if no texture atlas is defined
206
199
  if (this.addAnimation("default", null) !== 0) {
207
200
  // set as default
208
201
  this.setCurrentAnimation("default");
209
202
  }
210
-
211
- // enable currentTransform for me.Sprite based objects
212
- this.autoTransform = true;
213
203
  }
214
204
 
215
205
  /**
@@ -389,22 +379,24 @@ import Color from "../math/color.js";
389
379
  * return false; // do not reset to first frame
390
380
  * }).bind(this));
391
381
  */
392
- setCurrentAnimation(name, resetAnim, preserve_dt) {
393
- if (this.anim[name]) {
394
- this.current.name = name;
395
- this.current.length = this.anim[this.current.name].length;
396
- if (typeof resetAnim === "string") {
397
- this.resetAnim = this.setCurrentAnimation.bind(this, resetAnim, null, true);
398
- } else if (typeof resetAnim === "function") {
399
- this.resetAnim = resetAnim;
400
- } else {
401
- this.resetAnim = undefined;
402
- }
403
- this.setAnimationFrame(this.current.idx);
404
- if (!preserve_dt) {
405
- this.dt = 0;
382
+ setCurrentAnimation(name, resetAnim, preserve_dt = false) {
383
+ if (typeof this.anim[name] !== "undefined") {
384
+ if (!this.isCurrentAnimation(name)) {
385
+ this.current.name = name;
386
+ this.current.length = this.anim[this.current.name].length;
387
+ if (typeof resetAnim === "string") {
388
+ this.resetAnim = this.setCurrentAnimation.bind(this, resetAnim, null, true);
389
+ } else if (typeof resetAnim === "function") {
390
+ this.resetAnim = resetAnim;
391
+ } else {
392
+ this.resetAnim = undefined;
393
+ }
394
+ this.setAnimationFrame(0);
395
+ if (!preserve_dt) {
396
+ this.dt = 0;
397
+ }
398
+ this.isDirty = true;
406
399
  }
407
- this.isDirty = true;
408
400
  } else {
409
401
  throw new Error("animation id '" + name + "' not defined");
410
402
  }
@@ -461,17 +453,19 @@ import Color from "../math/color.js";
461
453
  // set the sprite offset within the texture
462
454
  this.current.offset.setV(region.offset);
463
455
  // set angle if defined
464
- this.current.angle = region.angle;
456
+ this.current.angle = typeof region.angle === "number" ? region.angle : 0;
465
457
  // update the default "current" size
466
458
  this.width = this.current.width = region.width;
467
459
  this.height = this.current.height = region.height;
468
460
  // set global anchortPoint if defined
469
461
  if (region.anchorPoint) {
470
- this.anchorPoint.set(
462
+ this.anchorPoint.setMuted(
471
463
  this._flip.x && region.trimmed === true ? 1 - region.anchorPoint.x : region.anchorPoint.x,
472
464
  this._flip.y && region.trimmed === true ? 1 - region.anchorPoint.y : region.anchorPoint.y
473
465
  );
474
466
  }
467
+ // update the sprite bounding box
468
+ this.updateBounds();
475
469
  this.isDirty = true;
476
470
  return this;
477
471
  }
@@ -480,14 +474,14 @@ import Color from "../math/color.js";
480
474
  * force the current animation frame index.
481
475
  * @name setAnimationFrame
482
476
  * @memberof Sprite
483
- * @param {number} [idx=0] - animation frame index
477
+ * @param {number} [index=0] - animation frame index
484
478
  * @returns {Sprite} Reference to this object for method chaining
485
479
  * @example
486
480
  * // reset the current animation to the first frame
487
481
  * this.setAnimationFrame();
488
482
  */
489
- setAnimationFrame(idx) {
490
- this.current.idx = (idx || 0) % this.current.length;
483
+ setAnimationFrame(index = 0) {
484
+ this.current.idx = index % this.current.length;
491
485
  return this.setRegion(this.getAnimationFrameObjectByIndex(this.current.idx));
492
486
  }
493
487
 
@@ -524,14 +518,14 @@ import Color from "../math/color.js";
524
518
  */
525
519
  update(dt) {
526
520
  // Update animation if necessary
527
- if (!this.animationpause && this.current && this.current.length > 0) {
521
+ if (!this.animationpause && this.current.length > 1) {
528
522
  var duration = this.getAnimationFrameObjectByIndex(this.current.idx).delay;
529
523
  this.dt += dt;
530
524
  while (this.dt >= duration) {
531
525
  this.isDirty = true;
532
526
  this.dt -= duration;
533
527
 
534
- var nextFrame = (this.current.length > 1? this.current.idx+1: this.current.idx);
528
+ var nextFrame = (this.current.length > 1 ? this.current.idx + 1 : this.current.idx);
535
529
  this.setAnimationFrame(nextFrame);
536
530
 
537
531
  // Switch animation if we reach the end of the strip and a callback is defined
@@ -551,21 +545,6 @@ import Color from "../math/color.js";
551
545
  }
552
546
  }
553
547
 
554
- // update the sprite bounding box
555
- /*
556
- if (this.isDirty === true && !this.currentTransform.isIdentity()) {
557
- this.getBounds().clear();
558
- this.getBounds().addFrame(
559
- 0,
560
- 0,
561
- this.current.width,
562
- this.current.height,
563
- this.currentTransform
564
- );
565
- this.updateBoundsPos(this.pos.x, this.pos.y);
566
- }
567
- */
568
-
569
548
  //update the "flickering" state if necessary
570
549
  if (this._flicker.isFlickering) {
571
550
  this._flicker.duration -= dt;
@@ -520,7 +520,7 @@ var state = {
520
520
  },
521
521
 
522
522
  /**
523
- * enable/disable transition for a specific state (by default enabled for all)
523
+ * enable/disable the transition to a particular state (by default enabled for all)
524
524
  * @name setTransition
525
525
  * @memberof state
526
526
  * @public
@@ -28,14 +28,14 @@ class ObjectPool {
28
28
  * @param {boolean} [recycling=false] - enables object recycling for the specified class
29
29
  * @example
30
30
  * // implement CherryEntity
31
- * class CherryEntity extends Spritesheet {
31
+ * class Cherry extends Sprite {
32
32
  * onResetEvent() {
33
33
  * // reset object mutable properties
34
34
  * this.lifeBar = 100;
35
35
  * }
36
36
  * };
37
37
  * // add our users defined entities in the object pool and enable object recycling
38
- * me.pool.register("cherryentity", CherryEntity, true);
38
+ * me.pool.register("cherrysprite", Cherry, true);
39
39
  */
40
40
  register(className, classObj, recycling = false) {
41
41
  if (typeof (classObj) !== "undefined") {
@@ -69,11 +69,7 @@ class ObjectPool {
69
69
  * me.game.world.removeChild(enemy);
70
70
  * me.game.world.removeChild(bullet);
71
71
  */
72
- pull(name) {
73
- var args = new Array(arguments.length);
74
- for (var i = 0; i < arguments.length; i++) {
75
- args[i] = arguments[i];
76
- }
72
+ pull(name, ...args) {
77
73
  var className = this.objectClass[name];
78
74
  if (className) {
79
75
  var proto = className["class"],
@@ -81,18 +77,12 @@ class ObjectPool {
81
77
  obj;
82
78
 
83
79
  if (poolArray && ((obj = poolArray.pop()))) {
84
- // pull an existing instance from the pool
85
- args.shift();
86
- // call the object onResetEvent function if defined
87
- if (typeof(obj.onResetEvent) === "function") {
88
- obj.onResetEvent.apply(obj, args);
89
- }
80
+ // poolable object must implement a `onResetEvent` method
81
+ obj.onResetEvent.apply(obj, args);
90
82
  this.instance_counter--;
91
- }
92
- else {
83
+ } else {
93
84
  // create a new instance
94
- args[0] = proto;
95
- obj = new (proto.bind.apply(proto, args))();
85
+ obj = new (proto.bind.apply(proto, [ proto, ...args ]))();
96
86
  if (poolArray) {
97
87
  obj.className = name;
98
88
  }