melonjs 10.7.1 → 10.10.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.
- package/LICENSE.md +1 -1
- package/README.md +29 -23
- package/dist/melonjs.js +2220 -1070
- package/dist/melonjs.min.js +4 -4
- package/dist/melonjs.module.d.ts +1395 -485
- package/dist/melonjs.module.js +2244 -1131
- package/package.json +17 -14
- package/src/camera/camera2d.js +1 -1
- package/src/entity/entity.js +6 -7
- package/src/game.js +2 -2
- package/src/geometries/ellipse.js +20 -21
- package/src/geometries/line.js +7 -7
- package/src/geometries/path2d.js +319 -0
- package/src/geometries/poly.js +27 -27
- package/src/geometries/rectangle.js +19 -19
- package/src/geometries/roundrect.js +164 -0
- package/src/index.js +12 -2
- package/src/input/gamepad.js +2 -2
- package/src/input/pointerevent.js +1 -1
- package/src/lang/deprecated.js +8 -6
- package/src/level/tiled/TMXLayer.js +1 -1
- package/src/level/tiled/TMXObject.js +9 -12
- package/src/level/tiled/TMXTileMap.js +23 -4
- package/src/level/tiled/TMXUtils.js +1 -1
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
- package/src/loader/loader.js +4 -4
- package/src/loader/loadingscreen.js +17 -6
- package/src/math/color.js +6 -5
- package/src/math/matrix2.js +1 -1
- package/src/math/matrix3.js +1 -1
- package/src/math/observable_vector2.js +1 -1
- package/src/math/observable_vector3.js +1 -1
- package/src/math/vector2.js +1 -1
- package/src/math/vector3.js +1 -1
- package/src/particles/emitter.js +34 -26
- package/src/particles/particle.js +3 -2
- package/src/physics/body.js +67 -51
- package/src/physics/bounds.js +8 -9
- package/src/physics/world.js +1 -1
- package/src/polyfill/index.js +1 -0
- package/src/polyfill/roundrect.js +235 -0
- package/src/renderable/GUI.js +5 -5
- package/src/renderable/collectable.js +9 -2
- package/src/renderable/colorlayer.js +1 -1
- package/src/renderable/container.js +27 -27
- package/src/renderable/imagelayer.js +3 -3
- package/src/renderable/light2d.js +115 -0
- package/src/renderable/renderable.js +23 -22
- package/src/renderable/sprite.js +15 -16
- package/src/renderable/trigger.js +10 -4
- package/src/state/stage.js +73 -3
- package/src/state/state.js +1 -1
- package/src/system/device.js +10 -8
- package/src/system/pooling.js +156 -149
- package/src/text/bitmaptext.js +1 -1
- package/src/text/text.js +14 -18
- package/src/utils/utils.js +2 -2
- package/src/video/canvas/canvas_renderer.js +144 -81
- package/src/video/renderer.js +64 -37
- package/src/video/{texture.js → texture/atlas.js} +8 -8
- package/src/video/{texture_cache.js → texture/cache.js} +4 -4
- package/src/video/texture/canvas_texture.js +87 -0
- package/src/video/webgl/glshader.js +29 -193
- package/src/video/webgl/utils/attributes.js +16 -0
- package/src/video/webgl/utils/precision.js +11 -0
- package/src/video/webgl/utils/program.js +58 -0
- package/src/video/webgl/utils/string.js +16 -0
- package/src/video/webgl/utils/uniforms.js +87 -0
- package/src/video/webgl/webgl_compositor.js +1 -14
- package/src/video/webgl/webgl_renderer.js +191 -231
package/src/physics/bounds.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import pool from "./../system/pooling.js";
|
|
1
2
|
import Vector2d from "./../math/vector2.js";
|
|
2
|
-
import Polygon from "./../geometries/poly.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @classdesc
|
|
@@ -10,6 +10,8 @@ class Bounds {
|
|
|
10
10
|
* @param {Vector2d[]} [vertices] an array of me.Vector2d points
|
|
11
11
|
*/
|
|
12
12
|
constructor(vertices) {
|
|
13
|
+
// @ignore
|
|
14
|
+
this._center = new Vector2d();
|
|
13
15
|
this.onResetEvent(vertices);
|
|
14
16
|
}
|
|
15
17
|
|
|
@@ -26,9 +28,6 @@ class Bounds {
|
|
|
26
28
|
if (typeof vertices !== "undefined") {
|
|
27
29
|
this.update(vertices);
|
|
28
30
|
}
|
|
29
|
-
|
|
30
|
-
// @ignore
|
|
31
|
-
this._center = new Vector2d();
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
/**
|
|
@@ -450,11 +449,11 @@ class Bounds {
|
|
|
450
449
|
* @returns {Polygon} a new Polygon that represents this bounds.
|
|
451
450
|
*/
|
|
452
451
|
toPolygon () {
|
|
453
|
-
return
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
452
|
+
return pool.pull("Polygon", this.x, this.y, [
|
|
453
|
+
pool.pull("Vector2d", 0, 0),
|
|
454
|
+
pool.pull("Vector2d", this.width, 0),
|
|
455
|
+
pool.pull("Vector2d", this.width, this.height),
|
|
456
|
+
pool.pull("Vector2d", 0, this.height)
|
|
458
457
|
]);
|
|
459
458
|
}
|
|
460
459
|
|
package/src/physics/world.js
CHANGED
package/src/polyfill/index.js
CHANGED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* based on https://www.npmjs.com/package/canvas-roundrect-polyfill
|
|
3
|
+
* @version 0.0.1
|
|
4
|
+
*/
|
|
5
|
+
(() => {
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
|
|
9
|
+
/** @ignore */
|
|
10
|
+
function roundRect(x, y, w, h, radii) {
|
|
11
|
+
|
|
12
|
+
if (!([x, y, w, h].every((input) => Number.isFinite(input)))) {
|
|
13
|
+
|
|
14
|
+
return;
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
radii = parseRadiiArgument(radii);
|
|
19
|
+
|
|
20
|
+
let upperLeft, upperRight, lowerRight, lowerLeft;
|
|
21
|
+
|
|
22
|
+
if (radii.length === 4) {
|
|
23
|
+
|
|
24
|
+
upperLeft = toCornerPoint(radii[0]);
|
|
25
|
+
upperRight = toCornerPoint(radii[1]);
|
|
26
|
+
lowerRight = toCornerPoint(radii[2]);
|
|
27
|
+
lowerLeft = toCornerPoint(radii[3]);
|
|
28
|
+
|
|
29
|
+
} else if (radii.length === 3) {
|
|
30
|
+
|
|
31
|
+
upperLeft = toCornerPoint(radii[0]);
|
|
32
|
+
upperRight = toCornerPoint(radii[1]);
|
|
33
|
+
lowerLeft = toCornerPoint(radii[1]);
|
|
34
|
+
lowerRight = toCornerPoint(radii[2]);
|
|
35
|
+
|
|
36
|
+
} else if (radii.length === 2) {
|
|
37
|
+
|
|
38
|
+
upperLeft = toCornerPoint(radii[0]);
|
|
39
|
+
lowerRight = toCornerPoint(radii[0]);
|
|
40
|
+
upperRight = toCornerPoint(radii[1]);
|
|
41
|
+
lowerLeft = toCornerPoint(radii[1]);
|
|
42
|
+
|
|
43
|
+
} else if (radii.length === 1) {
|
|
44
|
+
|
|
45
|
+
upperLeft = toCornerPoint(radii[0]);
|
|
46
|
+
upperRight = toCornerPoint(radii[0]);
|
|
47
|
+
lowerRight = toCornerPoint(radii[0]);
|
|
48
|
+
lowerLeft = toCornerPoint(radii[0]);
|
|
49
|
+
|
|
50
|
+
} else {
|
|
51
|
+
|
|
52
|
+
throw new Error(radii.length + " is not a valid size for radii sequence.");
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const corners = [upperLeft, upperRight, lowerRight, lowerLeft];
|
|
57
|
+
const negativeCorner = corners.find(({x, y}) => x < 0 || y < 0);
|
|
58
|
+
//const negativeValue = negativeCorner?.x < 0 ? negativeCorner.x : negativeCorner?.y
|
|
59
|
+
|
|
60
|
+
if (corners.some(({x, y}) => !Number.isFinite(x) || !Number.isFinite(y))) {
|
|
61
|
+
|
|
62
|
+
return;
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (negativeCorner) {
|
|
67
|
+
|
|
68
|
+
throw new Error("Radius value " + negativeCorner + " is negative.");
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
fixOverlappingCorners(corners);
|
|
73
|
+
|
|
74
|
+
if (w < 0 && h < 0) {
|
|
75
|
+
|
|
76
|
+
this.moveTo(x - upperLeft.x, y);
|
|
77
|
+
this.ellipse(x + w + upperRight.x, y - upperRight.y, upperRight.x, upperRight.y, 0, -Math.PI * 1.5, -Math.PI);
|
|
78
|
+
this.ellipse(x + w + lowerRight.x, y + h + lowerRight.y, lowerRight.x, lowerRight.y, 0, -Math.PI, -Math.PI / 2);
|
|
79
|
+
this.ellipse(x - lowerLeft.x, y + h + lowerLeft.y, lowerLeft.x, lowerLeft.y, 0, -Math.PI / 2, 0);
|
|
80
|
+
this.ellipse(x - upperLeft.x, y - upperLeft.y, upperLeft.x, upperLeft.y, 0, 0, -Math.PI / 2);
|
|
81
|
+
|
|
82
|
+
} else if (w < 0) {
|
|
83
|
+
|
|
84
|
+
this.moveTo(x - upperLeft.x, y);
|
|
85
|
+
this.ellipse(x + w + upperRight.x, y + upperRight.y, upperRight.x, upperRight.y, 0, -Math.PI / 2, -Math.PI, 1);
|
|
86
|
+
this.ellipse(x + w + lowerRight.x, y + h - lowerRight.y, lowerRight.x, lowerRight.y, 0, -Math.PI, -Math.PI * 1.5, 1);
|
|
87
|
+
this.ellipse(x - lowerLeft.x, y + h - lowerLeft.y, lowerLeft.x, lowerLeft.y, 0, Math.PI / 2, 0, 1);
|
|
88
|
+
this.ellipse(x - upperLeft.x, y + upperLeft.y, upperLeft.x, upperLeft.y, 0, 0, -Math.PI / 2, 1);
|
|
89
|
+
|
|
90
|
+
} else if (h < 0) {
|
|
91
|
+
|
|
92
|
+
this.moveTo(x + upperLeft.x, y);
|
|
93
|
+
this.ellipse(x + w - upperRight.x, y - upperRight.y, upperRight.x, upperRight.y, 0, Math.PI / 2, 0, 1);
|
|
94
|
+
this.ellipse(x + w - lowerRight.x, y + h + lowerRight.y, lowerRight.x, lowerRight.y, 0, 0, -Math.PI / 2, 1);
|
|
95
|
+
this.ellipse(x + lowerLeft.x, y + h + lowerLeft.y, lowerLeft.x, lowerLeft.y, 0, -Math.PI / 2, -Math.PI, 1);
|
|
96
|
+
this.ellipse(x + upperLeft.x, y - upperLeft.y, upperLeft.x, upperLeft.y, 0, -Math.PI, -Math.PI * 1.5, 1);
|
|
97
|
+
|
|
98
|
+
} else {
|
|
99
|
+
|
|
100
|
+
this.moveTo(x + upperLeft.x, y);
|
|
101
|
+
this.ellipse(x + w - upperRight.x, y + upperRight.y, upperRight.x, upperRight.y, 0, -Math.PI / 2, 0);
|
|
102
|
+
this.ellipse(x + w - lowerRight.x, y + h - lowerRight.y, lowerRight.x, lowerRight.y, 0, 0, Math.PI / 2);
|
|
103
|
+
this.ellipse(x + lowerLeft.x, y + h - lowerLeft.y, lowerLeft.x, lowerLeft.y, 0, Math.PI / 2, Math.PI);
|
|
104
|
+
this.ellipse(x + upperLeft.x, y + upperLeft.y, upperLeft.x, upperLeft.y, 0, Math.PI, Math.PI * 1.5);
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
this.closePath();
|
|
109
|
+
this.moveTo(x, y);
|
|
110
|
+
|
|
111
|
+
/** @ignore */
|
|
112
|
+
function toDOMPointInit(value) {
|
|
113
|
+
|
|
114
|
+
const {x, y, z, w} = value;
|
|
115
|
+
return {x, y, z, w};
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** @ignore */
|
|
120
|
+
function parseRadiiArgument(value) {
|
|
121
|
+
|
|
122
|
+
// https://webidl.spec.whatwg.org/#es-union
|
|
123
|
+
// with 'optional (unrestricted double or DOMPointInit
|
|
124
|
+
// or sequence<(unrestricted double or DOMPointInit)>) radii = 0'
|
|
125
|
+
const type = typeof value;
|
|
126
|
+
|
|
127
|
+
if (type === "undefined" || value === null) {
|
|
128
|
+
|
|
129
|
+
return [0];
|
|
130
|
+
|
|
131
|
+
}
|
|
132
|
+
if (type === "function") {
|
|
133
|
+
|
|
134
|
+
return [NaN];
|
|
135
|
+
|
|
136
|
+
}
|
|
137
|
+
if (type === "object") {
|
|
138
|
+
|
|
139
|
+
if (typeof value[Symbol.iterator] === "function") {
|
|
140
|
+
|
|
141
|
+
return [...value].map((elem) => {
|
|
142
|
+
// https://webidl.spec.whatwg.org/#es-union
|
|
143
|
+
// with '(unrestricted double or DOMPointInit)'
|
|
144
|
+
const elemType = typeof elem;
|
|
145
|
+
if (elemType === "undefined" || elem === null) {
|
|
146
|
+
return 0;
|
|
147
|
+
}
|
|
148
|
+
if (elemType === "function") {
|
|
149
|
+
return NaN;
|
|
150
|
+
}
|
|
151
|
+
if (elemType === "object") {
|
|
152
|
+
return toDOMPointInit(elem);
|
|
153
|
+
}
|
|
154
|
+
return toUnrestrictedNumber(elem);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return [toDOMPointInit(value)];
|
|
160
|
+
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return [toUnrestrictedNumber(value)];
|
|
164
|
+
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** @ignore */
|
|
168
|
+
function toUnrestrictedNumber(value) {
|
|
169
|
+
|
|
170
|
+
return +value;
|
|
171
|
+
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** @ignore */
|
|
175
|
+
function toCornerPoint(value) {
|
|
176
|
+
|
|
177
|
+
const asNumber = toUnrestrictedNumber(value);
|
|
178
|
+
if (Number.isFinite(asNumber)) {
|
|
179
|
+
|
|
180
|
+
return {
|
|
181
|
+
x: asNumber,
|
|
182
|
+
y: asNumber
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
if (Object(value) === value) {
|
|
187
|
+
|
|
188
|
+
return {
|
|
189
|
+
x: toUnrestrictedNumber(value.x || 0),
|
|
190
|
+
y: toUnrestrictedNumber(value.y || 0)
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return {
|
|
196
|
+
x: NaN,
|
|
197
|
+
y: NaN
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** @ignore */
|
|
203
|
+
function fixOverlappingCorners(corners) {
|
|
204
|
+
const [upperLeft, upperRight, lowerRight, lowerLeft] = corners;
|
|
205
|
+
const factors = [
|
|
206
|
+
Math.abs(w) / (upperLeft.x + upperRight.x),
|
|
207
|
+
Math.abs(h) / (upperRight.y + lowerRight.y),
|
|
208
|
+
Math.abs(w) / (lowerRight.x + lowerLeft.x),
|
|
209
|
+
Math.abs(h) / (upperLeft.y + lowerLeft.y)
|
|
210
|
+
];
|
|
211
|
+
const minFactor = Math.min(...factors);
|
|
212
|
+
if (minFactor <= 1) {
|
|
213
|
+
corners.forEach((radii) => {
|
|
214
|
+
radii.x *= minFactor;
|
|
215
|
+
radii.y *= minFactor;
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (typeof Path2D.prototype.roundRect === "undefined") {
|
|
222
|
+
Path2D.prototype.roundRect = roundRect;
|
|
223
|
+
}
|
|
224
|
+
if (globalThis.CanvasRenderingContext2D) {
|
|
225
|
+
if (typeof globalThis.CanvasRenderingContext2D.prototype.roundRect === "undefined") {
|
|
226
|
+
globalThis.CanvasRenderingContext2D.prototype.roundRect = roundRect;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (globalThis.OffscreenCanvasRenderingContext2D) {
|
|
230
|
+
if (typeof globalThis.OffscreenCanvasRenderingContext2D.prototype.roundRect === "undefined") {
|
|
231
|
+
globalThis.OffscreenCanvasRenderingContext2D.prototype.roundRect = roundRect;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
})();
|
package/src/renderable/GUI.js
CHANGED
|
@@ -116,7 +116,7 @@ class GUI_Object extends Sprite {
|
|
|
116
116
|
/**
|
|
117
117
|
* function called when the object is pressed (to be extended)
|
|
118
118
|
* @name onClick
|
|
119
|
-
* @memberof GUI_Object
|
|
119
|
+
* @memberof GUI_Object
|
|
120
120
|
* @public
|
|
121
121
|
* @function
|
|
122
122
|
* @param {Pointer} event the event object
|
|
@@ -139,7 +139,7 @@ class GUI_Object extends Sprite {
|
|
|
139
139
|
/**
|
|
140
140
|
* function called when the pointer is over the object
|
|
141
141
|
* @name onOver
|
|
142
|
-
* @memberof GUI_Object
|
|
142
|
+
* @memberof GUI_Object
|
|
143
143
|
* @public
|
|
144
144
|
* @function
|
|
145
145
|
* @param {Pointer} event the event object
|
|
@@ -160,7 +160,7 @@ class GUI_Object extends Sprite {
|
|
|
160
160
|
/**
|
|
161
161
|
* function called when the pointer is leaving the object area
|
|
162
162
|
* @name onOut
|
|
163
|
-
* @memberof GUI_Object
|
|
163
|
+
* @memberof GUI_Object
|
|
164
164
|
* @public
|
|
165
165
|
* @function
|
|
166
166
|
* @param {Pointer} event the event object
|
|
@@ -185,7 +185,7 @@ class GUI_Object extends Sprite {
|
|
|
185
185
|
/**
|
|
186
186
|
* function called when the object is pressed and released (to be extended)
|
|
187
187
|
* @name onRelease
|
|
188
|
-
* @memberof GUI_Object
|
|
188
|
+
* @memberof GUI_Object
|
|
189
189
|
* @public
|
|
190
190
|
* @function
|
|
191
191
|
* @returns {boolean} return false if we need to stop propagating the event
|
|
@@ -210,7 +210,7 @@ class GUI_Object extends Sprite {
|
|
|
210
210
|
* function called when the object is pressed and held<br>
|
|
211
211
|
* to be extended <br>
|
|
212
212
|
* @name onHold
|
|
213
|
-
* @memberof GUI_Object
|
|
213
|
+
* @memberof GUI_Object
|
|
214
214
|
* @public
|
|
215
215
|
* @function
|
|
216
216
|
*/
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import Sprite from "./sprite.js";
|
|
2
2
|
import Body from "./../physics/body.js";
|
|
3
|
-
import Rect from "./../geometries/rectangle.js";
|
|
4
3
|
import collision from "./../physics/collision.js";
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -24,7 +23,15 @@ class Collectable extends Sprite {
|
|
|
24
23
|
this.id = settings.id;
|
|
25
24
|
|
|
26
25
|
// add and configure the physic body
|
|
27
|
-
|
|
26
|
+
var shape = settings.shapes;
|
|
27
|
+
if (typeof shape === "undefined") {
|
|
28
|
+
shape = pool.pull("Polygon", 0, 0, [
|
|
29
|
+
pool.pull("Vector2d", 0, 0),
|
|
30
|
+
pool.pull("Vector2d", this.width, 0),
|
|
31
|
+
pool.pull("Vector2d", this.width, this.height)
|
|
32
|
+
]);
|
|
33
|
+
}
|
|
34
|
+
this.body = new Body(this, shape);
|
|
28
35
|
this.body.collisionType = collision.types.COLLECTABLE_OBJECT;
|
|
29
36
|
// by default only collides with PLAYER_OBJECT
|
|
30
37
|
this.body.setCollisionMask(collision.types.PLAYER_OBJECT);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import utils from "./../utils/utils.js";
|
|
2
2
|
import * as game from "./../game.js";
|
|
3
3
|
import * as event from "./../system/event.js";
|
|
4
|
-
import
|
|
4
|
+
import pool from "./../system/pooling.js";
|
|
5
5
|
import state from "./../state/state.js";
|
|
6
6
|
import Renderable from "./renderable.js";
|
|
7
7
|
import Body from "./../physics/body.js";
|
|
@@ -18,7 +18,7 @@ var globalFloatingCounter = 0;
|
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* @classdesc
|
|
21
|
-
*
|
|
21
|
+
* Container represents a collection of child objects
|
|
22
22
|
* @augments Renderable
|
|
23
23
|
*/
|
|
24
24
|
class Container extends Renderable {
|
|
@@ -192,7 +192,7 @@ class Container extends Renderable {
|
|
|
192
192
|
* orginal container. Then when the me.game.world.reset() is called the renderable
|
|
193
193
|
* will not be in any container.
|
|
194
194
|
* @name addChild
|
|
195
|
-
* @memberof Container
|
|
195
|
+
* @memberof Container
|
|
196
196
|
* @function
|
|
197
197
|
* @param {Renderable} child
|
|
198
198
|
* @param {number} [z] forces the z index of the child to the specified value
|
|
@@ -256,7 +256,7 @@ class Container extends Renderable {
|
|
|
256
256
|
* Add a child to the container at the specified index<br>
|
|
257
257
|
* (the list won't be sorted after insertion)
|
|
258
258
|
* @name addChildAt
|
|
259
|
-
* @memberof Container
|
|
259
|
+
* @memberof Container
|
|
260
260
|
* @function
|
|
261
261
|
* @param {Renderable} child
|
|
262
262
|
* @param {number} index
|
|
@@ -315,7 +315,7 @@ class Container extends Renderable {
|
|
|
315
315
|
* - The index of element in the array. <br>
|
|
316
316
|
* - The array forEach() was called upon. <br>
|
|
317
317
|
* @name forEach
|
|
318
|
-
* @memberof Container
|
|
318
|
+
* @memberof Container
|
|
319
319
|
* @function
|
|
320
320
|
* @param {Function} callback fnction to execute on each element
|
|
321
321
|
* @param {object} [thisArg] value to use as this(i.e reference Object) when executing callback.
|
|
@@ -352,7 +352,7 @@ class Container extends Renderable {
|
|
|
352
352
|
/**
|
|
353
353
|
* Swaps the position (z-index) of 2 children
|
|
354
354
|
* @name swapChildren
|
|
355
|
-
* @memberof Container
|
|
355
|
+
* @memberof Container
|
|
356
356
|
* @function
|
|
357
357
|
* @param {Renderable} child
|
|
358
358
|
* @param {Renderable} child2
|
|
@@ -380,7 +380,7 @@ class Container extends Renderable {
|
|
|
380
380
|
/**
|
|
381
381
|
* Returns the Child at the specified index
|
|
382
382
|
* @name getChildAt
|
|
383
|
-
* @memberof Container
|
|
383
|
+
* @memberof Container
|
|
384
384
|
* @function
|
|
385
385
|
* @param {number} index
|
|
386
386
|
* @returns {Renderable} the child at the specified index
|
|
@@ -397,7 +397,7 @@ class Container extends Renderable {
|
|
|
397
397
|
/**
|
|
398
398
|
* Returns the index of the given Child
|
|
399
399
|
* @name getChildIndex
|
|
400
|
-
* @memberof Container
|
|
400
|
+
* @memberof Container
|
|
401
401
|
* @function
|
|
402
402
|
* @param {Renderable} child
|
|
403
403
|
* @returns {number} index
|
|
@@ -425,7 +425,7 @@ class Container extends Renderable {
|
|
|
425
425
|
/**
|
|
426
426
|
* Returns true if contains the specified Child
|
|
427
427
|
* @name hasChild
|
|
428
|
-
* @memberof Container
|
|
428
|
+
* @memberof Container
|
|
429
429
|
* @function
|
|
430
430
|
* @param {Renderable} child
|
|
431
431
|
* @returns {boolean}
|
|
@@ -439,7 +439,7 @@ class Container extends Renderable {
|
|
|
439
439
|
* note : avoid calling this function every frame since
|
|
440
440
|
* it parses the whole object tree each time
|
|
441
441
|
* @name getChildByProp
|
|
442
|
-
* @memberof Container
|
|
442
|
+
* @memberof Container
|
|
443
443
|
* @public
|
|
444
444
|
* @function
|
|
445
445
|
* @param {string} prop Property name
|
|
@@ -491,7 +491,7 @@ class Container extends Renderable {
|
|
|
491
491
|
/**
|
|
492
492
|
* returns the list of childs with the specified class type
|
|
493
493
|
* @name getChildByType
|
|
494
|
-
* @memberof Container
|
|
494
|
+
* @memberof Container
|
|
495
495
|
* @public
|
|
496
496
|
* @function
|
|
497
497
|
* @param {object} classType
|
|
@@ -518,7 +518,7 @@ class Container extends Renderable {
|
|
|
518
518
|
* note : avoid calling this function every frame since
|
|
519
519
|
* it parses the whole object list each time
|
|
520
520
|
* @name getChildByName
|
|
521
|
-
* @memberof Container
|
|
521
|
+
* @memberof Container
|
|
522
522
|
* @public
|
|
523
523
|
* @function
|
|
524
524
|
* @param {string|RegExp|number|boolean} name child name
|
|
@@ -533,7 +533,7 @@ class Container extends Renderable {
|
|
|
533
533
|
* note : avoid calling this function every frame since
|
|
534
534
|
* it parses the whole object list each time
|
|
535
535
|
* @name getChildByGUID
|
|
536
|
-
* @memberof Container
|
|
536
|
+
* @memberof Container
|
|
537
537
|
* @public
|
|
538
538
|
* @function
|
|
539
539
|
* @param {string|RegExp|number|boolean} guid child GUID
|
|
@@ -547,7 +547,7 @@ class Container extends Renderable {
|
|
|
547
547
|
/**
|
|
548
548
|
* return all child in this container
|
|
549
549
|
* @name getChildren
|
|
550
|
-
* @memberof Container
|
|
550
|
+
* @memberof Container
|
|
551
551
|
* @public
|
|
552
552
|
* @function
|
|
553
553
|
* @returns {Renderable[]} an array of renderable object
|
|
@@ -563,7 +563,7 @@ class Container extends Renderable {
|
|
|
563
563
|
* update the bounding box for this shape.
|
|
564
564
|
* @ignore
|
|
565
565
|
* @name updateBounds
|
|
566
|
-
* @memberof Renderable
|
|
566
|
+
* @memberof Renderable
|
|
567
567
|
* @function
|
|
568
568
|
* @returns {Bounds} this shape bounding box Rectangle object
|
|
569
569
|
*/
|
|
@@ -592,7 +592,7 @@ class Container extends Renderable {
|
|
|
592
592
|
* Checks if this container is root or if it's attached to the root container.
|
|
593
593
|
* @private
|
|
594
594
|
* @name isAttachedToRoot
|
|
595
|
-
* @memberof Container
|
|
595
|
+
* @memberof Container
|
|
596
596
|
* @function
|
|
597
597
|
* @returns {boolean}
|
|
598
598
|
*/
|
|
@@ -615,7 +615,7 @@ class Container extends Renderable {
|
|
|
615
615
|
* update the cointainer's bounding rect (private)
|
|
616
616
|
* @ignore
|
|
617
617
|
* @name updateBoundsPos
|
|
618
|
-
* @memberof Container
|
|
618
|
+
* @memberof Container
|
|
619
619
|
* @function
|
|
620
620
|
*/
|
|
621
621
|
updateBoundsPos(newX, newY) {
|
|
@@ -650,7 +650,7 @@ class Container extends Renderable {
|
|
|
650
650
|
/**
|
|
651
651
|
* Invokes the removeChildNow in a defer, to ensure the child is removed safely after the update & draw stack has completed
|
|
652
652
|
* @name removeChild
|
|
653
|
-
* @memberof Container
|
|
653
|
+
* @memberof Container
|
|
654
654
|
* @public
|
|
655
655
|
* @function
|
|
656
656
|
* @param {Renderable} child
|
|
@@ -670,7 +670,7 @@ class Container extends Renderable {
|
|
|
670
670
|
* (removal is immediate and unconditional)<br>
|
|
671
671
|
* Never use keepalive=true with objects from {@link pool}. Doing so will create a memory leak.
|
|
672
672
|
* @name removeChildNow
|
|
673
|
-
* @memberof Container
|
|
673
|
+
* @memberof Container
|
|
674
674
|
* @function
|
|
675
675
|
* @param {Renderable} child
|
|
676
676
|
* @param {boolean} [keepalive=False] True to prevent calling child.destroy()
|
|
@@ -723,7 +723,7 @@ class Container extends Renderable {
|
|
|
723
723
|
/**
|
|
724
724
|
* Automatically set the specified property of all childs to the given value
|
|
725
725
|
* @name setChildsProperty
|
|
726
|
-
* @memberof Container
|
|
726
|
+
* @memberof Container
|
|
727
727
|
* @function
|
|
728
728
|
* @param {string} prop property name
|
|
729
729
|
* @param {object} value property value
|
|
@@ -741,7 +741,7 @@ class Container extends Renderable {
|
|
|
741
741
|
/**
|
|
742
742
|
* Move the child in the group one step forward (z depth).
|
|
743
743
|
* @name moveUp
|
|
744
|
-
* @memberof Container
|
|
744
|
+
* @memberof Container
|
|
745
745
|
* @function
|
|
746
746
|
* @param {Renderable} child
|
|
747
747
|
*/
|
|
@@ -758,7 +758,7 @@ class Container extends Renderable {
|
|
|
758
758
|
/**
|
|
759
759
|
* Move the child in the group one step backward (z depth).
|
|
760
760
|
* @name moveDown
|
|
761
|
-
* @memberof Container
|
|
761
|
+
* @memberof Container
|
|
762
762
|
* @function
|
|
763
763
|
* @param {Renderable} child
|
|
764
764
|
*/
|
|
@@ -775,7 +775,7 @@ class Container extends Renderable {
|
|
|
775
775
|
/**
|
|
776
776
|
* Move the specified child to the top(z depth).
|
|
777
777
|
* @name moveToTop
|
|
778
|
-
* @memberof Container
|
|
778
|
+
* @memberof Container
|
|
779
779
|
* @function
|
|
780
780
|
* @param {Renderable} child
|
|
781
781
|
*/
|
|
@@ -795,7 +795,7 @@ class Container extends Renderable {
|
|
|
795
795
|
/**
|
|
796
796
|
* Move the specified child the bottom (z depth).
|
|
797
797
|
* @name moveToBottom
|
|
798
|
-
* @memberof Container
|
|
798
|
+
* @memberof Container
|
|
799
799
|
* @function
|
|
800
800
|
* @param {Renderable} child
|
|
801
801
|
*/
|
|
@@ -815,7 +815,7 @@ class Container extends Renderable {
|
|
|
815
815
|
/**
|
|
816
816
|
* Manually trigger the sort of all the childs in the container</p>
|
|
817
817
|
* @name sort
|
|
818
|
-
* @memberof Container
|
|
818
|
+
* @memberof Container
|
|
819
819
|
* @public
|
|
820
820
|
* @function
|
|
821
821
|
* @param {boolean} [recursive=false] recursively sort all containers if true
|
|
@@ -910,7 +910,7 @@ class Container extends Renderable {
|
|
|
910
910
|
* container update function. <br>
|
|
911
911
|
* automatically called by the game manager {@link game}
|
|
912
912
|
* @name update
|
|
913
|
-
* @memberof Container
|
|
913
|
+
* @memberof Container
|
|
914
914
|
* @function
|
|
915
915
|
* @protected
|
|
916
916
|
* @param {number} dt time since the last update in milliseconds.
|
|
@@ -963,7 +963,7 @@ class Container extends Renderable {
|
|
|
963
963
|
* draw the container. <br>
|
|
964
964
|
* automatically called by the game manager {@link game}
|
|
965
965
|
* @name draw
|
|
966
|
-
* @memberof Container
|
|
966
|
+
* @memberof Container
|
|
967
967
|
* @function
|
|
968
968
|
* @protected
|
|
969
969
|
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer object
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { renderer } from "./../video/video.js";
|
|
2
2
|
import * as event from "./../system/event.js";
|
|
3
|
-
import
|
|
3
|
+
import pool from "./../system/pooling.js";
|
|
4
4
|
import { viewport } from "./../game.js";
|
|
5
5
|
import Sprite from "./sprite.js";
|
|
6
6
|
import * as stringUtil from "./../utils/string.js";
|
|
@@ -159,7 +159,7 @@ class ImageLayer extends Sprite {
|
|
|
159
159
|
/**
|
|
160
160
|
* resize the Image Layer to match the given size
|
|
161
161
|
* @name resize
|
|
162
|
-
* @memberof ImageLayer
|
|
162
|
+
* @memberof ImageLayer
|
|
163
163
|
* @function
|
|
164
164
|
* @param {number} w new width
|
|
165
165
|
* @param {number} h new height
|
|
@@ -249,7 +249,7 @@ class ImageLayer extends Sprite {
|
|
|
249
249
|
* draw the ImageLayer. <br>
|
|
250
250
|
* automatically called by the game manager {@link game}
|
|
251
251
|
* @name draw
|
|
252
|
-
* @memberof ImageLayer
|
|
252
|
+
* @memberof ImageLayer
|
|
253
253
|
* @function
|
|
254
254
|
* @protected
|
|
255
255
|
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer object
|