melonjs 15.1.4 → 15.1.5

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 (158) hide show
  1. package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +1 -1
  2. package/dist/melonjs.mjs/_virtual/earcut.js +1 -1
  3. package/dist/melonjs.mjs/_virtual/howler.js +1 -1
  4. package/dist/melonjs.mjs/_virtual/index.js +1 -1
  5. package/dist/melonjs.mjs/application/application.js +1 -1
  6. package/dist/melonjs.mjs/application/header.js +1 -1
  7. package/dist/melonjs.mjs/application/resize.js +1 -1
  8. package/dist/melonjs.mjs/application/settings.js +1 -1
  9. package/dist/melonjs.mjs/audio/audio.js +1 -1
  10. package/dist/melonjs.mjs/camera/camera2d.js +1 -1
  11. package/dist/melonjs.mjs/const.js +1 -1
  12. package/dist/melonjs.mjs/entity/entity.js +3 -6
  13. package/dist/melonjs.mjs/geometries/ellipse.js +1 -1
  14. package/dist/melonjs.mjs/geometries/line.js +1 -1
  15. package/dist/melonjs.mjs/geometries/path2d.js +5 -5
  16. package/dist/melonjs.mjs/geometries/point.js +1 -1
  17. package/dist/melonjs.mjs/geometries/poly.js +3 -3
  18. package/dist/melonjs.mjs/geometries/rectangle.js +1 -1
  19. package/dist/melonjs.mjs/geometries/roundrect.js +1 -1
  20. package/dist/melonjs.mjs/index.js +2 -2
  21. package/dist/melonjs.mjs/input/gamepad.js +1 -1
  22. package/dist/melonjs.mjs/input/input.js +1 -1
  23. package/dist/melonjs.mjs/input/keyboard.js +1 -1
  24. package/dist/melonjs.mjs/input/pointer.js +1 -1
  25. package/dist/melonjs.mjs/input/pointerevent.js +10 -10
  26. package/dist/melonjs.mjs/lang/console.js +1 -1
  27. package/dist/melonjs.mjs/lang/deprecated.js +1 -1
  28. package/dist/melonjs.mjs/level/level.js +1 -1
  29. package/dist/melonjs.mjs/level/tiled/TMXGroup.js +1 -1
  30. package/dist/melonjs.mjs/level/tiled/TMXLayer.js +4 -4
  31. package/dist/melonjs.mjs/level/tiled/TMXObject.js +1 -1
  32. package/dist/melonjs.mjs/level/tiled/TMXTile.js +1 -1
  33. package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +1 -1
  34. package/dist/melonjs.mjs/level/tiled/TMXTileset.js +1 -1
  35. package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +1 -1
  36. package/dist/melonjs.mjs/level/tiled/TMXUtils.js +4 -4
  37. package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
  38. package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +2 -2
  39. package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
  40. package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
  41. package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +2 -1
  42. package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
  43. package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +1 -1
  44. package/dist/melonjs.mjs/loader/cache.js +1 -1
  45. package/dist/melonjs.mjs/loader/loader.js +4 -3
  46. package/dist/melonjs.mjs/loader/loadingscreen.js +1 -1
  47. package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
  48. package/dist/melonjs.mjs/loader/parser.js +1 -1
  49. package/dist/melonjs.mjs/loader/settings.js +1 -1
  50. package/dist/melonjs.mjs/math/color.js +1 -1
  51. package/dist/melonjs.mjs/math/math.js +1 -1
  52. package/dist/melonjs.mjs/math/matrix2.js +1 -1
  53. package/dist/melonjs.mjs/math/matrix3.js +1 -1
  54. package/dist/melonjs.mjs/math/observable_vector2.js +1 -1
  55. package/dist/melonjs.mjs/math/observable_vector3.js +1 -1
  56. package/dist/melonjs.mjs/math/vector2.js +1 -1
  57. package/dist/melonjs.mjs/math/vector3.js +1 -1
  58. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/arraymultimap.js +1 -1
  59. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/multimap.js +1 -1
  60. package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +1 -1
  61. package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +1 -1
  62. package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +1 -1
  63. package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +1 -1
  64. package/dist/melonjs.mjs/particles/emitter.js +1 -1
  65. package/dist/melonjs.mjs/particles/particle.js +1 -1
  66. package/dist/melonjs.mjs/particles/settings.js +1 -1
  67. package/dist/melonjs.mjs/physics/body.js +1 -1
  68. package/dist/melonjs.mjs/physics/bounds.js +2 -2
  69. package/dist/melonjs.mjs/physics/collision.js +1 -1
  70. package/dist/melonjs.mjs/physics/detector.js +2 -2
  71. package/dist/melonjs.mjs/physics/quadtree.js +2 -2
  72. package/dist/melonjs.mjs/physics/response.js +1 -1
  73. package/dist/melonjs.mjs/physics/sat.js +5 -4
  74. package/dist/melonjs.mjs/physics/world.js +1 -1
  75. package/dist/melonjs.mjs/plugin/plugin.js +3 -3
  76. package/dist/melonjs.mjs/renderable/collectable.js +1 -1
  77. package/dist/melonjs.mjs/renderable/colorlayer.js +1 -1
  78. package/dist/melonjs.mjs/renderable/container.js +35 -25
  79. package/dist/melonjs.mjs/renderable/dragndrop.js +1 -1
  80. package/dist/melonjs.mjs/renderable/imagelayer.js +1 -1
  81. package/dist/melonjs.mjs/renderable/light2d.js +1 -1
  82. package/dist/melonjs.mjs/renderable/nineslicesprite.js +1 -1
  83. package/dist/melonjs.mjs/renderable/renderable.js +6 -9
  84. package/dist/melonjs.mjs/renderable/sprite.js +1 -1
  85. package/dist/melonjs.mjs/renderable/trigger.js +1 -1
  86. package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +7 -4
  87. package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +8 -2
  88. package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +1 -1
  89. package/dist/melonjs.mjs/state/stage.js +1 -1
  90. package/dist/melonjs.mjs/state/state.js +1 -1
  91. package/dist/melonjs.mjs/system/device.js +1 -1
  92. package/dist/melonjs.mjs/system/dom.js +1 -1
  93. package/dist/melonjs.mjs/system/event.js +1 -1
  94. package/dist/melonjs.mjs/system/platform.js +1 -1
  95. package/dist/melonjs.mjs/system/pooling.js +1 -1
  96. package/dist/melonjs.mjs/system/save.js +1 -1
  97. package/dist/melonjs.mjs/system/timer.js +1 -1
  98. package/dist/melonjs.mjs/text/bitmaptext.js +3 -3
  99. package/dist/melonjs.mjs/text/bitmaptextdata.js +1 -1
  100. package/dist/melonjs.mjs/text/glyph.js +1 -1
  101. package/dist/melonjs.mjs/text/text.js +2 -2
  102. package/dist/melonjs.mjs/text/textmetrics.js +1 -1
  103. package/dist/melonjs.mjs/text/textstyle.js +1 -1
  104. package/dist/melonjs.mjs/tweens/easing.js +1 -1
  105. package/dist/melonjs.mjs/tweens/interpolation.js +1 -1
  106. package/dist/melonjs.mjs/tweens/tween.js +1 -1
  107. package/dist/melonjs.mjs/utils/agent.js +1 -1
  108. package/dist/melonjs.mjs/utils/array.js +1 -1
  109. package/dist/melonjs.mjs/utils/file.js +1 -1
  110. package/dist/melonjs.mjs/utils/function.js +1 -1
  111. package/dist/melonjs.mjs/utils/string.js +1 -1
  112. package/dist/melonjs.mjs/utils/utils.js +1 -1
  113. package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +3 -6
  114. package/dist/melonjs.mjs/video/renderer.js +1 -1
  115. package/dist/melonjs.mjs/video/texture/atlas.js +1 -1
  116. package/dist/melonjs.mjs/video/texture/cache.js +1 -1
  117. package/dist/melonjs.mjs/video/texture/canvas_texture.js +2 -2
  118. package/dist/melonjs.mjs/video/utils/autodetect.js +1 -1
  119. package/dist/melonjs.mjs/video/video.js +1 -1
  120. package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +1 -1
  121. package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +1 -1
  122. package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +1 -1
  123. package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +1 -1
  124. package/dist/melonjs.mjs/video/webgl/glshader.js +1 -1
  125. package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +1 -1
  126. package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +1 -1
  127. package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +1 -1
  128. package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +1 -1
  129. package/dist/melonjs.mjs/video/webgl/utils/attributes.js +1 -1
  130. package/dist/melonjs.mjs/video/webgl/utils/precision.js +1 -1
  131. package/dist/melonjs.mjs/video/webgl/utils/program.js +1 -1
  132. package/dist/melonjs.mjs/video/webgl/utils/string.js +1 -1
  133. package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +1 -1
  134. package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +1 -1
  135. package/dist/melonjs.module.js +97 -84
  136. package/dist/types/loader/loader.d.ts +9 -4
  137. package/dist/types/renderable/renderable.d.ts +1 -1
  138. package/package.json +7 -7
  139. package/src/entity/entity.js +2 -5
  140. package/src/geometries/path2d.js +4 -4
  141. package/src/geometries/poly.js +2 -2
  142. package/src/input/pointerevent.js +9 -9
  143. package/src/level/tiled/TMXLayer.js +3 -3
  144. package/src/level/tiled/TMXUtils.js +3 -3
  145. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
  146. package/src/loader/loader.js +3 -2
  147. package/src/physics/bounds.js +1 -1
  148. package/src/physics/detector.js +1 -1
  149. package/src/physics/quadtree.js +1 -1
  150. package/src/physics/sat.js +3 -3
  151. package/src/renderable/container.js +34 -24
  152. package/src/renderable/renderable.js +5 -8
  153. package/src/renderable/ui/uibaseelement.js +6 -3
  154. package/src/renderable/ui/uispriteelement.js +7 -1
  155. package/src/text/bitmaptext.js +2 -2
  156. package/src/text/text.js +1 -1
  157. package/src/video/canvas/canvas_renderer.js +2 -5
  158. package/src/video/texture/canvas_texture.js +1 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v15.1.4
