melonjs 15.0.0 → 15.1.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 (285) hide show
  1. package/README.md +4 -4
  2. package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +1 -1
  3. package/dist/melonjs.mjs/_virtual/arraymultimap.js +1 -1
  4. package/dist/melonjs.mjs/_virtual/earcut.js +1 -1
  5. package/dist/melonjs.mjs/_virtual/howler.js +1 -1
  6. package/dist/melonjs.mjs/_virtual/index.js +7 -3
  7. package/dist/melonjs.mjs/_virtual/index2.js +1 -1
  8. package/dist/melonjs.mjs/_virtual/multimap.js +1 -1
  9. package/dist/melonjs.mjs/_virtual/setmultimap.js +1 -1
  10. package/dist/melonjs.mjs/application/application.js +27 -17
  11. package/dist/melonjs.mjs/application/header.js +6 -5
  12. package/dist/melonjs.mjs/application/resize.js +20 -20
  13. package/dist/melonjs.mjs/application/settings.js +1 -1
  14. package/dist/melonjs.mjs/audio/audio.js +17 -17
  15. package/dist/melonjs.mjs/camera/camera2d.js +10 -10
  16. package/dist/melonjs.mjs/const.js +1 -1
  17. package/dist/melonjs.mjs/entity/entity.js +4 -4
  18. package/dist/melonjs.mjs/geometries/ellipse.js +6 -6
  19. package/dist/melonjs.mjs/geometries/line.js +9 -9
  20. package/dist/melonjs.mjs/geometries/path2d.js +53 -53
  21. package/dist/melonjs.mjs/geometries/point.js +2 -2
  22. package/dist/melonjs.mjs/geometries/poly.js +29 -29
  23. package/dist/melonjs.mjs/geometries/rectangle.js +8 -8
  24. package/dist/melonjs.mjs/geometries/roundrect.js +6 -6
  25. package/dist/melonjs.mjs/index.js +5 -5
  26. package/dist/melonjs.mjs/input/gamepad.js +30 -30
  27. package/dist/melonjs.mjs/input/input.js +2 -2
  28. package/dist/melonjs.mjs/input/keyboard.js +15 -15
  29. package/dist/melonjs.mjs/input/pointer.js +2 -2
  30. package/dist/melonjs.mjs/input/pointerevent.js +58 -58
  31. package/dist/melonjs.mjs/lang/console.js +3 -3
  32. package/dist/melonjs.mjs/lang/deprecated.js +2 -2
  33. package/dist/melonjs.mjs/level/level.js +9 -9
  34. package/dist/melonjs.mjs/level/tiled/TMXGroup.js +3 -3
  35. package/dist/melonjs.mjs/level/tiled/TMXLayer.js +31 -31
  36. package/dist/melonjs.mjs/level/tiled/TMXObject.js +8 -8
  37. package/dist/melonjs.mjs/level/tiled/TMXTile.js +8 -8
  38. package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +19 -19
  39. package/dist/melonjs.mjs/level/tiled/TMXTileset.js +15 -15
  40. package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +3 -3
  41. package/dist/melonjs.mjs/level/tiled/TMXUtils.js +46 -41
  42. package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
  43. package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +30 -30
  44. package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +21 -21
  45. package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +10 -10
  46. package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +2 -2
  47. package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +6 -6
  48. package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +1 -1
  49. package/dist/melonjs.mjs/loader/cache.js +1 -1
  50. package/dist/melonjs.mjs/loader/loader.js +7 -7
  51. package/dist/melonjs.mjs/loader/loadingscreen.js +2 -2
  52. package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
  53. package/dist/melonjs.mjs/loader/parser.js +13 -13
  54. package/dist/melonjs.mjs/loader/settings.js +3 -3
  55. package/dist/melonjs.mjs/math/color.js +21 -21
  56. package/dist/melonjs.mjs/math/math.js +2 -2
  57. package/dist/melonjs.mjs/math/matrix2.js +22 -22
  58. package/dist/melonjs.mjs/math/matrix3.js +52 -52
  59. package/dist/melonjs.mjs/math/observable_vector2.js +12 -12
  60. package/dist/melonjs.mjs/math/observable_vector3.js +22 -22
  61. package/dist/melonjs.mjs/math/vector2.js +11 -11
  62. package/dist/melonjs.mjs/math/vector3.js +21 -21
  63. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/arraymultimap.js +45 -0
  64. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/multimap.js +130 -0
  65. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/arraymultimap.js +1 -1
  66. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/index.js +1 -1
  67. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/multimap.js +1 -1
  68. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/setmultimap.js +1 -1
  69. package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +1 -1
  70. package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +2 -2
  71. package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +1 -1
  72. package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +1 -1
  73. package/dist/melonjs.mjs/particles/emitter.js +5 -5
  74. package/dist/melonjs.mjs/particles/particle.js +8 -8
  75. package/dist/melonjs.mjs/particles/settings.js +3 -3
  76. package/dist/melonjs.mjs/physics/body.js +17 -17
  77. package/dist/melonjs.mjs/physics/bounds.js +12 -12
  78. package/dist/melonjs.mjs/physics/collision.js +3 -3
  79. package/dist/melonjs.mjs/physics/detector.js +14 -14
  80. package/dist/melonjs.mjs/physics/quadtree.js +19 -19
  81. package/dist/melonjs.mjs/physics/response.js +1 -1
  82. package/dist/melonjs.mjs/physics/sat.js +60 -60
  83. package/dist/melonjs.mjs/physics/world.js +4 -4
  84. package/dist/melonjs.mjs/plugin/plugin.js +11 -11
  85. package/dist/melonjs.mjs/renderable/collectable.js +2 -2
  86. package/dist/melonjs.mjs/renderable/colorlayer.js +1 -1
  87. package/dist/melonjs.mjs/renderable/container.js +77 -59
  88. package/dist/melonjs.mjs/renderable/dragndrop.js +5 -5
  89. package/dist/melonjs.mjs/renderable/imagelayer.js +7 -6
  90. package/dist/melonjs.mjs/renderable/light2d.js +6 -6
  91. package/dist/melonjs.mjs/renderable/nineslicesprite.js +12 -12
  92. package/dist/melonjs.mjs/renderable/renderable.js +11 -11
  93. package/dist/melonjs.mjs/renderable/sprite.js +25 -25
  94. package/dist/melonjs.mjs/renderable/trigger.js +11 -9
  95. package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +97 -27
  96. package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +25 -25
  97. package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +83 -63
  98. package/dist/melonjs.mjs/state/stage.js +7 -7
  99. package/dist/melonjs.mjs/state/state.js +15 -15
  100. package/dist/melonjs.mjs/system/device.js +2 -2
  101. package/dist/melonjs.mjs/system/dom.js +1 -1
  102. package/dist/melonjs.mjs/system/event.js +2 -2
  103. package/dist/melonjs.mjs/system/platform.js +1 -1
  104. package/dist/melonjs.mjs/system/pooling.js +9 -9
  105. package/dist/melonjs.mjs/system/save.js +6 -6
  106. package/dist/melonjs.mjs/system/timer.js +16 -12
  107. package/dist/melonjs.mjs/text/bitmaptext.js +20 -20
  108. package/dist/melonjs.mjs/text/bitmaptextdata.js +22 -22
  109. package/dist/melonjs.mjs/text/glyph.js +3 -3
  110. package/dist/melonjs.mjs/text/text.js +10 -9
  111. package/dist/melonjs.mjs/text/textmetrics.js +15 -15
  112. package/dist/melonjs.mjs/text/textstyle.js +1 -1
  113. package/dist/melonjs.mjs/tweens/easing.js +4 -4
  114. package/dist/melonjs.mjs/tweens/interpolation.js +8 -8
  115. package/dist/melonjs.mjs/tweens/tween.js +11 -11
  116. package/dist/melonjs.mjs/utils/agent.js +6 -6
  117. package/dist/melonjs.mjs/utils/array.js +4 -4
  118. package/dist/melonjs.mjs/utils/file.js +1 -1
  119. package/dist/melonjs.mjs/utils/function.js +5 -5
  120. package/dist/melonjs.mjs/utils/string.js +3 -3
  121. package/dist/melonjs.mjs/utils/utils.js +16 -16
  122. package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +35 -109
  123. package/dist/melonjs.mjs/video/renderer.js +74 -7
  124. package/dist/melonjs.mjs/video/texture/atlas.js +37 -37
  125. package/dist/melonjs.mjs/video/texture/cache.js +9 -10
  126. package/dist/melonjs.mjs/video/texture/canvas_texture.js +63 -3
  127. package/dist/melonjs.mjs/video/utils/autodetect.js +1 -1
  128. package/dist/melonjs.mjs/video/video.js +2 -2
  129. package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +3 -3
  130. package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +5 -5
  131. package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +5 -5
  132. package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +18 -15
  133. package/dist/melonjs.mjs/video/webgl/glshader.js +7 -7
  134. package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +1 -1
  135. package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +1 -1
  136. package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +1 -1
  137. package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +1 -1
  138. package/dist/melonjs.mjs/video/webgl/utils/attributes.js +2 -2
  139. package/dist/melonjs.mjs/video/webgl/utils/precision.js +1 -1
  140. package/dist/melonjs.mjs/video/webgl/utils/program.js +7 -7
  141. package/dist/melonjs.mjs/video/webgl/utils/string.js +1 -1
  142. package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +4 -4
  143. package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +55 -38
  144. package/dist/melonjs.module.js +1747 -1809
  145. package/dist/types/application/application.d.ts +11 -8
  146. package/dist/types/audio/audio.d.ts +3 -3
  147. package/dist/types/index.d.ts +4 -3
  148. package/dist/types/input/input.d.ts +1 -1
  149. package/dist/types/input/keyboard.d.ts +1 -1
  150. package/dist/types/input/pointerevent.d.ts +6 -6
  151. package/dist/types/level/level.d.ts +2 -2
  152. package/dist/types/level/tiled/TMXLayer.d.ts +4 -4
  153. package/dist/types/level/tiled/TMXTileMap.d.ts +2 -2
  154. package/dist/types/level/tiled/TMXUtils.d.ts +5 -4
  155. package/dist/types/loader/loader.d.ts +2 -2
  156. package/dist/types/loader/settings.d.ts +2 -2
  157. package/dist/types/particles/emitter.d.ts +1 -1
  158. package/dist/types/physics/collision.d.ts +1 -1
  159. package/dist/types/physics/detector.d.ts +1 -1
  160. package/dist/types/plugin/plugin.d.ts +2 -2
  161. package/dist/types/renderable/container.d.ts +21 -17
  162. package/dist/types/renderable/sprite.d.ts +11 -11
  163. package/dist/types/renderable/trigger.d.ts +1 -1
  164. package/dist/types/renderable/ui/uibaseelement.d.ts +28 -6
  165. package/dist/types/renderable/ui/uispriteelement.d.ts +12 -14
  166. package/dist/types/renderable/ui/uitextbutton.d.ts +52 -11
  167. package/dist/types/state/stage.d.ts +1 -1
  168. package/dist/types/system/device.d.ts +1 -1
  169. package/dist/types/system/pooling.d.ts +3 -3
  170. package/dist/types/system/timer.d.ts +5 -5
  171. package/dist/types/text/bitmaptext.d.ts +1 -1
  172. package/dist/types/text/text.d.ts +1 -1
  173. package/dist/types/utils/array.d.ts +2 -2
  174. package/dist/types/video/canvas/canvas_renderer.d.ts +8 -76
  175. package/dist/types/video/renderer.d.ts +48 -0
  176. package/dist/types/video/texture/atlas.d.ts +3 -3
  177. package/dist/types/video/texture/canvas_texture.d.ts +40 -0
  178. package/dist/types/video/webgl/glshader.d.ts +1 -1
  179. package/dist/types/video/webgl/webgl_renderer.d.ts +13 -9
  180. package/package.json +14 -14
  181. package/src/application/application.js +26 -16
  182. package/src/application/header.js +5 -4
  183. package/src/application/resize.js +19 -19
  184. package/src/audio/audio.js +16 -16
  185. package/src/camera/camera2d.js +9 -9
  186. package/src/entity/entity.js +3 -3
  187. package/src/geometries/ellipse.js +5 -5
  188. package/src/geometries/line.js +8 -8
  189. package/src/geometries/path2d.js +52 -52
  190. package/src/geometries/point.js +1 -1
  191. package/src/geometries/poly.js +28 -28
  192. package/src/geometries/rectangle.js +7 -7
  193. package/src/geometries/roundrect.js +5 -5
  194. package/src/index.js +3 -2
  195. package/src/input/gamepad.js +29 -29
  196. package/src/input/input.js +1 -1
  197. package/src/input/keyboard.js +14 -14
  198. package/src/input/pointer.js +1 -1
  199. package/src/input/pointerevent.js +52 -52
  200. package/src/lang/console.js +2 -2
  201. package/src/lang/deprecated.js +1 -1
  202. package/src/level/level.js +8 -8
  203. package/src/level/tiled/TMXGroup.js +2 -2
  204. package/src/level/tiled/TMXLayer.js +30 -30
  205. package/src/level/tiled/TMXObject.js +7 -7
  206. package/src/level/tiled/TMXTile.js +7 -7
  207. package/src/level/tiled/TMXTileMap.js +18 -18
  208. package/src/level/tiled/TMXTileset.js +14 -14
  209. package/src/level/tiled/TMXTilesetGroup.js +2 -2
  210. package/src/level/tiled/TMXUtils.js +45 -40
  211. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +29 -29
  212. package/src/level/tiled/renderer/TMXIsometricRenderer.js +20 -20
  213. package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +9 -9
  214. package/src/level/tiled/renderer/TMXRenderer.js +1 -1
  215. package/src/level/tiled/renderer/TMXStaggeredRenderer.js +5 -5
  216. package/src/loader/loader.js +6 -6
  217. package/src/loader/loadingscreen.js +1 -1
  218. package/src/loader/parser.js +12 -12
  219. package/src/loader/settings.js +2 -2
  220. package/src/math/color.js +20 -20
  221. package/src/math/math.js +1 -1
  222. package/src/math/matrix2.js +21 -21
  223. package/src/math/matrix3.js +51 -51
  224. package/src/math/observable_vector2.js +11 -11
  225. package/src/math/observable_vector3.js +21 -21
  226. package/src/math/vector2.js +10 -10
  227. package/src/math/vector3.js +20 -20
  228. package/src/particles/emitter.js +4 -4
  229. package/src/particles/particle.js +7 -7
  230. package/src/particles/settings.js +2 -2
  231. package/src/physics/body.js +16 -16
  232. package/src/physics/bounds.js +11 -11
  233. package/src/physics/collision.js +2 -2
  234. package/src/physics/detector.js +13 -13
  235. package/src/physics/quadtree.js +18 -18
  236. package/src/physics/sat.js +59 -59
  237. package/src/physics/world.js +3 -3
  238. package/src/plugin/plugin.js +8 -8
  239. package/src/renderable/collectable.js +1 -1
  240. package/src/renderable/container.js +76 -58
  241. package/src/renderable/dragndrop.js +4 -4
  242. package/src/renderable/imagelayer.js +6 -5
  243. package/src/renderable/light2d.js +5 -5
  244. package/src/renderable/nineslicesprite.js +11 -11
  245. package/src/renderable/renderable.js +10 -10
  246. package/src/renderable/sprite.js +24 -24
  247. package/src/renderable/trigger.js +10 -8
  248. package/src/renderable/ui/uibaseelement.js +96 -26
  249. package/src/renderable/ui/uispriteelement.js +24 -24
  250. package/src/renderable/ui/uitextbutton.js +85 -65
  251. package/src/state/stage.js +6 -6
  252. package/src/state/state.js +14 -14
  253. package/src/system/device.js +1 -1
  254. package/src/system/event.js +1 -1
  255. package/src/system/pooling.js +8 -8
  256. package/src/system/save.js +5 -5
  257. package/src/system/timer.js +15 -11
  258. package/src/text/bitmaptext.js +19 -19
  259. package/src/text/bitmaptextdata.js +21 -21
  260. package/src/text/glyph.js +2 -2
  261. package/src/text/text.js +9 -8
  262. package/src/text/textmetrics.js +14 -14
  263. package/src/tweens/easing.js +3 -3
  264. package/src/tweens/interpolation.js +7 -7
  265. package/src/tweens/tween.js +10 -10
  266. package/src/utils/agent.js +5 -5
  267. package/src/utils/array.js +3 -3
  268. package/src/utils/function.js +4 -4
  269. package/src/utils/string.js +2 -2
  270. package/src/utils/utils.js +15 -15
  271. package/src/video/canvas/canvas_renderer.js +34 -108
  272. package/src/video/renderer.js +72 -5
  273. package/src/video/texture/atlas.js +36 -36
  274. package/src/video/texture/cache.js +6 -6
  275. package/src/video/texture/canvas_texture.js +62 -2
  276. package/src/video/video.js +1 -1
  277. package/src/video/webgl/buffer/vertex.js +2 -2
  278. package/src/video/webgl/compositors/compositor.js +4 -4
  279. package/src/video/webgl/compositors/primitive_compositor.js +4 -4
  280. package/src/video/webgl/compositors/quad_compositor.js +17 -14
  281. package/src/video/webgl/glshader.js +6 -6
  282. package/src/video/webgl/utils/attributes.js +1 -1
  283. package/src/video/webgl/utils/program.js +6 -6
  284. package/src/video/webgl/utils/uniforms.js +3 -3
  285. package/src/video/webgl/webgl_renderer.js +54 -37
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.0.0
2
+ * melonJS Game Engine - v15.1.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -64,12 +64,12 @@ let globalFloatingCounter = 0;
64
64
  this.children = undefined;
