melonjs 15.1.4 → 15.1.6
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.
- package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +1 -1
- package/dist/melonjs.mjs/_virtual/earcut.js +1 -1
- package/dist/melonjs.mjs/_virtual/howler.js +1 -1
- package/dist/melonjs.mjs/_virtual/index.js +1 -1
- package/dist/melonjs.mjs/application/application.js +1 -1
- package/dist/melonjs.mjs/application/header.js +1 -1
- package/dist/melonjs.mjs/application/resize.js +1 -1
- package/dist/melonjs.mjs/application/settings.js +1 -1
- package/dist/melonjs.mjs/audio/audio.js +1 -1
- package/dist/melonjs.mjs/camera/camera2d.js +3 -3
- package/dist/melonjs.mjs/const.js +1 -1
- package/dist/melonjs.mjs/entity/entity.js +3 -6
- package/dist/melonjs.mjs/geometries/ellipse.js +1 -1
- package/dist/melonjs.mjs/geometries/line.js +1 -1
- package/dist/melonjs.mjs/geometries/path2d.js +5 -5
- package/dist/melonjs.mjs/geometries/point.js +1 -1
- package/dist/melonjs.mjs/geometries/poly.js +3 -3
- package/dist/melonjs.mjs/geometries/rectangle.js +1 -1
- package/dist/melonjs.mjs/geometries/roundrect.js +1 -1
- package/dist/melonjs.mjs/index.js +4 -3
- package/dist/melonjs.mjs/input/gamepad.js +1 -1
- package/dist/melonjs.mjs/input/input.js +1 -1
- package/dist/melonjs.mjs/input/keyboard.js +1 -1
- package/dist/melonjs.mjs/input/pointer.js +1 -1
- package/dist/melonjs.mjs/input/pointerevent.js +10 -10
- package/dist/melonjs.mjs/lang/console.js +1 -1
- package/dist/melonjs.mjs/lang/deprecated.js +3 -2
- package/dist/melonjs.mjs/level/level.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXGroup.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXLayer.js +4 -4
- package/dist/melonjs.mjs/level/tiled/TMXObject.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXTile.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +4 -4
- package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +2 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +1 -1
- package/dist/melonjs.mjs/loader/cache.js +1 -1
- package/dist/melonjs.mjs/loader/loader.js +4 -3
- package/dist/melonjs.mjs/loader/loadingscreen.js +1 -1
- package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
- package/dist/melonjs.mjs/loader/parser.js +1 -1
- package/dist/melonjs.mjs/loader/settings.js +1 -1
- package/dist/melonjs.mjs/math/color.js +1 -1
- package/dist/melonjs.mjs/math/math.js +1 -1
- package/dist/melonjs.mjs/math/matrix2.js +1 -1
- package/dist/melonjs.mjs/math/matrix3.js +1 -1
- package/dist/melonjs.mjs/math/observable_vector2.js +1 -1
- package/dist/melonjs.mjs/math/observable_vector3.js +1 -1
- package/dist/melonjs.mjs/math/vector2.js +1 -1
- package/dist/melonjs.mjs/math/vector3.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/arraymultimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/multimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +1 -1
- package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +1 -1
- package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +1 -1
- package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +1 -1
- package/dist/melonjs.mjs/particles/emitter.js +1 -1
- package/dist/melonjs.mjs/particles/particle.js +1 -1
- package/dist/melonjs.mjs/particles/settings.js +1 -1
- package/dist/melonjs.mjs/physics/body.js +3 -3
- package/dist/melonjs.mjs/physics/bounds.js +2 -2
- package/dist/melonjs.mjs/physics/collision.js +1 -1
- package/dist/melonjs.mjs/physics/detector.js +5 -5
- package/dist/melonjs.mjs/physics/quadtree.js +2 -2
- package/dist/melonjs.mjs/physics/response.js +1 -1
- package/dist/melonjs.mjs/physics/sat.js +13 -12
- package/dist/melonjs.mjs/physics/world.js +1 -1
- package/dist/melonjs.mjs/plugin/plugin.js +3 -3
- package/dist/melonjs.mjs/renderable/collectable.js +1 -1
- package/dist/melonjs.mjs/renderable/colorlayer.js +1 -1
- package/dist/melonjs.mjs/renderable/container.js +48 -38
- package/dist/melonjs.mjs/renderable/draggable.js +121 -0
- package/dist/melonjs.mjs/renderable/dragndrop.js +3 -113
- package/dist/melonjs.mjs/renderable/imagelayer.js +1 -1
- package/dist/melonjs.mjs/renderable/light2d.js +1 -1
- package/dist/melonjs.mjs/renderable/nineslicesprite.js +1 -1
- package/dist/melonjs.mjs/renderable/renderable.js +7 -10
- package/dist/melonjs.mjs/renderable/sprite.js +1 -1
- package/dist/melonjs.mjs/renderable/trigger.js +2 -2
- package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +7 -4
- package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +8 -2
- package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +1 -1
- package/dist/melonjs.mjs/state/stage.js +1 -1
- package/dist/melonjs.mjs/state/state.js +1 -1
- package/dist/melonjs.mjs/system/device.js +1 -1
- package/dist/melonjs.mjs/system/dom.js +1 -1
- package/dist/melonjs.mjs/system/event.js +1 -1
- package/dist/melonjs.mjs/system/platform.js +1 -1
- package/dist/melonjs.mjs/system/pooling.js +1 -1
- package/dist/melonjs.mjs/system/save.js +1 -1
- package/dist/melonjs.mjs/system/timer.js +1 -1
- package/dist/melonjs.mjs/text/bitmaptext.js +3 -3
- package/dist/melonjs.mjs/text/bitmaptextdata.js +1 -1
- package/dist/melonjs.mjs/text/glyph.js +1 -1
- package/dist/melonjs.mjs/text/text.js +2 -2
- package/dist/melonjs.mjs/text/textmetrics.js +1 -1
- package/dist/melonjs.mjs/text/textstyle.js +1 -1
- package/dist/melonjs.mjs/tweens/easing.js +1 -1
- package/dist/melonjs.mjs/tweens/interpolation.js +1 -1
- package/dist/melonjs.mjs/tweens/tween.js +1 -1
- package/dist/melonjs.mjs/utils/agent.js +1 -1
- package/dist/melonjs.mjs/utils/array.js +1 -1
- package/dist/melonjs.mjs/utils/file.js +1 -1
- package/dist/melonjs.mjs/utils/function.js +1 -1
- package/dist/melonjs.mjs/utils/string.js +1 -1
- package/dist/melonjs.mjs/utils/utils.js +1 -1
- package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +3 -6
- package/dist/melonjs.mjs/video/renderer.js +1 -1
- package/dist/melonjs.mjs/video/texture/atlas.js +1 -1
- package/dist/melonjs.mjs/video/texture/cache.js +1 -1
- package/dist/melonjs.mjs/video/texture/canvas_texture.js +2 -2
- package/dist/melonjs.mjs/video/utils/autodetect.js +1 -1
- package/dist/melonjs.mjs/video/video.js +1 -1
- package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +1 -1
- package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +1 -1
- package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +1 -1
- package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +1 -1
- package/dist/melonjs.mjs/video/webgl/glshader.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/attributes.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/precision.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/program.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/string.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +1 -1
- package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +1 -1
- package/dist/melonjs.module.js +153 -135
- package/dist/types/camera/camera2d.d.ts +4 -4
- package/dist/types/index.d.ts +1 -1
- package/dist/types/loader/loader.d.ts +9 -4
- package/dist/types/physics/body.d.ts +4 -4
- package/dist/types/physics/detector.d.ts +5 -5
- package/dist/types/physics/sat.d.ts +12 -12
- package/dist/types/renderable/container.d.ts +25 -25
- package/dist/types/renderable/draggable.d.ts +53 -0
- package/dist/types/renderable/dragndrop.d.ts +0 -52
- package/dist/types/renderable/renderable.d.ts +3 -3
- package/package.json +11 -11
- package/src/camera/camera2d.js +2 -2
- package/src/entity/entity.js +2 -5
- package/src/geometries/path2d.js +4 -4
- package/src/geometries/poly.js +2 -2
- package/src/index.js +2 -1
- package/src/input/pointerevent.js +9 -9
- package/src/lang/deprecated.js +2 -1
- package/src/level/tiled/TMXLayer.js +3 -3
- package/src/level/tiled/TMXUtils.js +3 -3
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
- package/src/loader/loader.js +3 -2
- package/src/physics/body.js +2 -2
- package/src/physics/bounds.js +1 -1
- package/src/physics/detector.js +4 -4
- package/src/physics/quadtree.js +1 -1
- package/src/physics/sat.js +11 -11
- package/src/renderable/container.js +47 -37
- package/src/renderable/draggable.js +114 -0
- package/src/renderable/dragndrop.js +0 -109
- package/src/renderable/renderable.js +6 -9
- package/src/renderable/trigger.js +1 -1
- package/src/renderable/ui/uibaseelement.js +6 -3
- package/src/renderable/ui/uispriteelement.js +7 -1
- package/src/text/bitmaptext.js +2 -2
- package/src/text/text.js +1 -1
- package/src/video/canvas/canvas_renderer.js +2 -5
- package/src/video/texture/canvas_texture.js +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.1.
|
|
2
|
+
* melonJS Game Engine - v15.1.6
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -23,7 +23,7 @@ import Point from '../geometries/point.js';
|
|
|
23
23
|
*/
|
|
24
24
|
class Body {
|
|
25
25
|
/**
|
|
26
|
-
* @param {Renderable} ancestor - the parent object this body is attached to
|
|
26
|
+
* @param {Renderable|Container|Entity|Sprite|NineSliceSprite} ancestor - the parent object this body is attached to
|
|
27
27
|
* @param {Rect|Rect[]|Polygon|Polygon[]|Line|Line[]|Ellipse|Ellipse[]|Point|Point[]|Bounds|Bounds[]|object} [shapes] - a initial shape, list of shapes, or JSON object defining the body
|
|
28
28
|
* @param {Function} [onBodyUpdate] - callback for when the body is updated (e.g. add/remove shapes)
|
|
29
29
|
*/
|
|
@@ -33,7 +33,7 @@ import Point from '../geometries/point.js';
|
|
|
33
33
|
* a reference to the parent object that contains this body,
|
|
34
34
|
* or undefined if it has not been added to one.
|
|
35
35
|
* @public
|
|
36
|
-
* @type {Renderable}
|
|
36
|
+
* @type {Renderable|Container|Entity|Sprite|NineSliceSprite}
|
|
37
37
|
* @default undefined
|
|
38
38
|
*/
|
|
39
39
|
this.ancestor = ancestor;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.1.
|
|
2
|
+
* melonJS Game Engine - v15.1.6
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -197,7 +197,7 @@ import Vector2d from '../math/vector2.js';
|
|
|
197
197
|
this.clear();
|
|
198
198
|
}
|
|
199
199
|
for (let i = 0; i < vertices.length; i++) {
|
|
200
|
-
|
|
200
|
+
const vertex = vertices[i];
|
|
201
201
|
if (vertex.x > this.max.x) this.max.x = vertex.x;
|
|
202
202
|
if (vertex.x < this.min.x) this.min.x = vertex.x;
|
|
203
203
|
if (vertex.y > this.max.y) this.max.y = vertex.y;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.1.
|
|
2
|
+
* melonJS Game Engine - v15.1.6
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -47,8 +47,8 @@ class Detector {
|
|
|
47
47
|
/**
|
|
48
48
|
* determine if two objects should collide (based on both respective objects body collision mask and type).<br>
|
|
49
49
|
* you can redefine this function if you need any specific rules over what should collide with what.
|
|
50
|
-
* @param {Renderable} a - a reference to the object A.
|
|
51
|
-
* @param {Renderable} b - a reference to the object B.
|
|
50
|
+
* @param {Renderable|Container|Entity|Sprite|NineSliceSprite} a - a reference to the object A.
|
|
51
|
+
* @param {Renderable|Container|Entity|Sprite|NineSliceSprite} b - a reference to the object B.
|
|
52
52
|
* @returns {boolean} true if they should collide, false otherwise
|
|
53
53
|
*/
|
|
54
54
|
shouldCollide(a, b) {
|
|
@@ -101,7 +101,7 @@ class Detector {
|
|
|
101
101
|
/**
|
|
102
102
|
* find all the collisions for the specified object using a broadphase algorithm
|
|
103
103
|
* @ignore
|
|
104
|
-
* @param {Renderable} objA - object to be tested for collision
|
|
104
|
+
* @param {Renderable|Container|Entity|Sprite|NineSliceSprite} objA - object to be tested for collision
|
|
105
105
|
* @returns {boolean} in case of collision, false otherwise
|
|
106
106
|
*/
|
|
107
107
|
collisions(objA) {
|
|
@@ -177,7 +177,7 @@ class Detector {
|
|
|
177
177
|
if (objB.body && line.getBounds().overlaps(objB.getBounds())) {
|
|
178
178
|
|
|
179
179
|
// go trough all defined shapes in B (if any)
|
|
180
|
-
|
|
180
|
+
const bLen = objB.body.shapes.length;
|
|
181
181
|
if ( objB.body.shapes.length === 0) {
|
|
182
182
|
continue;
|
|
183
183
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.1.
|
|
2
|
+
* melonJS Game Engine - v15.1.6
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -359,7 +359,7 @@ let QT_VECTOR = new Vector2d();
|
|
|
359
359
|
*/
|
|
360
360
|
hasChildren() {
|
|
361
361
|
for (let i = 0; i < this.nodes.length; i = i + 1) {
|
|
362
|
-
|
|
362
|
+
const subnode = this.nodes[i];
|
|
363
363
|
if (subnode.length > 0 || subnode.objects.length > 0) {
|
|
364
364
|
return true;
|
|
365
365
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.1.
|
|
2
|
+
* melonJS Game Engine - v15.1.6
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -12,6 +12,7 @@ import Vector2d from '../math/vector2.js';
|
|
|
12
12
|
* Available under the MIT License - https://github.com/jriecken/sat-js
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
+
|
|
15
16
|
/**
|
|
16
17
|
* Constants for Vornoi regions
|
|
17
18
|
* @ignore
|
|
@@ -65,7 +66,7 @@ function flattenPointsOn(points, normal, result) {
|
|
|
65
66
|
let len = points.length;
|
|
66
67
|
for (let i = 0; i < len; i++) {
|
|
67
68
|
// The magnitude of the projection of the point onto the normal
|
|
68
|
-
|
|
69
|
+
const dot = points[i].dot(normal);
|
|
69
70
|
if (dot < min) { min = dot; }
|
|
70
71
|
if (dot > max) { max = dot; }
|
|
71
72
|
}
|
|
@@ -194,9 +195,9 @@ function vornoiRegion(line, point) {
|
|
|
194
195
|
/**
|
|
195
196
|
* Checks whether polygons collide.
|
|
196
197
|
* @ignore
|
|
197
|
-
* @param {Renderable} a - a reference to the object A.
|
|
198
|
+
* @param {Renderable|Container|Entity|Sprite|NineSliceSprite} a - a reference to the object A.
|
|
198
199
|
* @param {Polygon} polyA - a reference to the object A Polygon to be tested
|
|
199
|
-
* @param {Renderable} b - a reference to the object B.
|
|
200
|
+
* @param {Renderable|Container|Entity|Sprite|NineSliceSprite} b - a reference to the object B.
|
|
200
201
|
* @param {Polygon} polyB - a reference to the object B Polygon to be tested
|
|
201
202
|
* @param {Response=} response - Response object (optional) that will be populated if they intersect.
|
|
202
203
|
* @returns {boolean} true if they intersect, false if they don't.
|
|
@@ -248,9 +249,9 @@ function testPolygonPolygon(a, polyA, b, polyB, response) {
|
|
|
248
249
|
/**
|
|
249
250
|
* Check if two Ellipse collide.
|
|
250
251
|
* @ignore
|
|
251
|
-
* @param {Renderable} a - a reference to the object A.
|
|
252
|
+
* @param {Renderable|Container|Entity|Sprite|NineSliceSprite} a - a reference to the object A.
|
|
252
253
|
* @param {Ellipse} ellipseA - a reference to the object A Ellipse to be tested
|
|
253
|
-
* @param {Renderable} b - a reference to the object B.
|
|
254
|
+
* @param {Renderable|Container|Entity|Sprite|NineSliceSprite} b - a reference to the object B.
|
|
254
255
|
* @param {Ellipse} ellipseB - a reference to the object B Ellipse to be tested
|
|
255
256
|
* @param {Response=} response - Response object (optional) that will be populated if
|
|
256
257
|
* the circles intersect.
|
|
@@ -289,9 +290,9 @@ function testEllipseEllipse(a, ellipseA, b, ellipseB, response) {
|
|
|
289
290
|
/**
|
|
290
291
|
* Check if a polygon and an ellipse collide.
|
|
291
292
|
* @ignore
|
|
292
|
-
* @param {Renderable} a - a reference to the object A.
|
|
293
|
+
* @param {Renderable|Container|Entity|Sprite|NineSliceSprite} a - a reference to the object A.
|
|
293
294
|
* @param {Polygon} polyA - a reference to the object A Polygon to be tested
|
|
294
|
-
* @param {Renderable} b - a reference to the object B.
|
|
295
|
+
* @param {Renderable|Container|Entity|Sprite|NineSliceSprite} b - a reference to the object B.
|
|
295
296
|
* @param {Ellipse} ellipseB - a reference to the object B Ellipse to be tested
|
|
296
297
|
* @param {Response=} response - Response object (optional) that will be populated if they intersect.
|
|
297
298
|
* @returns {boolean} true if they intersect, false if they don't.
|
|
@@ -312,8 +313,8 @@ function testPolygonEllipse(a, polyA, b, ellipseB, response) {
|
|
|
312
313
|
|
|
313
314
|
// For each edge in the polygon:
|
|
314
315
|
for (let i = 0; i < len; i++) {
|
|
315
|
-
|
|
316
|
-
|
|
316
|
+
const next = i === len - 1 ? 0 : i + 1;
|
|
317
|
+
const prev = i === 0 ? len - 1 : i - 1;
|
|
317
318
|
let overlap = 0;
|
|
318
319
|
let overlapN = null;
|
|
319
320
|
|
|
@@ -455,9 +456,9 @@ function testPolygonEllipse(a, polyA, b, ellipseB, response) {
|
|
|
455
456
|
* **NOTE:** This is slightly less efficient than testPolygonEllipse as it just
|
|
456
457
|
* runs testPolygonEllipse and reverses the response at the end.
|
|
457
458
|
* @ignore
|
|
458
|
-
* @param {Renderable} a - a reference to the object A.
|
|
459
|
+
* @param {Renderable|Container|Entity|Sprite|NineSliceSprite} a - a reference to the object A.
|
|
459
460
|
* @param {Ellipse} ellipseA - a reference to the object A Ellipse to be tested
|
|
460
|
-
* @param {Renderable} b - a reference to the object B.
|
|
461
|
+
* @param {Renderable|Container|Entity|Sprite|NineSliceSprite} b - a reference to the object B.
|
|
461
462
|
* @param {Polygon} polyB - a reference to the object B Polygon to be tested
|
|
462
463
|
* @param {Response=} response - Response object (optional) that will be populated if
|
|
463
464
|
* they intersect.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.1.
|
|
2
|
+
* melonJS Game Engine - v15.1.6
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -24,10 +24,10 @@ class BasePlugin {
|
|
|
24
24
|
* this can be overridden by the plugin
|
|
25
25
|
* @public
|
|
26
26
|
* @type {string}
|
|
27
|
-
* @default "15.1.
|
|
27
|
+
* @default "15.1.6"
|
|
28
28
|
* @name plugin.Base#version
|
|
29
29
|
*/
|
|
30
|
-
this.version = "15.1.
|
|
30
|
+
this.version = "15.1.6";
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.1.
|
|
2
|
+
* melonJS Game Engine - v15.1.6
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -183,7 +183,7 @@ let globalFloatingCounter = 0;
|
|
|
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.
|
|
186
|
-
* @param {Renderable} child
|
|
186
|
+
* @param {Renderable|Entity|Sprite|Collectable|Trigger|Draggable|DropTarget|NineSliceSprite|ImageLayer|ColorLayer|Light2d|UIBaseElement|UISpriteElement|UITextButton|Text|BitmapText} child
|
|
187
187
|
* @param {number} [z] - forces the z index of the child to the specified value
|
|
188
188
|
* @returns {Renderable} the added child
|
|
189
189
|
*/
|
|
@@ -200,10 +200,16 @@ let globalFloatingCounter = 0;
|
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
+
// add the new child
|
|
203
204
|
child.ancestor = this;
|
|
204
205
|
this.getChildren().push(child);
|
|
206
|
+
|
|
207
|
+
// update child bounds to reflect the new ancestor
|
|
205
208
|
if (typeof child.updateBounds === "function") {
|
|
206
|
-
|
|
209
|
+
if (this.isFloating === true) {
|
|
210
|
+
// only parent container can be floating
|
|
211
|
+
child.floating = false;
|
|
212
|
+
}
|
|
207
213
|
child.updateBounds();
|
|
208
214
|
}
|
|
209
215
|
|
|
@@ -224,12 +230,7 @@ let globalFloatingCounter = 0;
|
|
|
224
230
|
child.onActivateEvent();
|
|
225
231
|
}
|
|
226
232
|
|
|
227
|
-
// force
|
|
228
|
-
if (this.isAttachedToRoot() === true) {
|
|
229
|
-
this.isDirty = true;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// force bounds update if required
|
|
233
|
+
// force container bounds update if required
|
|
233
234
|
if (this.enableChildBoundsUpdate === true) {
|
|
234
235
|
this.updateBounds();
|
|
235
236
|
}
|
|
@@ -252,6 +253,9 @@ let globalFloatingCounter = 0;
|
|
|
252
253
|
}
|
|
253
254
|
}
|
|
254
255
|
|
|
256
|
+
// mark the container for repaint
|
|
257
|
+
this.isDirty = true;
|
|
258
|
+
|
|
255
259
|
// triggered callback if defined
|
|
256
260
|
this.onChildChange.call(this, this.getChildren().length - 1);
|
|
257
261
|
|
|
@@ -261,7 +265,7 @@ let globalFloatingCounter = 0;
|
|
|
261
265
|
/**
|
|
262
266
|
* Add a child to the container at the specified index<br>
|
|
263
267
|
* (the list won't be sorted after insertion)
|
|
264
|
-
* @param {Renderable} child
|
|
268
|
+
* @param {Renderable|Entity|Sprite|Collectable|Trigger|Draggable|DropTarget|NineSliceSprite|ImageLayer|ColorLayer|Light2d|UIBaseElement|UISpriteElement|UITextButton|Text|BitmapText} child
|
|
265
269
|
* @param {number} index
|
|
266
270
|
* @returns {Renderable} the added child
|
|
267
271
|
*/
|
|
@@ -278,20 +282,25 @@ let globalFloatingCounter = 0;
|
|
|
278
282
|
child.GUID = utils.createGUID();
|
|
279
283
|
}
|
|
280
284
|
}
|
|
281
|
-
child.ancestor = this;
|
|
282
285
|
|
|
286
|
+
// add the new child
|
|
287
|
+
child.ancestor = this;
|
|
283
288
|
this.getChildren().splice(index, 0, child);
|
|
284
289
|
|
|
285
|
-
|
|
286
|
-
|
|
290
|
+
// update child bounds to reflect the new ancestor
|
|
291
|
+
if (typeof child.updateBounds === "function") {
|
|
292
|
+
if (this.isFloating === true) {
|
|
293
|
+
// only parent container can be floating
|
|
294
|
+
child.floating = false;
|
|
295
|
+
}
|
|
296
|
+
child.updateBounds();
|
|
287
297
|
}
|
|
288
298
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
this.isDirty = true;
|
|
299
|
+
if (typeof child.onActivateEvent === "function" && this.isAttachedToRoot()) {
|
|
300
|
+
child.onActivateEvent();
|
|
292
301
|
}
|
|
293
302
|
|
|
294
|
-
// force bounds update if required
|
|
303
|
+
// force container bounds update if required
|
|
295
304
|
if (this.enableChildBoundsUpdate === true) {
|
|
296
305
|
this.updateBounds();
|
|
297
306
|
}
|
|
@@ -314,6 +323,9 @@ let globalFloatingCounter = 0;
|
|
|
314
323
|
}
|
|
315
324
|
}
|
|
316
325
|
|
|
326
|
+
// mark the container for repaint
|
|
327
|
+
this.isDirty = true;
|
|
328
|
+
|
|
317
329
|
// triggered callback if defined
|
|
318
330
|
this.onChildChange.call(this, index);
|
|
319
331
|
|
|
@@ -364,8 +376,8 @@ let globalFloatingCounter = 0;
|
|
|
364
376
|
|
|
365
377
|
/**
|
|
366
378
|
* Swaps the position (z-index) of 2 children
|
|
367
|
-
* @param {Renderable} child
|
|
368
|
-
* @param {Renderable} child2
|
|
379
|
+
* @param {Renderable|Entity|Sprite|Collectable|Trigger|Draggable|DropTarget|NineSliceSprite|ImageLayer|ColorLayer|Light2d|UIBaseElement|UISpriteElement|UITextButton|Text|BitmapText} child
|
|
380
|
+
* @param {Renderable|Entity|Sprite|Collectable|Trigger|Draggable|DropTarget|NineSliceSprite|ImageLayer|ColorLayer|Light2d|UIBaseElement|UISpriteElement|UITextButton|Text|BitmapText} child2
|
|
369
381
|
*/
|
|
370
382
|
swapChildren(child, child2) {
|
|
371
383
|
let index = this.getChildIndex(child);
|
|
@@ -403,7 +415,7 @@ let globalFloatingCounter = 0;
|
|
|
403
415
|
|
|
404
416
|
/**
|
|
405
417
|
* Returns the index of the given Child
|
|
406
|
-
* @param {Renderable} child
|
|
418
|
+
* @param {Renderable|Entity|Sprite|Collectable|Trigger|Draggable|DropTarget|NineSliceSprite|ImageLayer|ColorLayer|Light2d|UIBaseElement|UISpriteElement|UITextButton|Text|BitmapText} child
|
|
407
419
|
* @returns {number} index
|
|
408
420
|
*/
|
|
409
421
|
getChildIndex(child) {
|
|
@@ -412,7 +424,7 @@ let globalFloatingCounter = 0;
|
|
|
412
424
|
|
|
413
425
|
/**
|
|
414
426
|
* Returns the next child within the container or undefined if none
|
|
415
|
-
* @param {Renderable} child
|
|
427
|
+
* @param {Renderable|Entity|Sprite|Collectable|Trigger|Draggable|DropTarget|NineSliceSprite|ImageLayer|ColorLayer|Light2d|UIBaseElement|UISpriteElement|UITextButton|Text|BitmapText} child
|
|
416
428
|
* @returns {Renderable} child
|
|
417
429
|
*/
|
|
418
430
|
getNextChild(child) {
|
|
@@ -425,7 +437,7 @@ let globalFloatingCounter = 0;
|
|
|
425
437
|
|
|
426
438
|
/**
|
|
427
439
|
* Returns true if contains the specified Child
|
|
428
|
-
* @param {Renderable} child
|
|
440
|
+
* @param {Renderable|Entity|Sprite|Collectable|Trigger|Draggable|DropTarget|NineSliceSprite|ImageLayer|ColorLayer|Light2d|UIBaseElement|UISpriteElement|UITextButton|Text|BitmapText} child
|
|
429
441
|
* @returns {boolean}
|
|
430
442
|
*/
|
|
431
443
|
hasChild(child) {
|
|
@@ -538,10 +550,9 @@ let globalFloatingCounter = 0;
|
|
|
538
550
|
}
|
|
539
551
|
|
|
540
552
|
/**
|
|
541
|
-
* update the bounding box for this
|
|
542
|
-
* @
|
|
543
|
-
* @
|
|
544
|
-
* @returns {Bounds} this shape bounding box Rectangle object
|
|
553
|
+
* update the bounding box for this container.
|
|
554
|
+
* @param {boolean} [absolute=true] - update the bounds size and position in (world) absolute coordinates
|
|
555
|
+
* @returns {Bounds} this container bounding box Rectangle object
|
|
545
556
|
*/
|
|
546
557
|
updateBounds(absolute = true) {
|
|
547
558
|
let bounds = this.getBounds();
|
|
@@ -552,13 +563,14 @@ let globalFloatingCounter = 0;
|
|
|
552
563
|
if (this.enableChildBoundsUpdate === true) {
|
|
553
564
|
this.forEach((child) => {
|
|
554
565
|
if (child.isRenderable) {
|
|
555
|
-
let childBounds = child.
|
|
566
|
+
let childBounds = child.updateBounds(true);
|
|
556
567
|
if (childBounds.isFinite()) {
|
|
557
568
|
bounds.addBounds(childBounds);
|
|
558
569
|
}
|
|
559
570
|
}
|
|
560
571
|
});
|
|
561
572
|
}
|
|
573
|
+
|
|
562
574
|
return bounds;
|
|
563
575
|
}
|
|
564
576
|
|
|
@@ -633,7 +645,7 @@ let globalFloatingCounter = 0;
|
|
|
633
645
|
/**
|
|
634
646
|
* Invokes the removeChildNow in a defer, to ensure the child is removed safely after the update & draw stack has completed. <br>
|
|
635
647
|
* if the given child implements a onDeactivateEvent() method, that method will be called once the child is removed from this container.
|
|
636
|
-
* @param {
|
|
648
|
+
* @param {RendRenderable|Sprite|Collectable|Trigger|Draggable|DropTarget|NineSliceSprite|ImageLayer|ColorLayer|Light2d|UIBaseElement|UISpriteElement|UITextButton|Text|BitmapTexterable} child
|
|
637
649
|
* @param {boolean} [keepalive=false] - true to prevent calling child.destroy()
|
|
638
650
|
*/
|
|
639
651
|
removeChild(child, keepalive) {
|
|
@@ -649,7 +661,7 @@ let globalFloatingCounter = 0;
|
|
|
649
661
|
* Removes (and optionally destroys) a child from the container.<br>
|
|
650
662
|
* (removal is immediate and unconditional)<br>
|
|
651
663
|
* Never use keepalive=true with objects from {@link pool}. Doing so will create a memory leak.
|
|
652
|
-
* @param {Renderable} child
|
|
664
|
+
* @param {Renderable|Entity|Sprite|Collectable|Trigger|Draggable|DropTarget|NineSliceSprite|ImageLayer|ColorLayer|Light2d|UIBaseElement|UISpriteElement|UITextButton|Text|BitmapText} child
|
|
653
665
|
* @param {boolean} [keepalive=False] - True to prevent calling child.destroy()
|
|
654
666
|
*/
|
|
655
667
|
removeChildNow(child, keepalive) {
|
|
@@ -682,16 +694,14 @@ let globalFloatingCounter = 0;
|
|
|
682
694
|
child.ancestor = undefined;
|
|
683
695
|
}
|
|
684
696
|
|
|
685
|
-
// force repaint in case this is a static non-animated object
|
|
686
|
-
if (this.isAttachedToRoot() === true) {
|
|
687
|
-
this.isDirty = true;
|
|
688
|
-
}
|
|
689
|
-
|
|
690
697
|
// force bounds update if required
|
|
691
698
|
if (this.enableChildBoundsUpdate === true) {
|
|
692
699
|
this.updateBounds();
|
|
693
700
|
}
|
|
694
701
|
|
|
702
|
+
// mark the container for repaint
|
|
703
|
+
this.isDirty = true;
|
|
704
|
+
|
|
695
705
|
// triggered callback if defined
|
|
696
706
|
this.onChildChange.call(this, childIndex);
|
|
697
707
|
}
|
|
@@ -714,7 +724,7 @@ let globalFloatingCounter = 0;
|
|
|
714
724
|
|
|
715
725
|
/**
|
|
716
726
|
* Move the child in the group one step forward (z depth).
|
|
717
|
-
* @param {Renderable} child
|
|
727
|
+
* @param {Renderable|Entity|Sprite|Collectable|Trigger|Draggable|DropTarget|NineSliceSprite|ImageLayer|ColorLayer|Light2d|UIBaseElement|UISpriteElement|UITextButton|Text|BitmapText} child
|
|
718
728
|
*/
|
|
719
729
|
moveUp(child) {
|
|
720
730
|
let childIndex = this.getChildIndex(child);
|
|
@@ -728,7 +738,7 @@ let globalFloatingCounter = 0;
|
|
|
728
738
|
|
|
729
739
|
/**
|
|
730
740
|
* Move the child in the group one step backward (z depth).
|
|
731
|
-
* @param {Renderable} child
|
|
741
|
+
* @param {Renderable|Entity|Sprite|Collectable|Trigger|Draggable|DropTarget|NineSliceSprite|ImageLayer|ColorLayer|Light2d|UIBaseElement|UISpriteElement|UITextButton|Text|BitmapText} child
|
|
732
742
|
*/
|
|
733
743
|
moveDown(child) {
|
|
734
744
|
let childIndex = this.getChildIndex(child);
|
|
@@ -742,7 +752,7 @@ let globalFloatingCounter = 0;
|
|
|
742
752
|
|
|
743
753
|
/**
|
|
744
754
|
* Move the specified child to the top(z depth).
|
|
745
|
-
* @param {Renderable} child
|
|
755
|
+
* @param {Renderable|Entity|Sprite|Collectable|Trigger|Draggable|DropTarget|NineSliceSprite|ImageLayer|ColorLayer|Light2d|UIBaseElement|UISpriteElement|UITextButton|Text|BitmapText} child
|
|
746
756
|
*/
|
|
747
757
|
moveToTop(child) {
|
|
748
758
|
let childIndex = this.getChildIndex(child);
|
|
@@ -759,7 +769,7 @@ let globalFloatingCounter = 0;
|
|
|
759
769
|
|
|
760
770
|
/**
|
|
761
771
|
* Move the specified child the bottom (z depth).
|
|
762
|
-
* @param {Renderable} child
|
|
772
|
+
* @param {Renderable|Entity|Sprite|Collectable|Trigger|Draggable|DropTarget|NineSliceSprite|ImageLayer|ColorLayer|Light2d|UIBaseElement|UISpriteElement|UITextButton|Text|BitmapText} child
|
|
763
773
|
*/
|
|
764
774
|
moveToBottom(child) {
|
|
765
775
|
let childIndex = this.getChildIndex(child);
|