2
+ * melonJS Game Engine - v15.1.5
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -7020,8 +7020,8 @@ var earcut$1 = /*@__PURE__*/getDefaultExportFromCjs(earcutExports);
7020
7020
 
7021
7021
  //http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
7022
7022
  for (let i = 0, j = len - 1; i < len; j = i++) {
7023
- let iy = points[i].y + posy, ix = points[i].x + posx,
7024
- jy = points[j].y + posy, jx = points[j].x + posx;
7023
+ const iy = points[i].y + posy, ix = points[i].x + posx,
7024
+ jy = points[j].y + posy, jx = points[j].x + posx;
7025
7025
  if (((iy > _y) !== (jy > _y)) && (_x < (jx - ix) * (_y - iy) / (jy - iy) + ix)) {
7026
7026
  intersects = !intersects;
7027
7027
  }
@@ -8449,7 +8449,7 @@ let QT_VECTOR = new Vector2d();
8449
8449
  */
8450
8450
  hasChildren() {
8451
8451
  for (let i = 0; i < this.nodes.length; i = i + 1) {
8452
- let subnode = this.nodes[i];
8452
+ const subnode = this.nodes[i];
8453
8453
  if (subnode.length > 0 || subnode.objects.length > 0) {
8454
8454
  return true;
8455
8455
  }
@@ -8670,7 +8670,7 @@ let QT_VECTOR = new Vector2d();
8670
8670
  this.clear();
8671
8671
  }
8672
8672
  for (let i = 0; i < vertices.length; i++) {
8673
- let vertex = vertices[i];
8673
+ const vertex = vertices[i];
8674
8674
  if (vertex.x > this.max.x) this.max.x = vertex.x;
8675
8675
  if (vertex.x < this.min.x) this.min.x = vertex.x;
8676
8676
  if (vertex.y > this.max.y) this.max.y = vertex.y;
@@ -16641,7 +16641,7 @@ function enablePointerEvent() {
16641
16641
  */
16642
16642
  function findActiveEvent(activeEventList, eventTypes) {
16643
16643
  for (let i = 0; i < eventTypes.length; i++) {
16644
- let event = activeEventList.indexOf(eventTypes[i]);
16644
+ const event = activeEventList.indexOf(eventTypes[i]);
16645
16645
  if (event !== -1) {
16646
16646
  return eventTypes[i];
16647
16647
  }
@@ -16654,7 +16654,7 @@ function findActiveEvent(activeEventList, eventTypes) {
16654
16654
  function findAllActiveEvents(activeEventList, eventTypes) {
16655
16655
  let events = [];
16656
16656
  for (let i = 0; i < eventTypes.length; i++) {
16657
- let event = activeEventList.indexOf(eventTypes[i]);
16657
+ const event = activeEventList.indexOf(eventTypes[i]);
16658
16658
  if (event !== -1) {
16659
16659
  events.push(eventTypes[i]);
16660
16660
  }
@@ -16724,10 +16724,10 @@ function dispatchEvent(normalizedEvents) {
16724
16724
 
16725
16725
  for (let c = candidates.length, candidate; c--, (candidate = candidates[c]);) {
16726
16726
  if (eventHandlers.has(candidate) && (candidate.isKinematic !== true)) {
16727
- let handlers = eventHandlers.get(candidate);
16728
- let region = handlers.region;
16729
- let ancestor = region.ancestor;
16730
- let bounds = region.getBounds();
16727
+ const handlers = eventHandlers.get(candidate);
16728
+ const region = handlers.region;
16729
+ const ancestor = region.ancestor;
16730
+ const bounds = region.getBounds();
16731
16731
  let eventInBounds = false;
16732
16732
 
16733
16733
  if (region.isFloating === true) {
@@ -16835,7 +16835,7 @@ function normalizeEvent(originalEvent) {
16835
16835
  if (touchEvent && originalEvent.changedTouches) {
16836
16836
  // iOS/Android Touch event
16837
16837
  for (let i = 0, l = originalEvent.changedTouches.length; i < l; i++) {
16838
- let touchEvent = originalEvent.changedTouches[i];
16838
+ const touchEvent = originalEvent.changedTouches[i];
16839
16839
  _pointer = T_POINTERS.pop();
16840
16840
  _pointer.setEvent(
16841
16841
  originalEvent,
@@ -17113,7 +17113,7 @@ function registerPointerEvent(eventType, region, callback) {
17113
17113
  // allocate array if not defined
17114
17114
  let handlers = eventHandlers.get(region);
17115
17115
  for (let i = 0; i < eventTypes.length; i++) {
17116
- eventType = eventTypes[i];
17116
+ const eventType = eventTypes[i];
17117
17117
  if (handlers.callbacks[eventType]) {
17118
17118
  handlers.callbacks[eventType].push(callback);
17119
17119
  } else {
@@ -17146,7 +17146,7 @@ function releasePointerEvent(eventType, region, callback) {
17146
17146
  let handlers = eventHandlers.get(region);
17147
17147
  if (typeof (handlers) !== "undefined") {
17148
17148
  for (let i = 0; i < eventTypes.length; i++) {
17149
- eventType = eventTypes[i];
17149
+ const eventType = eventTypes[i];
17150
17150
  if (handlers.callbacks[eventType]) {
17151
17151
  if (typeof (callback) !== "undefined") {
17152
17152
  remove(handlers.callbacks[eventType], callback);
@@ -18012,12 +18012,12 @@ var input = {
18012
18012
  }
18013
18013
 
18014
18014
  /**
18015
- * Whether the renderable object is floating, or contained in a floating container
18015
+ * Whether the renderable object is floating (i.e. used screen coordinates), or contained in a floating parent container
18016
18016
  * @see Renderable#floating
18017
18017
  * @type {boolean}
18018
18018
  */
18019
18019
  get isFloating() {
18020
- return this.floating === true || (typeof this.ancestor !== "undefined" && this.ancestor.floating === true);
18020
+ return this.floating === true || (typeof this.ancestor !== "undefined" && this.ancestor.isFloating === true);
18021
18021
  }
18022
18022
 
18023
18023
  /**
@@ -18326,11 +18326,8 @@ var input = {
18326
18326
  }
18327
18327
 
18328
18328
  if (absolute === true) {
18329
- bounds.centerOn(this.pos.x + bounds.x + bounds.width / 2, this.pos.y + bounds.y + bounds.height / 2);
18330
- if (typeof this.ancestor !== "undefined" && typeof this.ancestor.addChild === "function" && this.floating !== true) {
18331
- bounds.translate(this.ancestor.getAbsolutePosition());
18332
- }
18333
-
18329
+ var absPos = this.getAbsolutePosition();
18330
+ bounds.centerOn(absPos.x + bounds.x + bounds.width / 2, absPos.y + bounds.y + bounds.height / 2);
18334
18331
  }
18335
18332
  return bounds;
18336
18333
 
@@ -18359,7 +18356,7 @@ var input = {
18359
18356
  }
18360
18357
  // XXX Cache me or something
18361
18358
  this._absPos.set(this.pos.x, this.pos.y);
18362
- if (typeof this.ancestor !== "undefined" && typeof this.ancestor.addChild === "function" && this.floating !== true) {
18359
+ if (typeof this.ancestor !== "undefined" && typeof this.ancestor.getAbsolutePosition === "function" && this.floating !== true) {
18363
18360
  this._absPos.add(this.ancestor.getAbsolutePosition());
18364
18361
  }
18365
18362
  return this._absPos;
@@ -19951,7 +19948,7 @@ function parseAttributes(obj, elt) {
19951
19948
  // do attributes
19952
19949
  if (elt.attributes && elt.attributes.length > 0) {
19953
19950
  for (let j = 0; j < elt.attributes.length; j++) {
19954
- let attribute = elt.attributes.item(j);
19951
+ const attribute = elt.attributes.item(j);
19955
19952
  if (typeof(attribute.name) !== "undefined") {
19956
19953
  // DOM4 (Attr no longer inherit from Node)
19957
19954
  obj[attribute.name] = attribute.value;
@@ -20150,8 +20147,8 @@ function normalize(obj, item) {
20150
20147
  var points = parse(item).points.split(" "); // <= "Unexpected lexical declaration in case block" if using let
20151
20148
 
20152
20149
  // And normalize them into an array of vectors
20153
- for (let i = 0, v; i < points.length; i++) {
20154
- v = points[i].split(",");
20150
+ for (let i = 0; i < points.length; i++) {
20151
+ const v = points[i].split(",");
20155
20152
  obj[nodeName].push({
20156
20153
  "x" : +v[0],
20157
20154
  "y" : +v[1]
@@ -20930,10 +20927,10 @@ class TMXObject {
20930
20927
  const cos_rotation = Math.cos(rotation);
20931
20928
  const sin_rotation = Math.sin(rotation);
20932
20929
  for (let j = 0; j < nr_of_interpolation_points; j++) {
20933
- let _x1 = radiusX * Math.cos(angle);
20934
- let _y1 = radiusY * Math.sin(angle);
20935
- let _x2 = x + _x1 * cos_rotation - _y1 * sin_rotation;
20936
- let _y2 = y + _x1 * sin_rotation + _y1 * cos_rotation;
20930
+ const _x1 = radiusX * Math.cos(angle);
20931
+ const _y1 = radiusY * Math.sin(angle);
20932
+ const _x2 = x + _x1 * cos_rotation - _y1 * sin_rotation;
20933
+ const _y2 = y + _x1 * sin_rotation + _y1 * cos_rotation;
20937
20934
  points.push(pool.pull("Point", _x2, _y2));
20938
20935
  angle += direction * dangle;
20939
20936
  }
@@ -22639,9 +22636,8 @@ class TextureCache {
22639
22636
  this.translate(poly.pos.x, poly.pos.y);
22640
22637
  context.beginPath();
22641
22638
  context.moveTo(poly.points[0].x, poly.points[0].y);
22642
- let point;
22643
22639
  for (let i = 1; i < poly.points.length; i++) {
22644
- point = poly.points[i];
22640
+ const point = poly.points[i];
22645
22641
  context.lineTo(point.x, point.y);
22646
22642
  }
22647
22643
  context.lineTo(poly.points[0].x, poly.points[0].y);
@@ -22936,11 +22932,9 @@ class TextureCache {
22936
22932
  } else {
22937
22933
  // polygon
22938
22934
  const _x = mask.pos.x, _y = mask.pos.y;
22939
- let point;
22940
-
22941
22935
  context.moveTo(_x + mask.points[0].x, _y + mask.points[0].y);
22942
22936
  for (let i = 1; i < mask.points.length; i++) {
22943
- point = mask.points[i];
22937
+ const point = mask.points[i];
22944
22938
  context.lineTo(_x + point.x, _y + point.y);
22945
22939
  }
22946
22940
  }
@@ -23004,7 +22998,7 @@ function setLayerData(layer, bounds, data) {
23004
22998
  for (let y = 0; y < height; y++) {
23005
22999
  for (let x = 0; x < width; x++) {
23006
23000
  // get the value of the gid
23007
- let gid = data[idx++];
23001
+ const gid = data[idx++];
23008
23002
  // fill the array
23009
23003
  if (gid !== 0) {
23010
23004
  // add a new tile to the layer
@@ -23023,7 +23017,7 @@ function preRenderLayer(layer, renderer) {
23023
23017
  for (let y = 0; y < layer.rows; y++) {
23024
23018
  for (let x = 0; x < layer.cols; x++) {
23025
23019
  // get the value of the gid
23026
- let tile = layer.layerData[x][y];
23020
+ const tile = layer.layerData[x][y];
23027
23021
  // draw the tile if defined
23028
23022
  if (tile instanceof Tile) {
23029
23023
  // add a new tile to the layer
@@ -23090,7 +23084,7 @@ function preRenderLayer(layer, renderer) {
23090
23084
  "height" : 0
23091
23085
  };
23092
23086
  for (let i = 0; i < this.tilesets.length; i++) {
23093
- let tileset = this.tilesets.getTilesetByIndex(i);
23087
+ const tileset = this.tilesets.getTilesetByIndex(i);
23094
23088
  this.maxTileSize.width = Math.max(this.maxTileSize.width, tileset.tilewidth);
23095
23089
  this.maxTileSize.height = Math.max(this.maxTileSize.height, tileset.tileheight);
23096
23090
  }
@@ -23695,10 +23689,16 @@ let globalFloatingCounter = 0;
23695
23689
  }
23696
23690
  }
23697
23691
 
23692
+ // add the new child
23698
23693
  child.ancestor = this;
23699
23694
  this.getChildren().push(child);
23695
+
23696
+ // update child bounds to reflect the new ancestor
23700
23697
  if (typeof child.updateBounds === "function") {
23701
- // update child bounds to reflect the new ancestor
23698
+ if (this.isFloating === true) {
23699
+ // only parent container can be floating
23700
+ child.floating = false;
23701
+ }
23702
23702
  child.updateBounds();
23703
23703
  }
23704
23704
 
@@ -23719,12 +23719,7 @@ let globalFloatingCounter = 0;
23719
23719
  child.onActivateEvent();
23720
23720
  }
23721
23721
 
23722
- // force repaint in case this is a static non-animated object
23723
- if (this.isAttachedToRoot() === true) {
23724
- this.isDirty = true;
23725
- }
23726
-
23727
- // force bounds update if required
23722
+ // force container bounds update if required
23728
23723
  if (this.enableChildBoundsUpdate === true) {
23729
23724
  this.updateBounds();
23730
23725
  }
@@ -23747,6 +23742,9 @@ let globalFloatingCounter = 0;
23747
23742
  }
23748
23743
  }
23749
23744
 
23745
+ // mark the container for repaint
23746
+ this.isDirty = true;
23747
+
23750
23748
  // triggered callback if defined
23751
23749
  this.onChildChange.call(this, this.getChildren().length - 1);
23752
23750
 
@@ -23773,20 +23771,25 @@ let globalFloatingCounter = 0;
23773
23771
  child.GUID = utils.createGUID();
23774
23772
  }
23775
23773
  }
23776
- child.ancestor = this;
23777
23774
 
23775
+ // add the new child
23776
+ child.ancestor = this;
23778
23777
  this.getChildren().splice(index, 0, child);
23779
23778
 
23780
- if (typeof child.onActivateEvent === "function" && this.isAttachedToRoot()) {
23781
- child.onActivateEvent();
23779
+ // update child bounds to reflect the new ancestor
23780
+ if (typeof child.updateBounds === "function") {
23781
+ if (this.isFloating === true) {
23782
+ // only parent container can be floating
23783
+ child.floating = false;
23784
+ }
23785
+ child.updateBounds();
23782
23786
  }
23783
23787
 
23784
- // force repaint in case this is a static non-animated object
23785
- if (this.isAttachedToRoot() === true) {
23786
- this.isDirty = true;
23788
+ if (typeof child.onActivateEvent === "function" && this.isAttachedToRoot()) {
23789
+ child.onActivateEvent();
23787
23790
  }
23788
23791
 
23789
- // force bounds update if required
23792
+ // force container bounds update if required
23790
23793
  if (this.enableChildBoundsUpdate === true) {
23791
23794
  this.updateBounds();
23792
23795
  }
@@ -23809,6 +23812,9 @@ let globalFloatingCounter = 0;
23809
23812
  }
23810
23813
  }
23811
23814
 
23815
+ // mark the container for repaint
23816
+ this.isDirty = true;
23817
+
23812
23818
  // triggered callback if defined
23813
23819
  this.onChildChange.call(this, index);
23814
23820
 
@@ -24033,10 +24039,9 @@ let globalFloatingCounter = 0;
24033
24039
  }
24034
24040
 
24035
24041
  /**
24036
- * update the bounding box for this shape.
24037
- * @ignore
24038
- * @param {boolean} absolute - update the bounds size and position in (world) absolute coordinates
24039
- * @returns {Bounds} this shape bounding box Rectangle object
24042
+ * update the bounding box for this container.
24043
+ * @param {boolean} [absolute=true] - update the bounds size and position in (world) absolute coordinates
24044
+ * @returns {Bounds} this container bounding box Rectangle object
24040
24045
  */
24041
24046
  updateBounds(absolute = true) {
24042
24047
  let bounds = this.getBounds();
@@ -24047,13 +24052,14 @@ let globalFloatingCounter = 0;
24047
24052
  if (this.enableChildBoundsUpdate === true) {
24048
24053
  this.forEach((child) => {
24049
24054
  if (child.isRenderable) {
24050
- let childBounds = child.getBounds();
24055
+ let childBounds = child.updateBounds(true);
24051
24056
  if (childBounds.isFinite()) {
24052
24057
  bounds.addBounds(childBounds);
24053
24058
  }
24054
24059
  }
24055
24060
  });
24056
24061
  }
24062
+
24057
24063
  return bounds;
24058
24064
  }
24059
24065
 
@@ -24177,16 +24183,14 @@ let globalFloatingCounter = 0;
24177
24183
  child.ancestor = undefined;
24178
24184
  }
24179
24185
 
24180
- // force repaint in case this is a static non-animated object
24181
- if (this.isAttachedToRoot() === true) {
24182
- this.isDirty = true;
24183
- }
24184
-
24185
24186
  // force bounds update if required
24186
24187
  if (this.enableChildBoundsUpdate === true) {
24187
24188
  this.updateBounds();
24188
24189
  }
24189
24190
 
24191
+ // mark the container for repaint
24192
+ this.isDirty = true;
24193
+
24190
24194
  // triggered callback if defined
24191
24195
  this.onChildChange.call(this, childIndex);
24192
24196
  }
@@ -24476,6 +24480,7 @@ let globalFloatingCounter = 0;
24476
24480
 
24477
24481
  /* eslint-disable no-unused-vars */
24478
24482
 
24483
+
24479
24484
  /**
24480
24485
  * @classdesc
24481
24486
  * The map renderer base class
@@ -25200,7 +25205,7 @@ const offsetsStaggerY = [
25200
25205
  let nearest = 0;
25201
25206
  let minDist = Number.MAX_VALUE;
25202
25207
  for (let i = 0; i < 4; ++i) {
25203
- let dc = this.centers[i].sub(rel).length2();
25208
+ const dc = this.centers[i].sub(rel).length2();
25204
25209
  if (dc < minDist) {
25205
25210
  minDist = dc;
25206
25211
  nearest = i;
@@ -26759,8 +26764,9 @@ function onLoadingError(res) {
26759
26764
  * an asset definition to be used with the loader
26760
26765
  * @typedef {object} loader.Asset
26761
26766
  * @property {string} name - name of the asset
26762
- * @property {string} type - the type of the asset : "audio", binary", "image", "json","js", "tmx", "tsx", "fontface"
26763
- * @property {string} src - path and/or file name of the resource (for audio assets only the path is required)
26767
+ * @property {string} type - the type of the asset : "audio", binary", "image", "json", "js", "tmx", "tmj", "tsx", "tsj", "fontface"
26768
+ * @property {string} [src] - path and/or file name of the resource (for audio assets only the path is required)
26769
+ * @property {string} [data] - TMX data if not provided through a src url
26764
26770
  * @property {boolean} [stream] - Set to true to force HTML5 Audio, which allows not to wait for large file to be downloaded before playing.
26765
26771
  * @see loader.preload
26766
26772
  * @see loader.load
@@ -32347,7 +32353,7 @@ class CanvasTexture {
32347
32353
  * the rendering context of this CanvasTexture
32348
32354
  * @type {CanvasRenderingContext2D}
32349
32355
  */
32350
- this.context = this.canvas.getContext("2d", { willReadFrequently: attributes.willReadFrequently });
32356
+ this.context = this.canvas.getContext(attributes.context, { willReadFrequently: attributes.willReadFrequently });
32351
32357
 
32352
32358
  // enable or disable antiAlias if specified
32353
32359
  this.setAntiAlias(attributes.antiAlias);
@@ -33181,7 +33187,7 @@ class CanvasTexture {
33181
33187
 
33182
33188
  /**
33183
33189
  * UI base elements use screen coordinates by default
33184
- * (Note: any child elements added to a UIBaseElement should set their floating property to false)
33190
+ * (Note: any child elements added to a UIBaseElement should have their floating property to false)
33185
33191
  * @see Renderable.floating
33186
33192
  * @type {boolean}
33187
33193
  * @default true
@@ -33193,6 +33199,9 @@ class CanvasTexture {
33193
33199
 
33194
33200
  // enable event detection
33195
33201
  this.isKinematic = false;
33202
+
33203
+ // update container and children bounds automatically
33204
+ this.enableChildBoundsUpdate = true;
33196
33205
  }
33197
33206
 
33198
33207
  /**
@@ -33227,7 +33236,7 @@ class CanvasTexture {
33227
33236
  * @returns {boolean} return false if we need to stop propagating the event
33228
33237
  */
33229
33238
  onClick(event) { // eslint-disable-line no-unused-vars
33230
- return false;
33239
+ return true;
33231
33240
  }
33232
33241
 
33233
33242
  /**
@@ -33320,7 +33329,7 @@ class CanvasTexture {
33320
33329
  * @returns {boolean} return false if we need to stop propagating the event
33321
33330
  */
33322
33331
  onRelease() {
33323
- return false;
33332
+ return true;
33324
33333
  }
33325
33334
 
33326
33335
  /**
@@ -33771,7 +33780,7 @@ const toPX = [12, 24, 0.75, 1];
33771
33780
  setContextStyle(context, this);
33772
33781
 
33773
33782
  for (let i = 0; i < text.length; i++) {
33774
- let string = text[i].trimEnd();
33783
+ const string = text[i].trimEnd();
33775
33784
  // draw the string
33776
33785
  if (this.fillStyle.alpha > 0) {
33777
33786
  context.fillText(string, x, y);
@@ -34200,7 +34209,7 @@ const toPX = [12, 24, 0.75, 1];
34200
34209
  }
34201
34210
 
34202
34211
  if (absolute === true) {
34203
- if (typeof this.ancestor !== "undefined" && typeof this.ancestor.addChild === "function" && this.floating !== true) {
34212
+ if (typeof this.ancestor !== "undefined" && typeof this.ancestor.getAbsolutePosition === "function" && this.floating !== true) {
34204
34213
  bounds.translate(this.ancestor.getAbsolutePosition());
34205
34214
  }
34206
34215
  }
@@ -34279,7 +34288,7 @@ const toPX = [12, 24, 0.75, 1];
34279
34288
 
34280
34289
  for (let i = 0; i < this._text.length; i++) {
34281
34290
  x = lX;
34282
- let string = this._text[i].trimEnd();
34291
+ const string = this._text[i].trimEnd();
34283
34292
  // adjust x pos based on alignment value
34284
34293
  let stringWidth = this.metrics.lineWidth(string);
34285
34294
  switch (this.textAlign) {
@@ -34589,7 +34598,13 @@ const toPX = [12, 24, 0.75, 1];
34589
34598
  this.holdTimeout = -1;
34590
34599
  this.released = true;
34591
34600
 
34592
- // GUI items use screen coordinates
34601
+ /**
34602
+ * if this UISpriteElement should use screen coordinates or local coordinates
34603
+ * (Note: any UISpriteElement elements added to a floating parent container should have their floating property to false)
34604
+ * @see Renderable.floating
34605
+ * @type {boolean}
34606
+ * @default true
34607
+ */
34593
34608
  this.floating = true;
34594
34609
 
34595
34610
  // enable event detection
@@ -35527,6 +35542,7 @@ class DropTarget extends Renderable {
35527
35542
  * Available under the MIT License - https://github.com/jriecken/sat-js
35528
35543
  */
35529
35544
 
35545
+
35530
35546
  /**
35531
35547
  * Constants for Vornoi regions
35532
35548
  * @ignore
@@ -35580,7 +35596,7 @@ function flattenPointsOn(points, normal, result) {
35580
35596
  let len = points.length;
35581
35597
  for (let i = 0; i < len; i++) {
35582
35598
  // The magnitude of the projection of the point onto the normal
35583
- let dot = points[i].dot(normal);
35599
+ const dot = points[i].dot(normal);
35584
35600
  if (dot < min) { min = dot; }
35585
35601
  if (dot > max) { max = dot; }
35586
35602
  }
@@ -35827,8 +35843,8 @@ function testPolygonEllipse(a, polyA, b, ellipseB, response) {
35827
35843
 
35828
35844
  // For each edge in the polygon:
35829
35845
  for (let i = 0; i < len; i++) {
35830
- let next = i === len - 1 ? 0 : i + 1;
35831
- let prev = i === 0 ? len - 1 : i - 1;
35846
+ const next = i === len - 1 ? 0 : i + 1;
35847
+ const prev = i === 0 ? len - 1 : i - 1;
35832
35848
  let overlap = 0;
35833
35849
  let overlapN = null;
35834
35850
 
@@ -36217,7 +36233,7 @@ class Detector {
36217
36233
  if (objB.body && line.getBounds().overlaps(objB.getBounds())) {
36218
36234
 
36219
36235
  // go trough all defined shapes in B (if any)
36220
- let bLen = objB.body.shapes.length;
36236
+ const bLen = objB.body.shapes.length;
36221
36237
  if ( objB.body.shapes.length === 0) {
36222
36238
  continue;
36223
36239
  }
@@ -37348,11 +37364,8 @@ function createDefaultParticleTexture(w = 8, h = 8) {
37348
37364
  }
37349
37365
 
37350
37366
  if (absolute === true) {
37351
- bounds.centerOn(this.pos.x + bounds.x + bounds.width / 2, this.pos.y + bounds.y + bounds.height / 2);
37352
- if (typeof this.ancestor !== "undefined" && typeof this.ancestor.addChild === "function" && this.floating !== true) {
37353
- bounds.translate(this.ancestor.getAbsolutePosition());
37354
- }
37355
-
37367
+ var absPos = this.getAbsolutePosition();
37368
+ bounds.centerOn(absPos.x + bounds.x + bounds.width / 2, absPos.y + bounds.y + bounds.height / 2);
37356
37369
  }
37357
37370
 
37358
37371
  return bounds;
@@ -37992,10 +38005,10 @@ class BasePlugin {
37992
38005
  * this can be overridden by the plugin
37993
38006
  * @public
37994
38007
  * @type {string}
37995
- * @default "15.1.4"
38008
+ * @default "15.1.5"
37996
38009
  * @name plugin.Base#version
37997
38010
  */
37998
- this.version = "15.1.4";
38011
+ this.version = "15.1.5";
37999
38012
  }
38000
38013
  }
38001
38014
 
@@ -38223,7 +38236,7 @@ Renderer.prototype.getScreenContext = function() {
38223
38236
  * @name version
38224
38237
  * @type {string}
38225
38238
  */
38226
- const version = "15.1.4";
38239
+ const version = "15.1.5";
38227
38240
 
38228
38241
  /**
38229
38242
  * a flag indicating that melonJS is fully initialized
@@ -2,8 +2,9 @@
2
2
  * an asset definition to be used with the loader
3
3
  * @typedef {object} loader.Asset
4
4
  * @property {string} name - name of the asset
5
- * @property {string} type - the type of the asset : "audio", binary", "image", "json","js", "tmx", "tsx", "fontface"
6
- * @property {string} src - path and/or file name of the resource (for audio assets only the path is required)
5
+ * @property {string} type - the type of the asset : "audio", binary", "image", "json", "js", "tmx", "tmj", "tsx", "tsj", "fontface"
6
+ * @property {string} [src] - path and/or file name of the resource (for audio assets only the path is required)
7
+ * @property {string} [data] - TMX data if not provided through a src url
7
8
  * @property {boolean} [stream] - Set to true to force HTML5 Audio, which allows not to wait for large file to be downloaded before playing.
8
9
  * @see loader.preload
9
10
  * @see loader.load
@@ -145,13 +146,17 @@ export namespace loader {
145
146
  */
146
147
  name: string;
147
148
  /**
148
- * - the type of the asset : "audio", binary", "image", "json","js", "tmx", "tsx", "fontface"
149
+ * - the type of the asset : "audio", binary", "image", "json", "js", "tmx", "tmj", "tsx", "tsj", "fontface"
149
150
  */
150
151
  type: string;
151
152
  /**
152
153
  * - path and/or file name of the resource (for audio assets only the path is required)
153
154
  */
154
- src: string;
155
+ src?: string | undefined;
156
+ /**
157
+ * - TMX data if not provided through a src url
158
+ */
159
+ data?: string | undefined;
155
160
  /**
156
161
  * - Set to true to force HTML5 Audio, which allows not to wait for large file to be downloaded before playing.
157
162
  */
@@ -205,7 +205,7 @@ export default class Renderable extends Rect {
205
205
  };
206
206
  _inViewport: boolean;
207
207
  /**
208
- * Whether the renderable object is floating, or contained in a floating container
208
+ * Whether the renderable object is floating (i.e. used screen coordinates), or contained in a floating parent container
209
209
  * @see Renderable#floating
210
210
  * @type {boolean}
211
211
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "melonjs",
3
- "version": "15.1.4",
3
+ "version": "15.1.5",
4
4
  "description": "melonJS Game Engine",
5
5
  "homepage": "http://www.melonjs.org/",
6
6
  "type": "module",
@@ -55,11 +55,11 @@
55
55
  "@teppeis/multimaps": "^3.0.0",
56
56
  "core-js": "^3.30.1",
57
57
  "earcut": "2.2.4",
58
- "eventemitter3": "^5.0.0",
58
+ "eventemitter3": "^5.0.1",
59
59
  "howler": "2.2.3"
60
60
  },
61
61
  "devDependencies": {
62
- "@babel/eslint-parser": "^7.21.3",
62
+ "@babel/eslint-parser": "^7.21.8",
63
63
  "@babel/plugin-syntax-import-assertions": "^7.20.0",
64
64
  "@fastify/static": "^6.10.1",
65
65
  "@melonjs/webdoc-theme": "^1.1.1",
@@ -68,18 +68,18 @@
68
68
  "@rollup/plugin-node-resolve": "^15.0.2",
69
69
  "@rollup/plugin-replace": "^5.0.2",
70
70
  "@webdoc/cli": "^2.2.0",
71
- "chromedriver": "^112.0.0",
71
+ "chromedriver": "^112.0.1",
72
72
  "cross-env": "^7.0.3",
73
73
  "del-cli": "^5.0.0",
74
74
  "eslint": "^8.39.0",
75
75
  "eslint-plugin-jsdoc": "^43.1.1",
76
76
  "expect": "^29.5.0",
77
77
  "expect-mocha-image-snapshot": "^3.0.13",
78
- "fastify": "^4.16.3",
78
+ "fastify": "^4.17.0",
79
79
  "mocha": "^10.2.0",
80
80
  "npm-self-link": "^1.1.7",
81
- "puppeteer": "^19.11.1",
82
- "rollup": "^3.21.0",
81
+ "puppeteer": "^20.1.0",
82
+ "rollup": "^3.21.5",
83
83
  "rollup-plugin-bundle-size": "^1.0.3",
84
84
  "rollup-plugin-string": "^3.0.0",
85
85
  "terser": "^5.17.1",
@@ -180,11 +180,8 @@ import Body from "./../physics/body.js";
180
180
  }
181
181
 
182
182
  if (absolute === true) {
183
- bounds.centerOn(this.pos.x + bounds.x + bounds.width / 2, this.pos.y + bounds.y + bounds.height / 2);
184
- if (typeof this.ancestor !== "undefined" && typeof this.ancestor.addChild === "function" && this.floating !== true) {
185
- bounds.translate(this.ancestor.getAbsolutePosition());
186
- }
187
-
183
+ var absPos = this.getAbsolutePosition();
184
+ bounds.centerOn(absPos.x + bounds.x + bounds.width / 2, absPos.y + bounds.y + bounds.height / 2);
188
185
  }
189
186
 
190
187
  return bounds;
@@ -235,10 +235,10 @@ import earcut from "earcut";
235
235
  const cos_rotation = Math.cos(rotation);
236
236
  const sin_rotation = Math.sin(rotation);
237
237
  for (let j = 0; j < nr_of_interpolation_points; j++) {
238
- let _x1 = radiusX * Math.cos(angle);
239
- let _y1 = radiusY * Math.sin(angle);
240
- let _x2 = x + _x1 * cos_rotation - _y1 * sin_rotation;
241
- let _y2 = y + _x1 * sin_rotation + _y1 * cos_rotation;
238
+ const _x1 = radiusX * Math.cos(angle);
239
+ const _y1 = radiusY * Math.sin(angle);
240
+ const _x2 = x + _x1 * cos_rotation - _y1 * sin_rotation;
241
+ const _y2 = y + _x1 * sin_rotation + _y1 * cos_rotation;
242
242
  points.push(pool.pull("Point", _x2, _y2));
243
243
  angle += direction * dangle;
244
244
  }
@@ -432,8 +432,8 @@ import pool from "./../system/pooling.js";
432
432
 
433
433
  //http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
434
434
  for (let i = 0, j = len - 1; i < len; j = i++) {
435
- let iy = points[i].y + posy, ix = points[i].x + posx,
436
- jy = points[j].y + posy, jx = points[j].x + posx;
435
+ const iy = points[i].y + posy, ix = points[i].x + posx,
436
+ jy = points[j].y + posy, jx = points[j].x + posx;
437
437
  if (((iy > _y) !== (jy > _y)) && (_x < (jx - ix) * (_y - iy) / (jy - iy) + ix)) {
438
438
  intersects = !intersects;
439
439
  }