65
65
 
66
66
  /**
67
- * The property of the child object that should be used to sort on <br>
67
+ * The property of the child object that should be used to sort on this container
68
68
  * value : "x", "y", "z"
69
69
  * @type {string}
70
- * @default me.game.sortOn
70
+ * @default "z"
71
71
  */
72
- this.sortOn = game.sortOn;
72
+ this.sortOn = "z";
73
73
 
74
74
  /**
75
75
  * Specify if the children list should be automatically sorted when adding a new child
@@ -157,8 +157,8 @@ let globalFloatingCounter = 0;
157
157
  }
158
158
 
159
159
  // delete all children
160
- var children = this.getChildren();
161
- for (var i = children.length, child; i >= 0; (child = children[--i])) {
160
+ let children = this.getChildren();
161
+ for (let i = children.length, child; i >= 0; (child = children[--i])) {
162
162
  // don't remove it if a persistent object
163
163
  if (child && child.isPersistent !== true) {
164
164
  this.removeChildNow(child);
@@ -177,9 +177,9 @@ let globalFloatingCounter = 0;
177
177
  * Add a child to the container <br>
178
178
  * if auto-sort is disable, the object will be appended at the bottom of the list.
179
179
  * Adding a child to the container will automatically remove it from its other container.
180
- * Meaning a child can only have one parent. This is important if you add a renderable
181
- * to a container then add it to the me.game.world container it will move it out of the
182
- * orginal container. Then when the me.game.world.reset() is called the renderable
180
+ * Meaning a child can only have one parent. This is important if you add a renderable
181
+ * to a container then add it to the World container it will move it out of the
182
+ * orginal container. Then when the World container reset() method is called the renderable
183
183
  * will not be in any container. <br>
184
184
  * if the given child implements a onActivateEvent method, that method will be called
185
185
  * once the child is added to this container.
@@ -226,7 +226,7 @@ let globalFloatingCounter = 0;
226
226
 
227
227
  // force repaint in case this is a static non-animated object
228
228
  if (this.isAttachedToRoot() === true) {
229
- game.repaint();
229
+ this.isDirty = true;
230
230
  }
231
231
 
232
232
  // force bounds update if required
@@ -236,7 +236,7 @@ let globalFloatingCounter = 0;
236
236
 
237
237
  // if a physic body is defined, add it to the game world
238
238
  if (child.body instanceof Body) {
239
- game.world.addBody(child.body);
239
+ this.getRootAncestor().addBody(child.body);
240
240
  }
241
241
 
242
242
  // triggered callback if defined
@@ -275,7 +275,7 @@ let globalFloatingCounter = 0;
275
275
 
276
276
  // force repaint in case this is a static non-animated object
277
277
  if (this.isAttachedToRoot() === true) {
278
- game.repaint();
278
+ this.isDirty = true;
279
279
  }
280
280
 
281
281
  // force bounds update if required
@@ -285,7 +285,7 @@ let globalFloatingCounter = 0;
285
285
 
286
286
  // if a physic body is defined, add it to the game world
287
287
  if (child.body instanceof Body) {
288
- game.world.addBody(child.body);
288
+ this.getRootAncestor().addBody(child.body);
289
289
  }
290
290
 
291
291
  // triggered callback if defined
@@ -307,20 +307,20 @@ let globalFloatingCounter = 0;
307
307
  * @param {Function} callback - fnction to execute on each element
308
308
  * @param {object} [thisArg] - value to use as this(i.e reference Object) when executing callback.
309
309
  * @example
310
- * // iterate through all children of the root container
311
- * me.game.world.forEach((child) => {
310
+ * // iterate through all children of this container
311
+ * container.forEach((child) => {
312
312
  * // do something with the child
313
313
  * child.doSomething();
314
314
  * });
315
- * me.game.world.forEach((child, index) => { ... });
316
- * me.game.world.forEach((child, index, array) => { ... });
317
- * me.game.world.forEach((child, index, array) => { ... }, thisArg);
315
+ * container.forEach((child, index) => { ... });
316
+ * container.forEach((child, index, array) => { ... });
317
+ * container.forEach((child, index, array) => { ... }, thisArg);
318
318
  */
