melonjs 10.10.0 → 11.0.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/README.md +4 -3
- package/dist/melonjs.js +1071 -2102
- package/dist/melonjs.min.js +4 -4
- package/dist/melonjs.module.d.ts +600 -1351
- package/dist/melonjs.module.js +996 -2029
- package/package.json +16 -19
- package/src/audio/audio.js +0 -1
- package/src/camera/camera2d.js +1 -16
- package/src/entity/entity.js +6 -11
- package/src/geometries/ellipse.js +3 -12
- package/src/geometries/line.js +1 -4
- package/src/geometries/path2d.js +4 -14
- package/src/geometries/poly.js +6 -24
- package/src/geometries/rectangle.js +3 -15
- package/src/geometries/roundrect.js +2 -6
- package/src/index.js +0 -1
- package/src/input/gamepad.js +3 -14
- package/src/input/keyboard.js +1 -9
- package/src/input/pointer.js +0 -1
- package/src/input/pointerevent.js +14 -23
- package/src/lang/deprecated.js +4 -3
- package/src/level/level.js +0 -9
- package/src/level/tiled/TMXGroup.js +0 -4
- package/src/level/tiled/TMXLayer.js +0 -8
- package/src/level/tiled/TMXObject.js +0 -3
- package/src/level/tiled/TMXTile.js +4 -5
- package/src/level/tiled/TMXTileMap.js +1 -7
- package/src/level/tiled/TMXTileset.js +0 -5
- package/src/level/tiled/TMXTilesetGroup.js +1 -4
- package/src/level/tiled/TMXUtils.js +0 -3
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +2 -3
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +0 -1
- package/src/level/tiled/renderer/TMXRenderer.js +1 -7
- package/src/loader/loader.js +0 -11
- package/src/loader/loadingscreen.js +1 -1
- package/src/math/color.js +5 -26
- package/src/math/math.js +0 -10
- package/src/math/matrix2.js +12 -27
- package/src/math/matrix3.js +1 -22
- package/src/math/observable_vector2.js +0 -29
- package/src/math/observable_vector3.js +0 -29
- package/src/math/vector2.js +3 -40
- package/src/math/vector3.js +4 -41
- package/src/particles/emitter.js +1 -1
- package/src/physics/body.js +4 -5
- package/src/physics/bounds.js +5 -19
- package/src/physics/collision.js +1 -13
- package/src/physics/detector.js +6 -56
- package/src/physics/quadtree.js +0 -7
- package/src/physics/response.js +48 -0
- package/src/physics/sat.js +4 -4
- package/src/physics/world.js +0 -4
- package/src/plugin/plugin.js +0 -2
- package/src/polyfill/roundrect.js +4 -2
- package/src/renderable/GUI.js +6 -9
- package/src/renderable/collectable.js +1 -0
- package/src/renderable/colorlayer.js +9 -7
- package/src/renderable/container.js +12 -38
- package/src/renderable/dragndrop.js +1 -10
- package/src/renderable/imagelayer.js +6 -10
- package/src/renderable/light2d.js +48 -16
- package/src/renderable/renderable.js +6 -28
- package/src/renderable/sprite.js +4 -16
- package/src/renderable/trigger.js +10 -3
- package/src/state/stage.js +0 -4
- package/src/state/state.js +22 -23
- package/src/system/device.js +16 -119
- package/src/system/dom.js +69 -0
- package/src/system/event.js +22 -0
- package/src/system/pooling.js +20 -9
- package/src/system/save.js +9 -11
- package/src/system/timer.js +239 -218
- package/src/text/bitmaptextdata.js +1 -4
- package/src/text/glyph.js +2 -2
- package/src/text/text.js +13 -8
- package/src/text/textmetrics.js +0 -2
- package/src/tweens/easing.js +1 -1
- package/src/tweens/interpolation.js +2 -2
- package/src/tweens/tween.js +1 -13
- package/src/utils/agent.js +1 -3
- package/src/utils/array.js +0 -3
- package/src/utils/file.js +0 -2
- package/src/utils/function.js +0 -2
- package/src/utils/string.js +0 -6
- package/src/utils/utils.js +0 -3
- package/src/video/canvas/canvas_renderer.js +4 -39
- package/src/video/renderer.js +1 -23
- package/src/video/texture/atlas.js +2 -0
- package/src/video/texture/cache.js +0 -1
- package/src/video/texture/canvas_texture.js +16 -4
- package/src/video/video.js +3 -3
- package/src/video/webgl/glshader.js +0 -5
- package/src/video/webgl/utils/uniforms.js +3 -6
- package/src/video/webgl/webgl_compositor.js +0 -14
- package/src/video/webgl/webgl_renderer.js +0 -42
package/src/physics/quadtree.js
CHANGED
|
@@ -165,7 +165,6 @@ class QuadTree {
|
|
|
165
165
|
* Insert the given object container into the node.
|
|
166
166
|
* @name insertContainer
|
|
167
167
|
* @memberof QuadTree
|
|
168
|
-
* @function
|
|
169
168
|
* @param {Container} container group of objects to be added
|
|
170
169
|
*/
|
|
171
170
|
insertContainer(container) {
|
|
@@ -194,7 +193,6 @@ class QuadTree {
|
|
|
194
193
|
* objects to their corresponding subnodes.
|
|
195
194
|
* @name insert
|
|
196
195
|
* @memberof QuadTree
|
|
197
|
-
* @function
|
|
198
196
|
* @param {object} item object to be added
|
|
199
197
|
*/
|
|
200
198
|
insert(item) {
|
|
@@ -239,7 +237,6 @@ class QuadTree {
|
|
|
239
237
|
* Return all objects that could collide with the given object
|
|
240
238
|
* @name retrieve
|
|
241
239
|
* @memberof QuadTree
|
|
242
|
-
* @function
|
|
243
240
|
* @param {object} item object to be checked against
|
|
244
241
|
* @param {object} [fn] a sorting function for the returned array
|
|
245
242
|
* @returns {object[]} array with all detected objects
|
|
@@ -275,7 +272,6 @@ class QuadTree {
|
|
|
275
272
|
* (this function won't recalculate the impacted node)
|
|
276
273
|
* @name remove
|
|
277
274
|
* @memberof QuadTree
|
|
278
|
-
* @function
|
|
279
275
|
* @param {object} item object to be removed
|
|
280
276
|
* @returns {boolean} true if the item was found and removed.
|
|
281
277
|
*/
|
|
@@ -316,7 +312,6 @@ class QuadTree {
|
|
|
316
312
|
* return true if the node is prunable
|
|
317
313
|
* @name isPrunable
|
|
318
314
|
* @memberof QuadTree
|
|
319
|
-
* @function
|
|
320
315
|
* @returns {boolean} true if the node is prunable
|
|
321
316
|
*/
|
|
322
317
|
isPrunable() {
|
|
@@ -327,7 +322,6 @@ class QuadTree {
|
|
|
327
322
|
* return true if the node has any children
|
|
328
323
|
* @name hasChildren
|
|
329
324
|
* @memberof QuadTree
|
|
330
|
-
* @function
|
|
331
325
|
* @returns {boolean} true if the node has any children
|
|
332
326
|
*/
|
|
333
327
|
hasChildren() {
|
|
@@ -344,7 +338,6 @@ class QuadTree {
|
|
|
344
338
|
* clear the quadtree
|
|
345
339
|
* @name clear
|
|
346
340
|
* @memberof QuadTree
|
|
347
|
-
* @function
|
|
348
341
|
* @param {Bounds} [bounds=this.bounds] the bounds to be cleared
|
|
349
342
|
*/
|
|
350
343
|
clear(bounds) {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import Vector2d from "./../math/vector2.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @classdesc
|
|
5
|
+
* An object representing the result of an intersection.
|
|
6
|
+
* @property {Renderable} a The first object participating in the intersection
|
|
7
|
+
* @property {Renderable} b The second object participating in the intersection
|
|
8
|
+
* @property {number} overlap Magnitude of the overlap on the shortest colliding axis
|
|
9
|
+
* @property {Vector2d} overlapV The overlap vector (i.e. `overlapN.scale(overlap, overlap)`). If this vector is subtracted from the position of a, a and b will no longer be colliding
|
|
10
|
+
* @property {Vector2d} overlapN The shortest colliding axis (unit-vector)
|
|
11
|
+
* @property {boolean} aInB Whether the first object is entirely inside the second
|
|
12
|
+
* @property {boolean} bInA Whether the second object is entirely inside the first
|
|
13
|
+
* @property {number} indexShapeA The index of the colliding shape for the object a body
|
|
14
|
+
* @property {number} indexShapeB The index of the colliding shape for the object b body
|
|
15
|
+
* @name ResponseObject
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export default class ResponseObject {
|
|
19
|
+
constructor() {
|
|
20
|
+
this.a = null;
|
|
21
|
+
this.b = null;
|
|
22
|
+
this.overlapN = new Vector2d();
|
|
23
|
+
this.overlapV = new Vector2d();
|
|
24
|
+
this.aInB = true;
|
|
25
|
+
this.bInA = true;
|
|
26
|
+
this.indexShapeA = -1;
|
|
27
|
+
this.indexShapeB = -1;
|
|
28
|
+
this.overlap = Number.MAX_VALUE;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Set some values of the response back to their defaults. <br>
|
|
33
|
+
* Call this between tests if you are going to reuse a single <br>
|
|
34
|
+
* Response object for multiple intersection tests <br>
|
|
35
|
+
* (recommended as it will avoid allocating extra memory) <br>
|
|
36
|
+
* @name clear
|
|
37
|
+
* @public
|
|
38
|
+
* @returns {object} this object for chaining
|
|
39
|
+
*/
|
|
40
|
+
clear () {
|
|
41
|
+
this.aInB = true;
|
|
42
|
+
this.bInA = true;
|
|
43
|
+
this.overlap = Number.MAX_VALUE;
|
|
44
|
+
this.indexShapeA = -1;
|
|
45
|
+
this.indexShapeB = -1;
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
}
|
package/src/physics/sat.js
CHANGED
|
@@ -9,19 +9,19 @@ import Vector2d from "./../math/vector2.js";
|
|
|
9
9
|
* Constants for Vornoi regions
|
|
10
10
|
* @ignore
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
const LEFT_VORNOI_REGION = -1;
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Constants for Vornoi regions
|
|
16
16
|
* @ignore
|
|
17
17
|
*/
|
|
18
|
-
|
|
18
|
+
const MIDDLE_VORNOI_REGION = 0;
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Constants for Vornoi regions
|
|
22
22
|
* @ignore
|
|
23
23
|
*/
|
|
24
|
-
|
|
24
|
+
const RIGHT_VORNOI_REGION = 1;
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
/**
|
|
@@ -458,7 +458,7 @@ export function testPolygonEllipse(a, polyA, b, ellipseB, response) {
|
|
|
458
458
|
*/
|
|
459
459
|
export function testEllipsePolygon(a, ellipseA, b, polyB, response) {
|
|
460
460
|
// Test the polygon against the circle.
|
|
461
|
-
var result =
|
|
461
|
+
var result = testPolygonEllipse(b, polyB, a, ellipseA, response);
|
|
462
462
|
if (result && response) {
|
|
463
463
|
// Swap A and B in the response.
|
|
464
464
|
var resa = response.a;
|
package/src/physics/world.js
CHANGED
|
@@ -96,7 +96,6 @@ class World extends Container {
|
|
|
96
96
|
* reset the game world
|
|
97
97
|
* @name reset
|
|
98
98
|
* @memberof World
|
|
99
|
-
* @function
|
|
100
99
|
*/
|
|
101
100
|
reset() {
|
|
102
101
|
// clear the quadtree
|
|
@@ -118,7 +117,6 @@ class World extends Container {
|
|
|
118
117
|
* @name addBody
|
|
119
118
|
* @memberof World
|
|
120
119
|
* @see Container.addChild
|
|
121
|
-
* @function
|
|
122
120
|
* @param {Body} body
|
|
123
121
|
* @returns {World} this game world
|
|
124
122
|
*/
|
|
@@ -133,7 +131,6 @@ class World extends Container {
|
|
|
133
131
|
* @name removeBody
|
|
134
132
|
* @memberof World
|
|
135
133
|
* @see Container.removeChild
|
|
136
|
-
* @function
|
|
137
134
|
* @param {Body} body
|
|
138
135
|
* @returns {World} this game world
|
|
139
136
|
*/
|
|
@@ -147,7 +144,6 @@ class World extends Container {
|
|
|
147
144
|
* update the game world
|
|
148
145
|
* @name reset
|
|
149
146
|
* @memberof World
|
|
150
|
-
* @function
|
|
151
147
|
* @param {number} dt the time passed since the last frame update
|
|
152
148
|
* @returns {boolean} true if the word is dirty
|
|
153
149
|
*/
|
package/src/plugin/plugin.js
CHANGED
|
@@ -44,7 +44,6 @@ export var plugin = {
|
|
|
44
44
|
* @name patch
|
|
45
45
|
* @memberof plugin
|
|
46
46
|
* @public
|
|
47
|
-
* @function
|
|
48
47
|
* @param {object} proto target object
|
|
49
48
|
* @param {string} name target function
|
|
50
49
|
* @param {Function} fn replacement function
|
|
@@ -90,7 +89,6 @@ export var plugin = {
|
|
|
90
89
|
* @memberof plugin
|
|
91
90
|
* @see Base
|
|
92
91
|
* @public
|
|
93
|
-
* @function
|
|
94
92
|
* @param {plugin.Base} pluginObj Plugin object to instantiate and register
|
|
95
93
|
* @param {string} name
|
|
96
94
|
* @param {object} [...arguments] all extra parameters will be passed to the plugin constructor
|
|
@@ -218,8 +218,10 @@
|
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
if (
|
|
222
|
-
|
|
221
|
+
if (globalThis.CanvasRenderingContext2D) {
|
|
222
|
+
if (typeof globalThis.Path2D.prototype.roundRect === "undefined") {
|
|
223
|
+
globalThis.Path2D.prototype.roundRect = roundRect;
|
|
224
|
+
}
|
|
223
225
|
}
|
|
224
226
|
if (globalThis.CanvasRenderingContext2D) {
|
|
225
227
|
if (typeof globalThis.CanvasRenderingContext2D.prototype.roundRect === "undefined") {
|
package/src/renderable/GUI.js
CHANGED
|
@@ -118,11 +118,10 @@ class GUI_Object extends Sprite {
|
|
|
118
118
|
* @name onClick
|
|
119
119
|
* @memberof GUI_Object
|
|
120
120
|
* @public
|
|
121
|
-
* @function
|
|
122
121
|
* @param {Pointer} event the event object
|
|
123
122
|
* @returns {boolean} return false if we need to stop propagating the event
|
|
124
123
|
*/
|
|
125
|
-
onClick(
|
|
124
|
+
onClick(event) { // eslint-disable-line no-unused-vars
|
|
126
125
|
return false;
|
|
127
126
|
}
|
|
128
127
|
|
|
@@ -141,10 +140,11 @@ class GUI_Object extends Sprite {
|
|
|
141
140
|
* @name onOver
|
|
142
141
|
* @memberof GUI_Object
|
|
143
142
|
* @public
|
|
144
|
-
* @function
|
|
145
143
|
* @param {Pointer} event the event object
|
|
146
144
|
*/
|
|
147
|
-
onOver(
|
|
145
|
+
onOver(event) { // eslint-disable-line no-unused-vars
|
|
146
|
+
// to be extended
|
|
147
|
+
}
|
|
148
148
|
|
|
149
149
|
/**
|
|
150
150
|
* function callback for the pointerLeave event
|
|
@@ -162,11 +162,10 @@ class GUI_Object extends Sprite {
|
|
|
162
162
|
* @name onOut
|
|
163
163
|
* @memberof GUI_Object
|
|
164
164
|
* @public
|
|
165
|
-
* @function
|
|
166
165
|
* @param {Pointer} event the event object
|
|
167
166
|
*/
|
|
168
|
-
onOut(
|
|
169
|
-
|
|
167
|
+
onOut(event) { // eslint-disable-line no-unused-vars
|
|
168
|
+
// to be extended
|
|
170
169
|
}
|
|
171
170
|
|
|
172
171
|
/**
|
|
@@ -187,7 +186,6 @@ class GUI_Object extends Sprite {
|
|
|
187
186
|
* @name onRelease
|
|
188
187
|
* @memberof GUI_Object
|
|
189
188
|
* @public
|
|
190
|
-
* @function
|
|
191
189
|
* @returns {boolean} return false if we need to stop propagating the event
|
|
192
190
|
*/
|
|
193
191
|
onRelease() {
|
|
@@ -212,7 +210,6 @@ class GUI_Object extends Sprite {
|
|
|
212
210
|
* @name onHold
|
|
213
211
|
* @memberof GUI_Object
|
|
214
212
|
* @public
|
|
215
|
-
* @function
|
|
216
213
|
*/
|
|
217
214
|
onHold() {}
|
|
218
215
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import pool from "./../system/pooling.js";
|
|
2
|
-
import { viewport } from "./../game.js";
|
|
3
2
|
import Renderable from "./renderable.js";
|
|
4
3
|
|
|
5
4
|
|
|
@@ -41,15 +40,18 @@ class ColorLayer extends Renderable {
|
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
/**
|
|
44
|
-
* draw
|
|
45
|
-
* @
|
|
43
|
+
* draw this color layer (automatically called by melonJS)
|
|
44
|
+
* @name draw
|
|
45
|
+
* @memberof ColorLayer
|
|
46
|
+
* @protected
|
|
47
|
+
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer instance
|
|
48
|
+
* @param {Camera2d} [viewport] the viewport to (re)draw
|
|
46
49
|
*/
|
|
47
|
-
draw(renderer,
|
|
48
|
-
var vpos = viewport.pos;
|
|
50
|
+
draw(renderer, viewport) {
|
|
49
51
|
renderer.save();
|
|
50
52
|
renderer.clipRect(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
0, 0,
|
|
54
|
+
viewport.width, viewport.height
|
|
53
55
|
);
|
|
54
56
|
renderer.clearColor(this.color);
|
|
55
57
|
renderer.restore();
|
|
@@ -100,10 +100,9 @@ class Container extends Renderable {
|
|
|
100
100
|
* a callback to be extended, triggered after a child has been added or removed
|
|
101
101
|
* @name onChildChange
|
|
102
102
|
* @memberof Container#
|
|
103
|
-
* @function
|
|
104
103
|
* @param {number} index added or removed child index
|
|
105
104
|
*/
|
|
106
|
-
this.onChildChange = function (
|
|
105
|
+
this.onChildChange = function (index) { // eslint-disable-line no-unused-vars
|
|
107
106
|
// to be extended
|
|
108
107
|
};
|
|
109
108
|
|
|
@@ -157,7 +156,6 @@ class Container extends Renderable {
|
|
|
157
156
|
* reset the container, removing all childrens, and reseting transforms.
|
|
158
157
|
* @name reset
|
|
159
158
|
* @memberof Container
|
|
160
|
-
* @function
|
|
161
159
|
*/
|
|
162
160
|
reset() {
|
|
163
161
|
// cancel any sort operation
|
|
@@ -189,11 +187,12 @@ class Container extends Renderable {
|
|
|
189
187
|
* Adding a child to the container will automatically remove it from its other container.
|
|
190
188
|
* Meaning a child can only have one parent. This is important if you add a renderable
|
|
191
189
|
* to a container then add it to the me.game.world container it will move it out of the
|
|
192
|
-
* orginal container.
|
|
193
|
-
* will not be in any container.
|
|
190
|
+
* orginal container. Then when the me.game.world.reset() is called the renderable
|
|
191
|
+
* will not be in any container. <br>
|
|
192
|
+
* if the given child implements a onActivateEvent method, that method will be called
|
|
193
|
+
* once the child is added to this container.
|
|
194
194
|
* @name addChild
|
|
195
195
|
* @memberof Container
|
|
196
|
-
* @function
|
|
197
196
|
* @param {Renderable} child
|
|
198
197
|
* @param {number} [z] forces the z index of the child to the specified value
|
|
199
198
|
* @returns {Renderable} the added child
|
|
@@ -257,7 +256,6 @@ class Container extends Renderable {
|
|
|
257
256
|
* (the list won't be sorted after insertion)
|
|
258
257
|
* @name addChildAt
|
|
259
258
|
* @memberof Container
|
|
260
|
-
* @function
|
|
261
259
|
* @param {Renderable} child
|
|
262
260
|
* @param {number} index
|
|
263
261
|
* @returns {Renderable} the added child
|
|
@@ -316,7 +314,6 @@ class Container extends Renderable {
|
|
|
316
314
|
* - The array forEach() was called upon. <br>
|
|
317
315
|
* @name forEach
|
|
318
316
|
* @memberof Container
|
|
319
|
-
* @function
|
|
320
317
|
* @param {Function} callback fnction to execute on each element
|
|
321
318
|
* @param {object} [thisArg] value to use as this(i.e reference Object) when executing callback.
|
|
322
319
|
* @example
|
|
@@ -353,7 +350,6 @@ class Container extends Renderable {
|
|
|
353
350
|
* Swaps the position (z-index) of 2 children
|
|
354
351
|
* @name swapChildren
|
|
355
352
|
* @memberof Container
|
|
356
|
-
* @function
|
|
357
353
|
* @param {Renderable} child
|
|
358
354
|
* @param {Renderable} child2
|
|
359
355
|
*/
|
|
@@ -381,7 +377,6 @@ class Container extends Renderable {
|
|
|
381
377
|
* Returns the Child at the specified index
|
|
382
378
|
* @name getChildAt
|
|
383
379
|
* @memberof Container
|
|
384
|
-
* @function
|
|
385
380
|
* @param {number} index
|
|
386
381
|
* @returns {Renderable} the child at the specified index
|
|
387
382
|
*/
|
|
@@ -398,7 +393,6 @@ class Container extends Renderable {
|
|
|
398
393
|
* Returns the index of the given Child
|
|
399
394
|
* @name getChildIndex
|
|
400
395
|
* @memberof Container
|
|
401
|
-
* @function
|
|
402
396
|
* @param {Renderable} child
|
|
403
397
|
* @returns {number} index
|
|
404
398
|
*/
|
|
@@ -410,7 +404,6 @@ class Container extends Renderable {
|
|
|
410
404
|
* Returns the next child within the container or undefined if none
|
|
411
405
|
* @name getNextChild
|
|
412
406
|
* @memberof Container
|
|
413
|
-
* @function
|
|
414
407
|
* @param {Renderable} child
|
|
415
408
|
* @returns {Renderable} child
|
|
416
409
|
*/
|
|
@@ -426,7 +419,6 @@ class Container extends Renderable {
|
|
|
426
419
|
* Returns true if contains the specified Child
|
|
427
420
|
* @name hasChild
|
|
428
421
|
* @memberof Container
|
|
429
|
-
* @function
|
|
430
422
|
* @param {Renderable} child
|
|
431
423
|
* @returns {boolean}
|
|
432
424
|
*/
|
|
@@ -441,7 +433,6 @@ class Container extends Renderable {
|
|
|
441
433
|
* @name getChildByProp
|
|
442
434
|
* @memberof Container
|
|
443
435
|
* @public
|
|
444
|
-
* @function
|
|
445
436
|
* @param {string} prop Property name
|
|
446
437
|
* @param {string|RegExp|number|boolean} value Value of the property
|
|
447
438
|
* @returns {Renderable[]} Array of childs
|
|
@@ -493,7 +484,6 @@ class Container extends Renderable {
|
|
|
493
484
|
* @name getChildByType
|
|
494
485
|
* @memberof Container
|
|
495
486
|
* @public
|
|
496
|
-
* @function
|
|
497
487
|
* @param {object} classType
|
|
498
488
|
* @returns {Renderable[]} Array of children
|
|
499
489
|
*/
|
|
@@ -520,7 +510,6 @@ class Container extends Renderable {
|
|
|
520
510
|
* @name getChildByName
|
|
521
511
|
* @memberof Container
|
|
522
512
|
* @public
|
|
523
|
-
* @function
|
|
524
513
|
* @param {string|RegExp|number|boolean} name child name
|
|
525
514
|
* @returns {Renderable[]} Array of children
|
|
526
515
|
*/
|
|
@@ -535,7 +524,6 @@ class Container extends Renderable {
|
|
|
535
524
|
* @name getChildByGUID
|
|
536
525
|
* @memberof Container
|
|
537
526
|
* @public
|
|
538
|
-
* @function
|
|
539
527
|
* @param {string|RegExp|number|boolean} guid child GUID
|
|
540
528
|
* @returns {Renderable} corresponding child or null
|
|
541
529
|
*/
|
|
@@ -549,7 +537,6 @@ class Container extends Renderable {
|
|
|
549
537
|
* @name getChildren
|
|
550
538
|
* @memberof Container
|
|
551
539
|
* @public
|
|
552
|
-
* @function
|
|
553
540
|
* @returns {Renderable[]} an array of renderable object
|
|
554
541
|
*/
|
|
555
542
|
getChildren() {
|
|
@@ -564,7 +551,6 @@ class Container extends Renderable {
|
|
|
564
551
|
* @ignore
|
|
565
552
|
* @name updateBounds
|
|
566
553
|
* @memberof Renderable
|
|
567
|
-
* @function
|
|
568
554
|
* @returns {Bounds} this shape bounding box Rectangle object
|
|
569
555
|
*/
|
|
570
556
|
updateBounds(forceUpdateChildBounds = false) {
|
|
@@ -593,7 +579,6 @@ class Container extends Renderable {
|
|
|
593
579
|
* @private
|
|
594
580
|
* @name isAttachedToRoot
|
|
595
581
|
* @memberof Container
|
|
596
|
-
* @function
|
|
597
582
|
* @returns {boolean}
|
|
598
583
|
*/
|
|
599
584
|
isAttachedToRoot() {
|
|
@@ -616,7 +601,6 @@ class Container extends Renderable {
|
|
|
616
601
|
* @ignore
|
|
617
602
|
* @name updateBoundsPos
|
|
618
603
|
* @memberof Container
|
|
619
|
-
* @function
|
|
620
604
|
*/
|
|
621
605
|
updateBoundsPos(newX, newY) {
|
|
622
606
|
// call the parent method
|
|
@@ -648,11 +632,11 @@ class Container extends Renderable {
|
|
|
648
632
|
}
|
|
649
633
|
|
|
650
634
|
/**
|
|
651
|
-
* Invokes the removeChildNow in a defer, to ensure the child is removed safely after the update & draw stack has completed
|
|
635
|
+
* Invokes the removeChildNow in a defer, to ensure the child is removed safely after the update & draw stack has completed. <br>
|
|
636
|
+
* if the given child implements a onDeactivateEvent() method, that method will be called once the child is removed from this container.
|
|
652
637
|
* @name removeChild
|
|
653
638
|
* @memberof Container
|
|
654
639
|
* @public
|
|
655
|
-
* @function
|
|
656
640
|
* @param {Renderable} child
|
|
657
641
|
* @param {boolean} [keepalive=False] True to prevent calling child.destroy()
|
|
658
642
|
*/
|
|
@@ -671,7 +655,6 @@ class Container extends Renderable {
|
|
|
671
655
|
* Never use keepalive=true with objects from {@link pool}. Doing so will create a memory leak.
|
|
672
656
|
* @name removeChildNow
|
|
673
657
|
* @memberof Container
|
|
674
|
-
* @function
|
|
675
658
|
* @param {Renderable} child
|
|
676
659
|
* @param {boolean} [keepalive=False] True to prevent calling child.destroy()
|
|
677
660
|
*/
|
|
@@ -724,7 +707,6 @@ class Container extends Renderable {
|
|
|
724
707
|
* Automatically set the specified property of all childs to the given value
|
|
725
708
|
* @name setChildsProperty
|
|
726
709
|
* @memberof Container
|
|
727
|
-
* @function
|
|
728
710
|
* @param {string} prop property name
|
|
729
711
|
* @param {object} value property value
|
|
730
712
|
* @param {boolean} [recursive=false] recursively apply the value to child containers if true
|
|
@@ -742,7 +724,6 @@ class Container extends Renderable {
|
|
|
742
724
|
* Move the child in the group one step forward (z depth).
|
|
743
725
|
* @name moveUp
|
|
744
726
|
* @memberof Container
|
|
745
|
-
* @function
|
|
746
727
|
* @param {Renderable} child
|
|
747
728
|
*/
|
|
748
729
|
moveUp(child) {
|
|
@@ -759,7 +740,6 @@ class Container extends Renderable {
|
|
|
759
740
|
* Move the child in the group one step backward (z depth).
|
|
760
741
|
* @name moveDown
|
|
761
742
|
* @memberof Container
|
|
762
|
-
* @function
|
|
763
743
|
* @param {Renderable} child
|
|
764
744
|
*/
|
|
765
745
|
moveDown(child) {
|
|
@@ -776,7 +756,6 @@ class Container extends Renderable {
|
|
|
776
756
|
* Move the specified child to the top(z depth).
|
|
777
757
|
* @name moveToTop
|
|
778
758
|
* @memberof Container
|
|
779
|
-
* @function
|
|
780
759
|
* @param {Renderable} child
|
|
781
760
|
*/
|
|
782
761
|
moveToTop(child) {
|
|
@@ -796,7 +775,6 @@ class Container extends Renderable {
|
|
|
796
775
|
* Move the specified child the bottom (z depth).
|
|
797
776
|
* @name moveToBottom
|
|
798
777
|
* @memberof Container
|
|
799
|
-
* @function
|
|
800
778
|
* @param {Renderable} child
|
|
801
779
|
*/
|
|
802
780
|
moveToBottom(child) {
|
|
@@ -817,7 +795,6 @@ class Container extends Renderable {
|
|
|
817
795
|
* @name sort
|
|
818
796
|
* @memberof Container
|
|
819
797
|
* @public
|
|
820
|
-
* @function
|
|
821
798
|
* @param {boolean} [recursive=false] recursively sort all containers if true
|
|
822
799
|
*/
|
|
823
800
|
sort(recursive) {
|
|
@@ -911,7 +888,6 @@ class Container extends Renderable {
|
|
|
911
888
|
* automatically called by the game manager {@link game}
|
|
912
889
|
* @name update
|
|
913
890
|
* @memberof Container
|
|
914
|
-
* @function
|
|
915
891
|
* @protected
|
|
916
892
|
* @param {number} dt time since the last update in milliseconds.
|
|
917
893
|
* @returns {boolean} true if the Container is dirty
|
|
@@ -960,16 +936,14 @@ class Container extends Renderable {
|
|
|
960
936
|
}
|
|
961
937
|
|
|
962
938
|
/**
|
|
963
|
-
|
|
964
|
-
* automatically called by the game manager {@link game}
|
|
939
|
+
* draw this renderable (automatically called by melonJS)
|
|
965
940
|
* @name draw
|
|
966
941
|
* @memberof Container
|
|
967
|
-
* @function
|
|
968
942
|
* @protected
|
|
969
|
-
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer
|
|
970
|
-
* @param {
|
|
943
|
+
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer instance
|
|
944
|
+
* @param {Camera2d} [viewport] the viewport to (re)draw
|
|
971
945
|
*/
|
|
972
|
-
draw(renderer,
|
|
946
|
+
draw(renderer, viewport) {
|
|
973
947
|
var isFloating = false;
|
|
974
948
|
var bounds = this.getBounds();
|
|
975
949
|
|
|
@@ -1011,7 +985,7 @@ class Container extends Renderable {
|
|
|
1011
985
|
obj.preDraw(renderer);
|
|
1012
986
|
|
|
1013
987
|
// draw the object
|
|
1014
|
-
obj.draw(renderer,
|
|
988
|
+
obj.draw(renderer, viewport);
|
|
1015
989
|
|
|
1016
990
|
// postdraw (clean-up);
|
|
1017
991
|
obj.postDraw(renderer);
|
|
@@ -33,7 +33,6 @@ export class Draggable extends Renderable {
|
|
|
33
33
|
* transformed events.
|
|
34
34
|
* @name initEvents
|
|
35
35
|
* @memberof Draggable
|
|
36
|
-
* @function
|
|
37
36
|
* @private
|
|
38
37
|
*/
|
|
39
38
|
initEvents() {
|
|
@@ -57,7 +56,6 @@ export class Draggable extends Renderable {
|
|
|
57
56
|
* Gets called when the user starts dragging the entity
|
|
58
57
|
* @name dragStart
|
|
59
58
|
* @memberof Draggable
|
|
60
|
-
* @function
|
|
61
59
|
* @param {object} e the pointer event
|
|
62
60
|
* @returns {boolean} false if the object is being dragged
|
|
63
61
|
*/
|
|
@@ -74,7 +72,6 @@ export class Draggable extends Renderable {
|
|
|
74
72
|
* Gets called when the user drags this entity around
|
|
75
73
|
* @name dragMove
|
|
76
74
|
* @memberof Draggable
|
|
77
|
-
* @function
|
|
78
75
|
* @param {object} e the pointer event
|
|
79
76
|
*/
|
|
80
77
|
dragMove(e) {
|
|
@@ -88,7 +85,6 @@ export class Draggable extends Renderable {
|
|
|
88
85
|
* Gets called when the user stops dragging the entity
|
|
89
86
|
* @name dragEnd
|
|
90
87
|
* @memberof Draggable
|
|
91
|
-
* @function
|
|
92
88
|
* @returns {boolean} false if the object stopped being dragged
|
|
93
89
|
*/
|
|
94
90
|
dragEnd() {
|
|
@@ -102,7 +98,6 @@ export class Draggable extends Renderable {
|
|
|
102
98
|
* Destructor
|
|
103
99
|
* @name destroy
|
|
104
100
|
* @memberof Draggable
|
|
105
|
-
* @function
|
|
106
101
|
* @ignore
|
|
107
102
|
*/
|
|
108
103
|
destroy() {
|
|
@@ -173,7 +168,6 @@ export class DropTarget extends Renderable {
|
|
|
173
168
|
* Sets the collision method which is going to be used to check a valid drop
|
|
174
169
|
* @name setCheckMethod
|
|
175
170
|
* @memberof DropTarget
|
|
176
|
-
* @function
|
|
177
171
|
* @param {string} checkMethod the checkmethod (defaults to CHECKMETHOD_OVERLAP)
|
|
178
172
|
*/
|
|
179
173
|
setCheckMethod(checkMethod) {
|
|
@@ -188,7 +182,6 @@ export class DropTarget extends Renderable {
|
|
|
188
182
|
* Checks if a dropped entity is dropped on the current entity
|
|
189
183
|
* @name checkOnMe
|
|
190
184
|
* @memberof DropTarget
|
|
191
|
-
* @function
|
|
192
185
|
* @param {object} e the triggering event
|
|
193
186
|
* @param {Draggable} draggable the draggable object that is dropped
|
|
194
187
|
*/
|
|
@@ -203,10 +196,9 @@ export class DropTarget extends Renderable {
|
|
|
203
196
|
* Gets called when a draggable entity is dropped on the current entity
|
|
204
197
|
* @name drop
|
|
205
198
|
* @memberof DropTarget
|
|
206
|
-
* @function
|
|
207
199
|
* @param {Draggable} draggable the draggable object that is dropped
|
|
208
200
|
*/
|
|
209
|
-
drop() {
|
|
201
|
+
drop(draggable) { // eslint-disable-line no-unused-vars
|
|
210
202
|
|
|
211
203
|
}
|
|
212
204
|
|
|
@@ -214,7 +206,6 @@ export class DropTarget extends Renderable {
|
|
|
214
206
|
* Destructor
|
|
215
207
|
* @name destroy
|
|
216
208
|
* @memberof DropTarget
|
|
217
|
-
* @function
|
|
218
209
|
* @ignore
|
|
219
210
|
*/
|
|
220
211
|
destroy() {
|
|
@@ -75,7 +75,7 @@ class ImageLayer extends Sprite {
|
|
|
75
75
|
* - a number, to change the value for both axis <br>
|
|
76
76
|
* - a json expression like `json:{"x":0.5,"y":0.5}` if you wish to specify a different value for both x and y
|
|
77
77
|
* @public
|
|
78
|
-
* @
|
|
78
|
+
* @member {Vector2d}
|
|
79
79
|
* @default <0.0,0.0>
|
|
80
80
|
* @name ImageLayer#anchorPoint
|
|
81
81
|
*/
|
|
@@ -160,12 +160,11 @@ class ImageLayer extends Sprite {
|
|
|
160
160
|
* resize the Image Layer to match the given size
|
|
161
161
|
* @name resize
|
|
162
162
|
* @memberof ImageLayer
|
|
163
|
-
* @function
|
|
164
163
|
* @param {number} w new width
|
|
165
164
|
* @param {number} h new height
|
|
166
165
|
*/
|
|
167
166
|
resize(w, h) {
|
|
168
|
-
super.resize(
|
|
167
|
+
return super.resize(
|
|
169
168
|
this.repeatX ? Infinity : w,
|
|
170
169
|
this.repeatY ? Infinity : h
|
|
171
170
|
);
|
|
@@ -174,7 +173,6 @@ class ImageLayer extends Sprite {
|
|
|
174
173
|
/**
|
|
175
174
|
* createPattern function
|
|
176
175
|
* @ignore
|
|
177
|
-
* @function
|
|
178
176
|
*/
|
|
179
177
|
createPattern() {
|
|
180
178
|
this._pattern = renderer.createPattern(this.image, this._repeat);
|
|
@@ -183,7 +181,6 @@ class ImageLayer extends Sprite {
|
|
|
183
181
|
/**
|
|
184
182
|
* updateLayer function
|
|
185
183
|
* @ignore
|
|
186
|
-
* @function
|
|
187
184
|
*/
|
|
188
185
|
updateLayer(vpos) {
|
|
189
186
|
var rx = this.ratio.x,
|
|
@@ -246,15 +243,14 @@ class ImageLayer extends Sprite {
|
|
|
246
243
|
}
|
|
247
244
|
|
|
248
245
|
/**
|
|
249
|
-
* draw
|
|
250
|
-
* automatically called by the game manager {@link game}
|
|
246
|
+
* draw this ImageLayer (automatically called by melonJS)
|
|
251
247
|
* @name draw
|
|
252
248
|
* @memberof ImageLayer
|
|
253
|
-
* @function
|
|
254
249
|
* @protected
|
|
255
|
-
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer
|
|
250
|
+
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer instance
|
|
251
|
+
* @param {Camera2d} [viewport] the viewport to (re)draw
|
|
256
252
|
*/
|
|
257
|
-
draw(renderer) {
|
|
253
|
+
draw(renderer, viewport) {
|
|
258
254
|
var width = this.width,
|
|
259
255
|
height = this.height,
|
|
260
256
|
bw = viewport.bounds.width,
|