melonjs 15.0.0 → 15.1.1
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 -4
- package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +1 -1
- package/dist/melonjs.mjs/_virtual/arraymultimap.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 +7 -3
- package/dist/melonjs.mjs/_virtual/index2.js +1 -1
- package/dist/melonjs.mjs/_virtual/multimap.js +1 -1
- package/dist/melonjs.mjs/_virtual/setmultimap.js +1 -1
- package/dist/melonjs.mjs/application/application.js +27 -17
- package/dist/melonjs.mjs/application/header.js +6 -5
- package/dist/melonjs.mjs/application/resize.js +20 -20
- package/dist/melonjs.mjs/application/settings.js +1 -1
- package/dist/melonjs.mjs/audio/audio.js +17 -17
- package/dist/melonjs.mjs/camera/camera2d.js +10 -10
- package/dist/melonjs.mjs/const.js +1 -1
- package/dist/melonjs.mjs/entity/entity.js +4 -4
- package/dist/melonjs.mjs/geometries/ellipse.js +6 -6
- package/dist/melonjs.mjs/geometries/line.js +9 -9
- package/dist/melonjs.mjs/geometries/path2d.js +53 -53
- package/dist/melonjs.mjs/geometries/point.js +2 -2
- package/dist/melonjs.mjs/geometries/poly.js +29 -29
- package/dist/melonjs.mjs/geometries/rectangle.js +8 -8
- package/dist/melonjs.mjs/geometries/roundrect.js +6 -6
- package/dist/melonjs.mjs/index.js +5 -5
- package/dist/melonjs.mjs/input/gamepad.js +30 -30
- package/dist/melonjs.mjs/input/input.js +2 -2
- package/dist/melonjs.mjs/input/keyboard.js +15 -15
- package/dist/melonjs.mjs/input/pointer.js +2 -2
- package/dist/melonjs.mjs/input/pointerevent.js +58 -58
- package/dist/melonjs.mjs/lang/console.js +3 -3
- package/dist/melonjs.mjs/lang/deprecated.js +2 -2
- package/dist/melonjs.mjs/level/level.js +9 -9
- package/dist/melonjs.mjs/level/tiled/TMXGroup.js +3 -3
- package/dist/melonjs.mjs/level/tiled/TMXLayer.js +31 -31
- package/dist/melonjs.mjs/level/tiled/TMXObject.js +8 -8
- package/dist/melonjs.mjs/level/tiled/TMXTile.js +8 -8
- package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +19 -19
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +15 -15
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +3 -3
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +46 -41
- package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +30 -30
- package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +21 -21
- package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +10 -10
- package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +6 -6
- 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 +7 -7
- package/dist/melonjs.mjs/loader/loadingscreen.js +2 -2
- package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
- package/dist/melonjs.mjs/loader/parser.js +13 -13
- package/dist/melonjs.mjs/loader/settings.js +3 -3
- package/dist/melonjs.mjs/math/color.js +21 -21
- package/dist/melonjs.mjs/math/math.js +2 -2
- package/dist/melonjs.mjs/math/matrix2.js +22 -22
- package/dist/melonjs.mjs/math/matrix3.js +52 -52
- package/dist/melonjs.mjs/math/observable_vector2.js +12 -12
- package/dist/melonjs.mjs/math/observable_vector3.js +22 -22
- package/dist/melonjs.mjs/math/vector2.js +11 -11
- package/dist/melonjs.mjs/math/vector3.js +21 -21
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/arraymultimap.js +45 -0
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/multimap.js +130 -0
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/arraymultimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/index.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/multimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/setmultimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +1 -1
- package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +2 -2
- 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 +5 -5
- package/dist/melonjs.mjs/particles/particle.js +8 -8
- package/dist/melonjs.mjs/particles/settings.js +3 -3
- package/dist/melonjs.mjs/physics/body.js +17 -17
- package/dist/melonjs.mjs/physics/bounds.js +12 -12
- package/dist/melonjs.mjs/physics/collision.js +3 -3
- package/dist/melonjs.mjs/physics/detector.js +14 -14
- package/dist/melonjs.mjs/physics/quadtree.js +19 -19
- package/dist/melonjs.mjs/physics/response.js +1 -1
- package/dist/melonjs.mjs/physics/sat.js +60 -60
- package/dist/melonjs.mjs/physics/world.js +4 -4
- package/dist/melonjs.mjs/plugin/plugin.js +11 -11
- package/dist/melonjs.mjs/renderable/collectable.js +2 -2
- package/dist/melonjs.mjs/renderable/colorlayer.js +1 -1
- package/dist/melonjs.mjs/renderable/container.js +107 -63
- package/dist/melonjs.mjs/renderable/dragndrop.js +5 -5
- package/dist/melonjs.mjs/renderable/imagelayer.js +7 -6
- package/dist/melonjs.mjs/renderable/light2d.js +6 -6
- package/dist/melonjs.mjs/renderable/nineslicesprite.js +12 -12
- package/dist/melonjs.mjs/renderable/renderable.js +11 -11
- package/dist/melonjs.mjs/renderable/sprite.js +25 -25
- package/dist/melonjs.mjs/renderable/trigger.js +11 -9
- package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +97 -27
- package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +25 -25
- package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +83 -63
- package/dist/melonjs.mjs/state/stage.js +7 -7
- package/dist/melonjs.mjs/state/state.js +15 -15
- package/dist/melonjs.mjs/system/device.js +2 -2
- package/dist/melonjs.mjs/system/dom.js +1 -1
- package/dist/melonjs.mjs/system/event.js +2 -2
- package/dist/melonjs.mjs/system/platform.js +1 -1
- package/dist/melonjs.mjs/system/pooling.js +9 -9
- package/dist/melonjs.mjs/system/save.js +6 -6
- package/dist/melonjs.mjs/system/timer.js +16 -12
- package/dist/melonjs.mjs/text/bitmaptext.js +20 -20
- package/dist/melonjs.mjs/text/bitmaptextdata.js +22 -22
- package/dist/melonjs.mjs/text/glyph.js +3 -3
- package/dist/melonjs.mjs/text/text.js +10 -9
- package/dist/melonjs.mjs/text/textmetrics.js +15 -15
- package/dist/melonjs.mjs/text/textstyle.js +1 -1
- package/dist/melonjs.mjs/tweens/easing.js +4 -4
- package/dist/melonjs.mjs/tweens/interpolation.js +8 -8
- package/dist/melonjs.mjs/tweens/tween.js +11 -11
- package/dist/melonjs.mjs/utils/agent.js +6 -6
- package/dist/melonjs.mjs/utils/array.js +4 -4
- package/dist/melonjs.mjs/utils/file.js +1 -1
- package/dist/melonjs.mjs/utils/function.js +5 -5
- package/dist/melonjs.mjs/utils/string.js +3 -3
- package/dist/melonjs.mjs/utils/utils.js +16 -16
- package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +35 -109
- package/dist/melonjs.mjs/video/renderer.js +74 -7
- package/dist/melonjs.mjs/video/texture/atlas.js +37 -37
- package/dist/melonjs.mjs/video/texture/cache.js +9 -10
- package/dist/melonjs.mjs/video/texture/canvas_texture.js +63 -3
- package/dist/melonjs.mjs/video/utils/autodetect.js +1 -1
- package/dist/melonjs.mjs/video/video.js +2 -2
- package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +3 -3
- package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +5 -5
- package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +5 -5
- package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +18 -15
- package/dist/melonjs.mjs/video/webgl/glshader.js +7 -7
- 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 +2 -2
- package/dist/melonjs.mjs/video/webgl/utils/precision.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/program.js +7 -7
- package/dist/melonjs.mjs/video/webgl/utils/string.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +4 -4
- package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +55 -38
- package/dist/melonjs.module.js +1777 -1813
- package/dist/types/application/application.d.ts +11 -8
- package/dist/types/audio/audio.d.ts +3 -3
- package/dist/types/index.d.ts +4 -3
- package/dist/types/input/input.d.ts +1 -1
- package/dist/types/input/keyboard.d.ts +1 -1
- package/dist/types/input/pointerevent.d.ts +6 -6
- package/dist/types/level/level.d.ts +2 -2
- package/dist/types/level/tiled/TMXLayer.d.ts +4 -4
- package/dist/types/level/tiled/TMXTileMap.d.ts +2 -2
- package/dist/types/level/tiled/TMXUtils.d.ts +5 -4
- package/dist/types/loader/loader.d.ts +2 -2
- package/dist/types/loader/settings.d.ts +2 -2
- package/dist/types/particles/emitter.d.ts +1 -1
- package/dist/types/physics/collision.d.ts +1 -1
- package/dist/types/physics/detector.d.ts +1 -1
- package/dist/types/plugin/plugin.d.ts +2 -2
- package/dist/types/renderable/container.d.ts +21 -17
- package/dist/types/renderable/sprite.d.ts +11 -11
- package/dist/types/renderable/trigger.d.ts +1 -1
- package/dist/types/renderable/ui/uibaseelement.d.ts +28 -6
- package/dist/types/renderable/ui/uispriteelement.d.ts +12 -14
- package/dist/types/renderable/ui/uitextbutton.d.ts +52 -11
- package/dist/types/state/stage.d.ts +1 -1
- package/dist/types/system/device.d.ts +1 -1
- package/dist/types/system/pooling.d.ts +3 -3
- package/dist/types/system/timer.d.ts +5 -5
- package/dist/types/text/bitmaptext.d.ts +1 -1
- package/dist/types/text/text.d.ts +1 -1
- package/dist/types/utils/array.d.ts +2 -2
- package/dist/types/video/canvas/canvas_renderer.d.ts +8 -76
- package/dist/types/video/renderer.d.ts +48 -0
- package/dist/types/video/texture/atlas.d.ts +3 -3
- package/dist/types/video/texture/canvas_texture.d.ts +40 -0
- package/dist/types/video/webgl/glshader.d.ts +1 -1
- package/dist/types/video/webgl/webgl_renderer.d.ts +13 -9
- package/package.json +14 -14
- package/src/application/application.js +26 -16
- package/src/application/header.js +5 -4
- package/src/application/resize.js +19 -19
- package/src/audio/audio.js +16 -16
- package/src/camera/camera2d.js +9 -9
- package/src/entity/entity.js +3 -3
- package/src/geometries/ellipse.js +5 -5
- package/src/geometries/line.js +8 -8
- package/src/geometries/path2d.js +52 -52
- package/src/geometries/point.js +1 -1
- package/src/geometries/poly.js +28 -28
- package/src/geometries/rectangle.js +7 -7
- package/src/geometries/roundrect.js +5 -5
- package/src/index.js +3 -2
- package/src/input/gamepad.js +29 -29
- package/src/input/input.js +1 -1
- package/src/input/keyboard.js +14 -14
- package/src/input/pointer.js +1 -1
- package/src/input/pointerevent.js +52 -52
- package/src/lang/console.js +2 -2
- package/src/lang/deprecated.js +1 -1
- package/src/level/level.js +8 -8
- package/src/level/tiled/TMXGroup.js +2 -2
- package/src/level/tiled/TMXLayer.js +30 -30
- package/src/level/tiled/TMXObject.js +7 -7
- package/src/level/tiled/TMXTile.js +7 -7
- package/src/level/tiled/TMXTileMap.js +18 -18
- package/src/level/tiled/TMXTileset.js +14 -14
- package/src/level/tiled/TMXTilesetGroup.js +2 -2
- package/src/level/tiled/TMXUtils.js +45 -40
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +29 -29
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +20 -20
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +9 -9
- package/src/level/tiled/renderer/TMXRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +5 -5
- package/src/loader/loader.js +6 -6
- package/src/loader/loadingscreen.js +1 -1
- package/src/loader/parser.js +12 -12
- package/src/loader/settings.js +2 -2
- package/src/math/color.js +20 -20
- package/src/math/math.js +1 -1
- package/src/math/matrix2.js +21 -21
- package/src/math/matrix3.js +51 -51
- package/src/math/observable_vector2.js +11 -11
- package/src/math/observable_vector3.js +21 -21
- package/src/math/vector2.js +10 -10
- package/src/math/vector3.js +20 -20
- package/src/particles/emitter.js +4 -4
- package/src/particles/particle.js +7 -7
- package/src/particles/settings.js +2 -2
- package/src/physics/body.js +16 -16
- package/src/physics/bounds.js +11 -11
- package/src/physics/collision.js +2 -2
- package/src/physics/detector.js +13 -13
- package/src/physics/quadtree.js +18 -18
- package/src/physics/sat.js +59 -59
- package/src/physics/world.js +3 -3
- package/src/plugin/plugin.js +8 -8
- package/src/renderable/collectable.js +1 -1
- package/src/renderable/container.js +106 -62
- package/src/renderable/dragndrop.js +4 -4
- package/src/renderable/imagelayer.js +6 -5
- package/src/renderable/light2d.js +5 -5
- package/src/renderable/nineslicesprite.js +11 -11
- package/src/renderable/renderable.js +10 -10
- package/src/renderable/sprite.js +24 -24
- package/src/renderable/trigger.js +10 -8
- package/src/renderable/ui/uibaseelement.js +96 -26
- package/src/renderable/ui/uispriteelement.js +24 -24
- package/src/renderable/ui/uitextbutton.js +85 -65
- package/src/state/stage.js +6 -6
- package/src/state/state.js +14 -14
- package/src/system/device.js +1 -1
- package/src/system/event.js +1 -1
- package/src/system/pooling.js +8 -8
- package/src/system/save.js +5 -5
- package/src/system/timer.js +15 -11
- package/src/text/bitmaptext.js +19 -19
- package/src/text/bitmaptextdata.js +21 -21
- package/src/text/glyph.js +2 -2
- package/src/text/text.js +9 -8
- package/src/text/textmetrics.js +14 -14
- package/src/tweens/easing.js +3 -3
- package/src/tweens/interpolation.js +7 -7
- package/src/tweens/tween.js +10 -10
- package/src/utils/agent.js +5 -5
- package/src/utils/array.js +3 -3
- package/src/utils/function.js +4 -4
- package/src/utils/string.js +2 -2
- package/src/utils/utils.js +15 -15
- package/src/video/canvas/canvas_renderer.js +34 -108
- package/src/video/renderer.js +72 -5
- package/src/video/texture/atlas.js +36 -36
- package/src/video/texture/cache.js +6 -6
- package/src/video/texture/canvas_texture.js +62 -2
- package/src/video/video.js +1 -1
- package/src/video/webgl/buffer/vertex.js +2 -2
- package/src/video/webgl/compositors/compositor.js +4 -4
- package/src/video/webgl/compositors/primitive_compositor.js +4 -4
- package/src/video/webgl/compositors/quad_compositor.js +17 -14
- package/src/video/webgl/glshader.js +6 -6
- package/src/video/webgl/utils/attributes.js +1 -1
- package/src/video/webgl/utils/program.js +6 -6
- package/src/video/webgl/utils/uniforms.js +3 -3
- package/src/video/webgl/webgl_renderer.js +54 -37
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.1.1
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -64,12 +64,12 @@ let globalFloatingCounter = 0;
|
|
|
64
64
|
this.children = undefined;
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
|
-
* The property of the child object that should be used to sort on
|
|
67
|
+
* The property of the child object that should be used to sort on this container
|
|
68
68
|
* value : "x", "y", "z"
|
|
69
69
|
* @type {string}
|
|
70
|
-
* @default
|
|
70
|
+
* @default "z"
|
|
71
71
|
*/
|
|
72
|
-
this.sortOn =
|
|
72
|
+
this.sortOn = "z";
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
75
|
* Specify if the children list should be automatically sorted when adding a new child
|
|
@@ -157,8 +157,8 @@ let globalFloatingCounter = 0;
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
// delete all children
|
|
160
|
-
|
|
161
|
-
for (
|
|
160
|
+
let children = this.getChildren();
|
|
161
|
+
for (let i = children.length, child; i >= 0; (child = children[--i])) {
|
|
162
162
|
// don't remove it if a persistent object
|
|
163
163
|
if (child && child.isPersistent !== true) {
|
|
164
164
|
this.removeChildNow(child);
|
|
@@ -177,9 +177,9 @@ let globalFloatingCounter = 0;
|
|
|
177
177
|
* Add a child to the container <br>
|
|
178
178
|
* if auto-sort is disable, the object will be appended at the bottom of the list.
|
|
179
179
|
* Adding a child to the container will automatically remove it from its other container.
|
|
180
|
-
* Meaning a child can only have one parent.
|
|
181
|
-
* to a container then add it to the
|
|
182
|
-
* orginal container. Then when the
|
|
180
|
+
* Meaning a child can only have one parent. This is important if you add a renderable
|
|
181
|
+
* to a container then add it to the World container it will move it out of the
|
|
182
|
+
* orginal container. Then when the World container reset() method is called the renderable
|
|
183
183
|
* will not be in any container. <br>
|
|
184
184
|
* if the given child implements a onActivateEvent method, that method will be called
|
|
185
185
|
* once the child is added to this container.
|
|
@@ -226,7 +226,7 @@ let globalFloatingCounter = 0;
|
|
|
226
226
|
|
|
227
227
|
// force repaint in case this is a static non-animated object
|
|
228
228
|
if (this.isAttachedToRoot() === true) {
|
|
229
|
-
|
|
229
|
+
this.isDirty = true;
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
// force bounds update if required
|
|
@@ -234,9 +234,22 @@ let globalFloatingCounter = 0;
|
|
|
234
234
|
this.updateBounds();
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
// if a physic body
|
|
238
|
-
if (
|
|
239
|
-
|
|
237
|
+
// if a physic body(ies) to the game world
|
|
238
|
+
if (this.isAttachedToRoot()) {
|
|
239
|
+
var worldContainer = this.getRootAncestor();
|
|
240
|
+
if (child.body instanceof Body) {
|
|
241
|
+
worldContainer.addBody(child.body);
|
|
242
|
+
}
|
|
243
|
+
// if the child is a container
|
|
244
|
+
if (child instanceof Container) {
|
|
245
|
+
// add all container child bodies
|
|
246
|
+
// TODO: make it recursive ?
|
|
247
|
+
child.forEach((cchild) => {
|
|
248
|
+
if (cchild.body instanceof Body) {
|
|
249
|
+
worldContainer.addBody(cchild.body);
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
}
|
|
240
253
|
}
|
|
241
254
|
|
|
242
255
|
// triggered callback if defined
|
|
@@ -275,7 +288,7 @@ let globalFloatingCounter = 0;
|
|
|
275
288
|
|
|
276
289
|
// force repaint in case this is a static non-animated object
|
|
277
290
|
if (this.isAttachedToRoot() === true) {
|
|
278
|
-
|
|
291
|
+
this.isDirty = true;
|
|
279
292
|
}
|
|
280
293
|
|
|
281
294
|
// force bounds update if required
|
|
@@ -283,9 +296,22 @@ let globalFloatingCounter = 0;
|
|
|
283
296
|
this.updateBounds();
|
|
284
297
|
}
|
|
285
298
|
|
|
286
|
-
// if a physic body
|
|
287
|
-
if (
|
|
288
|
-
|
|
299
|
+
// if a physic body(ies) to the game world
|
|
300
|
+
if (this.isAttachedToRoot()) {
|
|
301
|
+
var worldContainer = this.getRootAncestor();
|
|
302
|
+
if (child.body instanceof Body) {
|
|
303
|
+
worldContainer.addBody(child.body);
|
|
304
|
+
}
|
|
305
|
+
// if the child is a container
|
|
306
|
+
if (child instanceof Container) {
|
|
307
|
+
// add all container child bodies
|
|
308
|
+
// TODO: make it recursive ?
|
|
309
|
+
child.forEach((cchild) => {
|
|
310
|
+
if (cchild.body instanceof Body) {
|
|
311
|
+
worldContainer.addBody(cchild.body);
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
}
|
|
289
315
|
}
|
|
290
316
|
|
|
291
317
|
// triggered callback if defined
|
|
@@ -307,20 +333,20 @@ let globalFloatingCounter = 0;
|
|
|
307
333
|
* @param {Function} callback - fnction to execute on each element
|
|
308
334
|
* @param {object} [thisArg] - value to use as this(i.e reference Object) when executing callback.
|
|
309
335
|
* @example
|
|
310
|
-
* // iterate through all children of
|
|
311
|
-
*
|
|
336
|
+
* // iterate through all children of this container
|
|
337
|
+
* container.forEach((child) => {
|
|
312
338
|
* // do something with the child
|
|
313
339
|
* child.doSomething();
|
|
314
340
|
* });
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
341
|
+
* container.forEach((child, index) => { ... });
|
|
342
|
+
* container.forEach((child, index, array) => { ... });
|
|
343
|
+
* container.forEach((child, index, array) => { ... }, thisArg);
|
|
318
344
|
*/
|
|
319
345
|
forEach(callback, thisArg) {
|
|
320
|
-
|
|
321
|
-
|
|
346
|
+
let context = this, i = 0;
|
|
347
|
+
let children = this.getChildren();
|
|
322
348
|
|
|
323
|
-
|
|
349
|
+
let len = children.length;
|
|
324
350
|
|
|
325
351
|
if (typeof callback !== "function") {
|
|
326
352
|
throw new Error(callback + " is not a function");
|
|
@@ -342,12 +368,12 @@ let globalFloatingCounter = 0;
|
|
|
342
368
|
* @param {Renderable} child2
|
|
343
369
|
*/
|
|
344
370
|
swapChildren(child, child2) {
|
|
345
|
-
|
|
346
|
-
|
|
371
|
+
let index = this.getChildIndex(child);
|
|
372
|
+
let index2 = this.getChildIndex(child2);
|
|
347
373
|
|
|
348
374
|
if ((index !== -1) && (index2 !== -1)) {
|
|
349
375
|
// swap z index
|
|
350
|
-
|
|
376
|
+
let _z = child.pos.z;
|
|
351
377
|
child.pos.z = child2.pos.z;
|
|
352
378
|
child2.pos.z = _z;
|
|
353
379
|
// swap the positions..
|
|
@@ -390,7 +416,7 @@ let globalFloatingCounter = 0;
|
|
|
390
416
|
* @returns {Renderable} child
|
|
391
417
|
*/
|
|
392
418
|
getNextChild(child) {
|
|
393
|
-
|
|
419
|
+
let index = this.getChildren().indexOf(child) - 1;
|
|
394
420
|
if (index >= 0 && index < this.getChildren().length) {
|
|
395
421
|
return this.getChildAt(index);
|
|
396
422
|
}
|
|
@@ -415,27 +441,27 @@ let globalFloatingCounter = 0;
|
|
|
415
441
|
* @returns {Renderable[]} Array of childs
|
|
416
442
|
* @example
|
|
417
443
|
* // get the first child object called "mainPlayer" in a specific container :
|
|
418
|
-
*
|
|
444
|
+
* let ent = myContainer.getChildByProp("name", "mainPlayer");
|
|
419
445
|
*
|
|
420
446
|
* // or query the whole world :
|
|
421
|
-
*
|
|
447
|
+
* let ent = container.getChildByProp("name", "mainPlayer");
|
|
422
448
|
*
|
|
423
449
|
* // partial property matches are also allowed by using a RegExp.
|
|
424
450
|
* // the following matches "redCOIN", "bluecoin", "bagOfCoins", etc :
|
|
425
|
-
*
|
|
451
|
+
* let allCoins = container.getChildByProp("name", /coin/i);
|
|
426
452
|
*
|
|
427
453
|
* // searching for numbers or other data types :
|
|
428
|
-
*
|
|
429
|
-
*
|
|
454
|
+
* let zIndex10 = container.getChildByProp("z", 10);
|
|
455
|
+
* let inViewport = container.getChildByProp("inViewport", true);
|
|
430
456
|
*/
|
|
431
457
|
getChildByProp(prop, value) {
|
|
432
|
-
|
|
458
|
+
let objList = [];
|
|
433
459
|
|
|
434
460
|
/**
|
|
435
461
|
* @ignore
|
|
436
462
|
*/
|
|
437
463
|
function compare(obj, prop) {
|
|
438
|
-
|
|
464
|
+
let v = obj[prop];
|
|
439
465
|
if (value instanceof RegExp && typeof(v) === "string") {
|
|
440
466
|
if (value.test(v)) {
|
|
441
467
|
objList.push(obj);
|
|
@@ -462,7 +488,7 @@ let globalFloatingCounter = 0;
|
|
|
462
488
|
* @returns {Renderable[]} Array of children
|
|
463
489
|
*/
|
|
464
490
|
getChildByType(classType) {
|
|
465
|
-
|
|
491
|
+
let objList = [];
|
|
466
492
|
|
|
467
493
|
this.forEach((child) => {
|
|
468
494
|
if (child instanceof classType) {
|
|
@@ -496,7 +522,7 @@ let globalFloatingCounter = 0;
|
|
|
496
522
|
* @returns {Renderable} corresponding child or null
|
|
497
523
|
*/
|
|
498
524
|
getChildByGUID(guid) {
|
|
499
|
-
|
|
525
|
+
let obj = this.getChildByProp("GUID", guid);
|
|
500
526
|
return (obj.length > 0) ? obj[0] : null;
|
|
501
527
|
}
|
|
502
528
|
|
|
@@ -518,7 +544,7 @@ let globalFloatingCounter = 0;
|
|
|
518
544
|
* @returns {Bounds} this shape bounding box Rectangle object
|
|
519
545
|
*/
|
|
520
546
|
updateBounds(absolute = true) {
|
|
521
|
-
|
|
547
|
+
let bounds = this.getBounds();
|
|
522
548
|
|
|
523
549
|
// call parent method
|
|
524
550
|
super.updateBounds(absolute);
|
|
@@ -526,7 +552,7 @@ let globalFloatingCounter = 0;
|
|
|
526
552
|
if (this.enableChildBoundsUpdate === true) {
|
|
527
553
|
this.forEach((child) => {
|
|
528
554
|
if (child.isRenderable) {
|
|
529
|
-
|
|
555
|
+
let childBounds = child.getBounds();
|
|
530
556
|
if (childBounds.isFinite()) {
|
|
531
557
|
bounds.addBounds(childBounds);
|
|
532
558
|
}
|
|
@@ -538,14 +564,13 @@ let globalFloatingCounter = 0;
|
|
|
538
564
|
|
|
539
565
|
/**
|
|
540
566
|
* Checks if this container is root or if it's attached to the root container.
|
|
541
|
-
* @private
|
|
542
567
|
* @returns {boolean}
|
|
543
568
|
*/
|
|
544
569
|
isAttachedToRoot() {
|
|
545
570
|
if (this.root === true) {
|
|
546
571
|
return true;
|
|
547
572
|
} else {
|
|
548
|
-
|
|
573
|
+
let ancestor = this.ancestor;
|
|
549
574
|
while (ancestor) {
|
|
550
575
|
if (ancestor.root === true) {
|
|
551
576
|
return true;
|
|
@@ -556,6 +581,25 @@ let globalFloatingCounter = 0;
|
|
|
556
581
|
}
|
|
557
582
|
}
|
|
558
583
|
|
|
584
|
+
/**
|
|
585
|
+
* Returns the instance of the root container (i.e. the current application World container).
|
|
586
|
+
* @returns {Container}
|
|
587
|
+
*/
|
|
588
|
+
getRootAncestor() {
|
|
589
|
+
if (this.root === true) {
|
|
590
|
+
return this;
|
|
591
|
+
} else {
|
|
592
|
+
let ancestor = this.ancestor;
|
|
593
|
+
while (ancestor) {
|
|
594
|
+
if (ancestor.root === true) {
|
|
595
|
+
break;
|
|
596
|
+
}
|
|
597
|
+
ancestor = ancestor.ancestor;
|
|
598
|
+
}
|
|
599
|
+
return ancestor;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
559
603
|
/**
|
|
560
604
|
* update the cointainer's bounding rect (private)
|
|
561
605
|
* @ignore
|
|
@@ -617,7 +661,7 @@ let globalFloatingCounter = 0;
|
|
|
617
661
|
// remove the body first to avoid a condition where a body can be detached
|
|
618
662
|
// from its parent, before the body is removed from the game world
|
|
619
663
|
if (child.body instanceof Body) {
|
|
620
|
-
|
|
664
|
+
this.getRootAncestor().removeBody(child.body);
|
|
621
665
|
}
|
|
622
666
|
|
|
623
667
|
if (!keepalive) {
|
|
@@ -632,7 +676,7 @@ let globalFloatingCounter = 0;
|
|
|
632
676
|
|
|
633
677
|
// Don't cache the child index; another element might have been removed
|
|
634
678
|
// by the child's `onDeactivateEvent` or `destroy` methods
|
|
635
|
-
|
|
679
|
+
let childIndex = this.getChildIndex(child);
|
|
636
680
|
if (childIndex >= 0) {
|
|
637
681
|
this.getChildren().splice(childIndex, 1);
|
|
638
682
|
child.ancestor = undefined;
|
|
@@ -640,7 +684,7 @@ let globalFloatingCounter = 0;
|
|
|
640
684
|
|
|
641
685
|
// force repaint in case this is a static non-animated object
|
|
642
686
|
if (this.isAttachedToRoot() === true) {
|
|
643
|
-
|
|
687
|
+
this.isDirty = true;
|
|
644
688
|
}
|
|
645
689
|
|
|
646
690
|
// force bounds update if required
|
|
@@ -673,7 +717,7 @@ let globalFloatingCounter = 0;
|
|
|
673
717
|
* @param {Renderable} child
|
|
674
718
|
*/
|
|
675
719
|
moveUp(child) {
|
|
676
|
-
|
|
720
|
+
let childIndex = this.getChildIndex(child);
|
|
677
721
|
if (childIndex - 1 >= 0) {
|
|
678
722
|
// note : we use an inverted loop
|
|
679
723
|
this.swapChildren(child, this.getChildAt(childIndex - 1));
|
|
@@ -687,7 +731,7 @@ let globalFloatingCounter = 0;
|
|
|
687
731
|
* @param {Renderable} child
|
|
688
732
|
*/
|
|
689
733
|
moveDown(child) {
|
|
690
|
-
|
|
734
|
+
let childIndex = this.getChildIndex(child);
|
|
691
735
|
if (childIndex >= 0 && (childIndex + 1) < this.getChildren().length) {
|
|
692
736
|
// note : we use an inverted loop
|
|
693
737
|
this.swapChildren(child, this.getChildAt(childIndex + 1));
|
|
@@ -701,9 +745,9 @@ let globalFloatingCounter = 0;
|
|
|
701
745
|
* @param {Renderable} child
|
|
702
746
|
*/
|
|
703
747
|
moveToTop(child) {
|
|
704
|
-
|
|
748
|
+
let childIndex = this.getChildIndex(child);
|
|
705
749
|
if (childIndex > 0) {
|
|
706
|
-
|
|
750
|
+
let children = this.getChildren();
|
|
707
751
|
// note : we use an inverted loop
|
|
708
752
|
children.splice(0, 0, children.splice(childIndex, 1)[0]);
|
|
709
753
|
// increment our child z value based on the previous child depth
|
|
@@ -718,8 +762,8 @@ let globalFloatingCounter = 0;
|
|
|
718
762
|
* @param {Renderable} child
|
|
719
763
|
*/
|
|
720
764
|
moveToBottom(child) {
|
|
721
|
-
|
|
722
|
-
|
|
765
|
+
let childIndex = this.getChildIndex(child);
|
|
766
|
+
let children = this.getChildren();
|
|
723
767
|
if (childIndex >= 0 && childIndex < (children.length - 1)) {
|
|
724
768
|
// note : we use an inverted loop
|
|
725
769
|
children.splice((children.length - 1), 0, children.splice(childIndex, 1)[0]);
|
|
@@ -753,7 +797,7 @@ let globalFloatingCounter = 0;
|
|
|
753
797
|
// clear the defer id
|
|
754
798
|
this.pendingSort = null;
|
|
755
799
|
// make sure we redraw everything
|
|
756
|
-
|
|
800
|
+
this.isDirty = true;
|
|
757
801
|
}, this);
|
|
758
802
|
}
|
|
759
803
|
}
|
|
@@ -793,7 +837,7 @@ let globalFloatingCounter = 0;
|
|
|
793
837
|
if (!b.pos || !a.pos) {
|
|
794
838
|
return (a.pos ? -Infinity : Infinity);
|
|
795
839
|
}
|
|
796
|
-
|
|
840
|
+
let result = b.pos.z - a.pos.z;
|
|
797
841
|
return (result ? result : (b.pos.x - a.pos.x));
|
|
798
842
|
}
|
|
799
843
|
|
|
@@ -805,7 +849,7 @@ let globalFloatingCounter = 0;
|
|
|
805
849
|
if (!b.pos || !a.pos) {
|
|
806
850
|
return (a.pos ? -Infinity : Infinity);
|
|
807
851
|
}
|
|
808
|
-
|
|
852
|
+
let result = b.pos.z - a.pos.z;
|
|
809
853
|
return (result ? result : (b.pos.y - a.pos.y));
|
|
810
854
|
}
|
|
811
855
|
|
|
@@ -822,17 +866,17 @@ let globalFloatingCounter = 0;
|
|
|
822
866
|
|
|
823
867
|
/**
|
|
824
868
|
* container update function. <br>
|
|
825
|
-
* automatically called by the
|
|
869
|
+
* automatically called by the application update loop {@link Application}
|
|
826
870
|
* @protected
|
|
827
871
|
* @param {number} dt - time since the last update in milliseconds.
|
|
828
872
|
* @returns {boolean} true if the Container is dirty
|
|
829
873
|
*/
|
|
830
874
|
update(dt) {
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
875
|
+
let isFloating = false;
|
|
876
|
+
let isPaused = state.isPaused();
|
|
877
|
+
let children = this.getChildren();
|
|
834
878
|
|
|
835
|
-
for (
|
|
879
|
+
for (let i = children.length, obj; i--, (obj = children[i]);) {
|
|
836
880
|
if (isPaused && (!obj.updateWhenPaused)) {
|
|
837
881
|
// skip this object
|
|
838
882
|
continue;
|
|
@@ -877,8 +921,8 @@ let globalFloatingCounter = 0;
|
|
|
877
921
|
* @param {Camera2d} [viewport] - the viewport to (re)draw
|
|
878
922
|
*/
|
|
879
923
|
draw(renderer, viewport) {
|
|
880
|
-
|
|
881
|
-
|
|
924
|
+
let isFloating = false;
|
|
925
|
+
let bounds = this.getBounds();
|
|
882
926
|
|
|
883
927
|
this.drawCount = 0;
|
|
884
928
|
|
|
@@ -900,8 +944,8 @@ let globalFloatingCounter = 0;
|
|
|
900
944
|
renderer.clearColor(this.backgroundColor);
|
|
901
945
|
}
|
|
902
946
|
|
|
903
|
-
|
|
904
|
-
for (
|
|
947
|
+
let children = this.getChildren();
|
|
948
|
+
for (let i = children.length, obj; i--, (obj = children[i]);) {
|
|
905
949
|
if (obj.isRenderable) {
|
|
906
950
|
|
|
907
951
|
isFloating = obj.floating === true;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.1.1
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -43,10 +43,10 @@ class Draggable extends Renderable {
|
|
|
43
43
|
* @private
|
|
44
44
|
*/
|
|
45
45
|
initEvents() {
|
|
46
|
-
registerPointerEvent("pointerdown", this, (e) =>
|
|
47
|
-
registerPointerEvent("pointerup", this, (e) =>
|
|
48
|
-
registerPointerEvent("pointercancel", this, (e) =>
|
|
49
|
-
on(POINTERMOVE, this.dragMove
|
|
46
|
+
registerPointerEvent("pointerdown", this, (e) => emit(DRAGSTART, e, this));
|
|
47
|
+
registerPointerEvent("pointerup", this, (e) => emit(DRAGEND, e, this));
|
|
48
|
+
registerPointerEvent("pointercancel", this, (e) => emit(DRAGEND, e, this));
|
|
49
|
+
on(POINTERMOVE, (e) => this.dragMove(e));
|
|
50
50
|
on(DRAGSTART, (e, draggable) => {
|
|
51
51
|
if (draggable === this) {
|
|
52
52
|
this.dragStart(e);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.1.1
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -189,7 +189,7 @@ import { isNumeric } from '../utils/string.js';
|
|
|
189
189
|
* @ignore
|
|
190
190
|
*/
|
|
191
191
|
updateLayer(vpos) {
|
|
192
|
-
|
|
192
|
+
const rx = this.ratio.x,
|
|
193
193
|
ry = this.ratio.y;
|
|
194
194
|
|
|
195
195
|
if (rx === 0 && ry === 0) {
|
|
@@ -197,7 +197,7 @@ import { isNumeric } from '../utils/string.js';
|
|
|
197
197
|
return;
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
|
|
200
|
+
const width = this.width,
|
|
201
201
|
height = this.height,
|
|
202
202
|
bw = game.viewport.bounds.width,
|
|
203
203
|
bh = game.viewport.bounds.height,
|
|
@@ -263,13 +263,14 @@ import { isNumeric } from '../utils/string.js';
|
|
|
263
263
|
* @param {Camera2d} [viewport] - the viewport to (re)draw
|
|
264
264
|
*/
|
|
265
265
|
draw(renderer, viewport) {
|
|
266
|
-
|
|
266
|
+
const width = this.width,
|
|
267
267
|
height = this.height,
|
|
268
268
|
bw = viewport.bounds.width,
|
|
269
269
|
bh = viewport.bounds.height,
|
|
270
270
|
ax = this.anchorPoint.x,
|
|
271
|
-
ay = this.anchorPoint.y
|
|
272
|
-
|
|
271
|
+
ay = this.anchorPoint.y;
|
|
272
|
+
|
|
273
|
+
let x = this.pos.x,
|
|
273
274
|
y = this.pos.y;
|
|
274
275
|
|
|
275
276
|
if (this.ratio.x === 0 && this.ratio.y === 0) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.1.1
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -10,16 +10,16 @@ import Renderable from './renderable.js';
|
|
|
10
10
|
|
|
11
11
|
/** @ignore */
|
|
12
12
|
function createGradient(light) {
|
|
13
|
-
|
|
13
|
+
let context = light.texture.context;
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
let x1 = light.texture.width / 2,
|
|
16
16
|
y1 = light.texture.height / 2;
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
let radiusX = light.radiusX,
|
|
19
19
|
radiusY = light.radiusY;
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
let scaleX, scaleY, invScaleX, invScaleY;
|
|
22
|
+
let gradient;
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
light.texture.clear();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.1.1
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -93,18 +93,18 @@ import Sprite from './sprite.js';
|
|
|
93
93
|
*/
|
|
94
94
|
draw(renderer) {
|
|
95
95
|
// the frame to draw
|
|
96
|
-
|
|
96
|
+
let frame = this.current;
|
|
97
97
|
|
|
98
98
|
// cache the current position and size
|
|
99
|
-
|
|
99
|
+
let dx = this.pos.x,
|
|
100
100
|
dy = this.pos.y;
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
let w = frame.width,
|
|
103
103
|
h = frame.height;
|
|
104
104
|
|
|
105
105
|
// frame offset in the texture/atlas
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
let frame_offset = frame.offset;
|
|
107
|
+
let g_offset = this.offset;
|
|
108
108
|
|
|
109
109
|
|
|
110
110
|
// remove image's TexturePacker/ShoeBox rotation
|
|
@@ -116,11 +116,11 @@ import Sprite from './sprite.js';
|
|
|
116
116
|
h = frame.width;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
let sx = g_offset.x + frame_offset.x,
|
|
120
120
|
sy = g_offset.y + frame_offset.y;
|
|
121
121
|
|
|
122
122
|
// should this be configurable ?
|
|
123
|
-
|
|
123
|
+
let corner_width = this.insetx || w / 4,
|
|
124
124
|
corner_height = this.insety || h / 4;
|
|
125
125
|
|
|
126
126
|
// OPTIMIZE ME !
|
|
@@ -170,11 +170,11 @@ import Sprite from './sprite.js';
|
|
|
170
170
|
|
|
171
171
|
|
|
172
172
|
// DRAW SIDES and CENTER
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
let image_center_width = w - (corner_width << 1);
|
|
174
|
+
let image_center_height = h - (corner_height << 1);
|
|
175
175
|
|
|
176
|
-
|
|
177
|
-
|
|
176
|
+
let target_center_width = this.nss_width - (corner_width << 1);
|
|
177
|
+
let target_center_height = this.nss_height - (corner_height << 1);
|
|
178
178
|
|
|
179
179
|
//Top center
|
|
180
180
|
renderer.drawImage(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.1.1
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -433,11 +433,11 @@ import { releaseAllPointerEvents } from '../input/pointerevent.js';
|
|
|
433
433
|
* @returns {number} angle in radians
|
|
434
434
|
*/
|
|
435
435
|
angleTo(target) {
|
|
436
|
-
|
|
437
|
-
|
|
436
|
+
let a = this.getBounds();
|
|
437
|
+
let ax, ay;
|
|
438
438
|
|
|
439
439
|
if (target instanceof Renderable) {
|
|
440
|
-
|
|
440
|
+
let b = target.getBounds();
|
|
441
441
|
ax = b.centerX - a.centerX;
|
|
442
442
|
ay = b.centerY - a.centerY;
|
|
443
443
|
} else { // vector object
|
|
@@ -454,11 +454,11 @@ import { releaseAllPointerEvents } from '../input/pointerevent.js';
|
|
|
454
454
|
* @returns {number} distance
|
|
455
455
|
*/
|
|
456
456
|
distanceTo(target) {
|
|
457
|
-
|
|
458
|
-
|
|
457
|
+
let a = this.getBounds();
|
|
458
|
+
let dx, dy;
|
|
459
459
|
|
|
460
460
|
if (target instanceof Renderable) {
|
|
461
|
-
|
|
461
|
+
let b = target.getBounds();
|
|
462
462
|
dx = a.centerX - b.centerX;
|
|
463
463
|
dy = a.centerY - b.centerY;
|
|
464
464
|
} else { // vector object
|
|
@@ -475,7 +475,7 @@ import { releaseAllPointerEvents } from '../input/pointerevent.js';
|
|
|
475
475
|
* @returns {Renderable} Reference to this object for method chaining
|
|
476
476
|
*/
|
|
477
477
|
lookAt(target) {
|
|
478
|
-
|
|
478
|
+
let position;
|
|
479
479
|
|
|
480
480
|
if (target instanceof Renderable) {
|
|
481
481
|
position = target.pos;
|
|
@@ -483,7 +483,7 @@ import { releaseAllPointerEvents } from '../input/pointerevent.js';
|
|
|
483
483
|
position = target;
|
|
484
484
|
}
|
|
485
485
|
|
|
486
|
-
|
|
486
|
+
let angle = this.angleTo(position);
|
|
487
487
|
|
|
488
488
|
this.rotate(angle);
|
|
489
489
|
|
|
@@ -548,7 +548,7 @@ import { releaseAllPointerEvents } from '../input/pointerevent.js';
|
|
|
548
548
|
*/
|
|
549
549
|
updateBounds(absolute = true) {
|
|
550
550
|
if (this.isRenderable) {
|
|
551
|
-
|
|
551
|
+
let bounds = this.getBounds();
|
|
552
552
|
|
|
553
553
|
bounds.clear();
|
|
554
554
|
|
|
@@ -646,7 +646,7 @@ import { releaseAllPointerEvents } from '../input/pointerevent.js';
|
|
|
646
646
|
* @param {CanvasRenderer|WebGLRenderer} renderer - a renderer object
|
|
647
647
|
*/
|
|
648
648
|
preDraw(renderer) {
|
|
649
|
-
|
|
649
|
+
let ax = this.width * this.anchorPoint.x,
|
|
650
650
|
ay = this.height * this.anchorPoint.y;
|
|
651
651
|
|
|
652
652
|
// save renderer context
|