319
319
  forEach(callback, thisArg) {
320
- var context = this, i = 0;
321
- var children = this.getChildren();
320
+ let context = this, i = 0;
321
+ let children = this.getChildren();
322
322
 
323
- var len = children.length;
323
+ let len = children.length;
324
324
 
325
325
  if (typeof callback !== "function") {
326
326
  throw new Error(callback + " is not a function");
@@ -342,12 +342,12 @@ let globalFloatingCounter = 0;
342
342
  * @param {Renderable} child2
343
343
  */
344
344
  swapChildren(child, child2) {
345
- var index = this.getChildIndex(child);
346
- var index2 = this.getChildIndex(child2);
345
+ let index = this.getChildIndex(child);
346
+ let index2 = this.getChildIndex(child2);
347
347
 
348
348
  if ((index !== -1) && (index2 !== -1)) {
349
349
  // swap z index
350
- var _z = child.pos.z;
350
+ let _z = child.pos.z;
351
351
  child.pos.z = child2.pos.z;
352
352
  child2.pos.z = _z;
353
353
  // swap the positions..
@@ -390,7 +390,7 @@ let globalFloatingCounter = 0;
390
390
  * @returns {Renderable} child
391
391
  */
392
392
  getNextChild(child) {
393
- var index = this.getChildren().indexOf(child) - 1;
393
+ let index = this.getChildren().indexOf(child) - 1;
394
394
  if (index >= 0 && index < this.getChildren().length) {
395
395
  return this.getChildAt(index);
396
396
  }
@@ -415,27 +415,27 @@ let globalFloatingCounter = 0;
415
415
  * @returns {Renderable[]} Array of childs
416
416
  * @example
417
417
  * // get the first child object called "mainPlayer" in a specific container :
418
- * var ent = myContainer.getChildByProp("name", "mainPlayer");
418
+ * let ent = myContainer.getChildByProp("name", "mainPlayer");
419
419
  *
420
420
  * // or query the whole world :
421
- * var ent = me.game.world.getChildByProp("name", "mainPlayer");
421
+ * let ent = container.getChildByProp("name", "mainPlayer");
422
422
  *
423
423
  * // partial property matches are also allowed by using a RegExp.
424
424
  * // the following matches "redCOIN", "bluecoin", "bagOfCoins", etc :
425
- * var allCoins = me.game.world.getChildByProp("name", /coin/i);
425
+ * let allCoins = container.getChildByProp("name", /coin/i);
426
426
  *
427
427
  * // searching for numbers or other data types :
428
- * var zIndex10 = me.game.world.getChildByProp("z", 10);
429
- * var inViewport = me.game.world.getChildByProp("inViewport", true);
428
+ * let zIndex10 = container.getChildByProp("z", 10);
429
+ * let inViewport = container.getChildByProp("inViewport", true);
430
430
  */
431
431
  getChildByProp(prop, value) {
432
- var objList = [];
432
+ let objList = [];
433
433
 
434
434
  /**
435
435
  * @ignore
436
436
  */
437
437
  function compare(obj, prop) {
438
- var v = obj[prop];
438
+ let v = obj[prop];
439
439
  if (value instanceof RegExp && typeof(v) === "string") {
440
440
  if (value.test(v)) {
441
441
  objList.push(obj);
@@ -462,7 +462,7 @@ let globalFloatingCounter = 0;
462
462
  * @returns {Renderable[]} Array of children
463
463
  */
464
464
  getChildByType(classType) {
465
- var objList = [];
465
+ let objList = [];
466
466
 
467
467
  this.forEach((child) => {
468
468
  if (child instanceof classType) {
@@ -496,7 +496,7 @@ let globalFloatingCounter = 0;
496
496
  * @returns {Renderable} corresponding child or null
497
497
  */
498
498
  getChildByGUID(guid) {
499
- var obj = this.getChildByProp("GUID", guid);
499
+ let obj = this.getChildByProp("GUID", guid);
500
500
  return (obj.length > 0) ? obj[0] : null;
501
501
  }
502
502
 
@@ -518,7 +518,7 @@ let globalFloatingCounter = 0;
518
518
  * @returns {Bounds} this shape bounding box Rectangle object
519
519
  */
520
520
  updateBounds(absolute = true) {
521
- var bounds = this.getBounds();
521
+ let bounds = this.getBounds();
522
522
 
523
523
  // call parent method
524
524
  super.updateBounds(absolute);
@@ -526,7 +526,7 @@ let globalFloatingCounter = 0;
526
526
  if (this.enableChildBoundsUpdate === true) {
527
527
  this.forEach((child) => {
528
528
  if (child.isRenderable) {
529
- var childBounds = child.getBounds();
529
+ let childBounds = child.getBounds();
530
530
  if (childBounds.isFinite()) {
531
531
  bounds.addBounds(childBounds);
532
532
  }
@@ -538,14 +538,13 @@ let globalFloatingCounter = 0;
538
538
 
539
539
  /**
540
540
  * Checks if this container is root or if it's attached to the root container.
541
- * @private
542
541
  * @returns {boolean}
543
542
  */
544
543
  isAttachedToRoot() {
545
544
  if (this.root === true) {
546
545
  return true;
547
546
  } else {
548
- var ancestor = this.ancestor;
547
+ let ancestor = this.ancestor;
549
548
  while (ancestor) {
550
549
  if (ancestor.root === true) {
551
550
  return true;
@@ -556,6 +555,25 @@ let globalFloatingCounter = 0;
556
555
  }
557
556
  }
558
557
 
558
+ /**
559
+ * Returns the instance of the root container (i.e. the current application World container).
560
+ * @returns {Container}
561
+ */
562
+ getRootAncestor() {
563
+ if (this.root === true) {
564
+ return this;
565
+ } else {
566
+ let ancestor = this.ancestor;
567
+ while (ancestor) {
568
+ if (ancestor.root === true) {
569
+ break;
570
+ }
571
+ ancestor = ancestor.ancestor;
572
+ }
573
+ return ancestor;
574
+ }
575
+ }
576
+
559
577
  /**
560
578
  * update the cointainer's bounding rect (private)
561
579
  * @ignore
@@ -617,7 +635,7 @@ let globalFloatingCounter = 0;
617
635
  // remove the body first to avoid a condition where a body can be detached
618
636
  // from its parent, before the body is removed from the game world
619
637
  if (child.body instanceof Body) {
620
- game.world.removeBody(child.body);
638
+ this.getRootAncestor().removeBody(child.body);
621
639
  }
622
640
 
623
641
  if (!keepalive) {
@@ -632,7 +650,7 @@ let globalFloatingCounter = 0;
632
650
 
633
651
  // Don't cache the child index; another element might have been removed
634
652
  // by the child's `onDeactivateEvent` or `destroy` methods
635
- var childIndex = this.getChildIndex(child);
653
+ let childIndex = this.getChildIndex(child);
636
654
  if (childIndex >= 0) {
637
655
  this.getChildren().splice(childIndex, 1);
638
656
  child.ancestor = undefined;
@@ -640,7 +658,7 @@ let globalFloatingCounter = 0;
640
658
 
641
659
  // force repaint in case this is a static non-animated object
642
660
  if (this.isAttachedToRoot() === true) {
643
- game.repaint();
661
+ this.isDirty = true;
644
662
  }
645
663
 
646
664
  // force bounds update if required
@@ -673,7 +691,7 @@ let globalFloatingCounter = 0;
673
691
  * @param {Renderable} child
674
692
  */
675
693
  moveUp(child) {
676
- var childIndex = this.getChildIndex(child);
694
+ let childIndex = this.getChildIndex(child);
677
695
  if (childIndex - 1 >= 0) {
678
696
  // note : we use an inverted loop
679
697
  this.swapChildren(child, this.getChildAt(childIndex - 1));
@@ -687,7 +705,7 @@ let globalFloatingCounter = 0;
687
705
  * @param {Renderable} child
688
706
  */
689
707
  moveDown(child) {
690
- var childIndex = this.getChildIndex(child);
708
+ let childIndex = this.getChildIndex(child);
691
709
  if (childIndex >= 0 && (childIndex + 1) < this.getChildren().length) {
692
710
  // note : we use an inverted loop
693
711
  this.swapChildren(child, this.getChildAt(childIndex + 1));
@@ -701,9 +719,9 @@ let globalFloatingCounter = 0;
701
719
  * @param {Renderable} child
702
720
  */
703
721
  moveToTop(child) {
704
- var childIndex = this.getChildIndex(child);
722
+ let childIndex = this.getChildIndex(child);
705
723
  if (childIndex > 0) {
706
- var children = this.getChildren();
724
+ let children = this.getChildren();
707
725
  // note : we use an inverted loop
708
726
  children.splice(0, 0, children.splice(childIndex, 1)[0]);
709
727
  // increment our child z value based on the previous child depth
@@ -718,8 +736,8 @@ let globalFloatingCounter = 0;
718
736
  * @param {Renderable} child
719
737
  */
720
738
  moveToBottom(child) {
721
- var childIndex = this.getChildIndex(child);
722
- var children = this.getChildren();
739
+ let childIndex = this.getChildIndex(child);
740
+ let children = this.getChildren();
723
741
  if (childIndex >= 0 && childIndex < (children.length - 1)) {
724
742
  // note : we use an inverted loop
725
743
  children.splice((children.length - 1), 0, children.splice(childIndex, 1)[0]);
@@ -753,7 +771,7 @@ let globalFloatingCounter = 0;
753
771
  // clear the defer id
754
772
  this.pendingSort = null;
755
773
  // make sure we redraw everything
756
- game.repaint();
774
+ this.isDirty = true;
757
775
  }, this);
758
776
  }
759
777
  }
@@ -793,7 +811,7 @@ let globalFloatingCounter = 0;
793
811
  if (!b.pos || !a.pos) {
794
812
  return (a.pos ? -Infinity : Infinity);
795
813
  }
796
- var result = b.pos.z - a.pos.z;
814
+ let result = b.pos.z - a.pos.z;
797
815
  return (result ? result : (b.pos.x - a.pos.x));
798
816
  }
799
817
 
@@ -805,7 +823,7 @@ let globalFloatingCounter = 0;
805
823
  if (!b.pos || !a.pos) {
806
824
  return (a.pos ? -Infinity : Infinity);
807
825
  }
808
- var result = b.pos.z - a.pos.z;
826
+ let result = b.pos.z - a.pos.z;
809
827
  return (result ? result : (b.pos.y - a.pos.y));
810
828
  }
811
829
 
@@ -822,17 +840,17 @@ let globalFloatingCounter = 0;
822
840
 
823
841
  /**
824
842
  * container update function. <br>
825
- * automatically called by the game manager {@link game}
843
+ * automatically called by the application update loop {@link Application}
826
844
  * @protected
827
845
  * @param {number} dt - time since the last update in milliseconds.
828
846
  * @returns {boolean} true if the Container is dirty
829
847
  */
830
848
  update(dt) {
831
- var isFloating = false;
832
- var isPaused = state.isPaused();
833
- var children = this.getChildren();
849
+ let isFloating = false;
850
+ let isPaused = state.isPaused();
851
+ let children = this.getChildren();
834
852
 
835
- for (var i = children.length, obj; i--, (obj = children[i]);) {
853
+ for (let i = children.length, obj; i--, (obj = children[i]);) {
836
854
  if (isPaused && (!obj.updateWhenPaused)) {
837
855
  // skip this object
838
856
  continue;
@@ -877,8 +895,8 @@ let globalFloatingCounter = 0;
877
895
  * @param {Camera2d} [viewport] - the viewport to (re)draw
878
896
  */
879
897
  draw(renderer, viewport) {
880
- var isFloating = false;
881
- var bounds = this.getBounds();
898
+ let isFloating = false;
899
+ let bounds = this.getBounds();
882
900
 
883
901
  this.drawCount = 0;
884
902
 
@@ -900,8 +918,8 @@ let globalFloatingCounter = 0;
900
918
  renderer.clearColor(this.backgroundColor);
901
919
  }
902
920
 
903
- var children = this.getChildren();
904
- for (var i = children.length, obj; i--, (obj = children[i]);) {
921
+ let children = this.getChildren();
922
+ for (let i = children.length, obj; i--, (obj = children[i]);) {
905
923
  if (obj.isRenderable) {
906
924
 
907
925
  isFloating = obj.floating === true;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.0.0
2
+ * melonJS Game Engine - v15.1.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -43,10 +43,10 @@ class Draggable extends Renderable {
43
43
  * @private
44
44
  */
45
45
  initEvents() {
46
- registerPointerEvent("pointerdown", this, (e) => { emit(DRAGSTART, e, this); });
47
- registerPointerEvent("pointerup", this, (e) => { emit(DRAGEND, e, this); });
48
- registerPointerEvent("pointercancel", this, (e) => { emit(DRAGEND, e, this); });
49
- on(POINTERMOVE, this.dragMove.bind(this));
46
+ registerPointerEvent("pointerdown", this, (e) => emit(DRAGSTART, e, this));
47
+ registerPointerEvent("pointerup", this, (e) => emit(DRAGEND, e, this));
48
+ registerPointerEvent("pointercancel", this, (e) => emit(DRAGEND, e, this));
49
+ on(POINTERMOVE, (e) => this.dragMove(e));
50
50
  on(DRAGSTART, (e, draggable) => {
51
51
  if (draggable === this) {
52
52
  this.dragStart(e);
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.0.0
2
+ * melonJS Game Engine - v15.1.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -189,7 +189,7 @@ import { isNumeric } from '../utils/string.js';
189
189
  * @ignore
190
190
  */
191
191
  updateLayer(vpos) {
192
- var rx = this.ratio.x,
192
+ const rx = this.ratio.x,
193
193
  ry = this.ratio.y;
194
194
 
195
195
  if (rx === 0 && ry === 0) {
@@ -197,7 +197,7 @@ import { isNumeric } from '../utils/string.js';
197
197
  return;
198
198
  }
199
199
 
200
- var width = this.width,
200
+ const width = this.width,
201
201
  height = this.height,
202
202
  bw = game.viewport.bounds.width,
203
203
  bh = game.viewport.bounds.height,
@@ -263,13 +263,14 @@ import { isNumeric } from '../utils/string.js';
263
263
  * @param {Camera2d} [viewport] - the viewport to (re)draw
264
264
  */
265
265
  draw(renderer, viewport) {
266
- var width = this.width,
266
+ const width = this.width,
267
267
  height = this.height,
268
268
  bw = viewport.bounds.width,
269
269
  bh = viewport.bounds.height,
270
270
  ax = this.anchorPoint.x,
271
- ay = this.anchorPoint.y,
272
- x = this.pos.x,
271
+ ay = this.anchorPoint.y;
272
+
273
+ let x = this.pos.x,
273
274
  y = this.pos.y;
274
275
 
275
276
  if (this.ratio.x === 0 && this.ratio.y === 0) {
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.0.0
2
+ * melonJS Game Engine - v15.1.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -10,16 +10,16 @@ import Renderable from './renderable.js';
10
10
 
11
11
  /** @ignore */
12
12
  function createGradient(light) {
13
- var context = light.texture.context;
13
+ let context = light.texture.context;
14
14
 
15
- var x1 = light.texture.width / 2,
15
+ let x1 = light.texture.width / 2,
16
16
  y1 = light.texture.height / 2;
17
17
 
18
- var radiusX = light.radiusX,
18
+ let radiusX = light.radiusX,
19
19
  radiusY = light.radiusY;
20
20
 
21
- var scaleX, scaleY, invScaleX, invScaleY;
22
- var gradient;
21
+ let scaleX, scaleY, invScaleX, invScaleY;
22
+ let gradient;
23
23
 
24
24
 
25
25
  light.texture.clear();
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.0.0
2
+ * melonJS Game Engine - v15.1.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -93,18 +93,18 @@ import Sprite from './sprite.js';
93
93
  */
94
94
  draw(renderer) {
95
95
  // the frame to draw
96
- var frame = this.current;
96
+ let frame = this.current;
97
97
 
98
98
  // cache the current position and size
99
- var dx = this.pos.x,
99
+ let dx = this.pos.x,
100
100
  dy = this.pos.y;
101
101
 
102
- var w = frame.width,
102
+ let w = frame.width,
103
103
  h = frame.height;
104
104
 
105
105
  // frame offset in the texture/atlas
106
- var frame_offset = frame.offset;
107
- var g_offset = this.offset;
106
+ let frame_offset = frame.offset;
107
+ let g_offset = this.offset;
108
108
 
109
109
 
110
110
  // remove image's TexturePacker/ShoeBox rotation
@@ -116,11 +116,11 @@ import Sprite from './sprite.js';
116
116
  h = frame.width;
117
117
  }
118
118
 
119
- var sx = g_offset.x + frame_offset.x,
119
+ let sx = g_offset.x + frame_offset.x,
120
120
  sy = g_offset.y + frame_offset.y;
121
121
 
122
122
  // should this be configurable ?
123
- var corner_width = this.insetx || w / 4,
123
+ let corner_width = this.insetx || w / 4,
124
124
  corner_height = this.insety || h / 4;
125
125
 
126
126
  // OPTIMIZE ME !
@@ -170,11 +170,11 @@ import Sprite from './sprite.js';
170
170
 
171
171
 
172
172
  // DRAW SIDES and CENTER
173
- var image_center_width = w - (corner_width << 1);
174
- var image_center_height = h - (corner_height << 1);
173
+ let image_center_width = w - (corner_width << 1);
174
+ let image_center_height = h - (corner_height << 1);
175
175
 
176
- var target_center_width = this.nss_width - (corner_width << 1);
177
- var target_center_height = this.nss_height - (corner_height << 1);
176
+ let target_center_width = this.nss_width - (corner_width << 1);
177
+ let target_center_height = this.nss_height - (corner_height << 1);
178
178
 
179
179
  //Top center
180
180
  renderer.drawImage(
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.0.0
2
+ * melonJS Game Engine - v15.1.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -433,11 +433,11 @@ import { releaseAllPointerEvents } from '../input/pointerevent.js';
433
433
  * @returns {number} angle in radians
434
434
  */
435
435
  angleTo(target) {
436
- var a = this.getBounds();
437
- var ax, ay;
436
+ let a = this.getBounds();
437
+ let ax, ay;
438
438
 
439
439
  if (target instanceof Renderable) {
440
- var b = target.getBounds();
440
+ let b = target.getBounds();
441
441
  ax = b.centerX - a.centerX;
442
442
  ay = b.centerY - a.centerY;
443
443
  } else { // vector object
@@ -454,11 +454,11 @@ import { releaseAllPointerEvents } from '../input/pointerevent.js';
454
454
  * @returns {number} distance
455
455
  */
456
456
  distanceTo(target) {
457
- var a = this.getBounds();
458
- var dx, dy;
457
+ let a = this.getBounds();
458
+ let dx, dy;
459
459
 
460
460
  if (target instanceof Renderable) {
461
- var b = target.getBounds();
461
+ let b = target.getBounds();
462
462
  dx = a.centerX - b.centerX;
463
463
  dy = a.centerY - b.centerY;
464
464
  } else { // vector object
@@ -475,7 +475,7 @@ import { releaseAllPointerEvents } from '../input/pointerevent.js';
475
475
  * @returns {Renderable} Reference to this object for method chaining
476
476
  */
477
477
  lookAt(target) {
478
- var position;
478
+ let position;
479
479
 
480
480
  if (target instanceof Renderable) {
481
481
  position = target.pos;
@@ -483,7 +483,7 @@ import { releaseAllPointerEvents } from '../input/pointerevent.js';
483
483
  position = target;
484
484
  }
485
485
 
486
- var angle = this.angleTo(position);
486
+ let angle = this.angleTo(position);
487
487
 
488
488
  this.rotate(angle);
489
489
 
@@ -548,7 +548,7 @@ import { releaseAllPointerEvents } from '../input/pointerevent.js';
548
548
  */
549
549
  updateBounds(absolute = true) {
550
550
  if (this.isRenderable) {
551
- var bounds = this.getBounds();
551
+ let bounds = this.getBounds();
552
552
 
553
553
  bounds.clear();
554
554
 
@@ -646,7 +646,7 @@ import { releaseAllPointerEvents } from '../input/pointerevent.js';
646
646
  * @param {CanvasRenderer|WebGLRenderer} renderer - a renderer object
647
647
  */
648
648
  preDraw(renderer) {
649
- var ax = this.width * this.anchorPoint.x,
649
+ let ax = this.width * this.anchorPoint.x,
650
650
  ay = this.height * this.anchorPoint.y;
651
651
 
652
652
  // save renderer context