melonjs 14.4.0 → 15.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/LICENSE.md +1 -1
- package/README.md +13 -57
- 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 +1 -1
- 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 +1 -1
- package/dist/melonjs.mjs/application/header.js +1 -1
- package/dist/melonjs.mjs/application/resize.js +1 -1
- package/dist/melonjs.mjs/application/settings.js +1 -1
- package/dist/melonjs.mjs/audio/audio.js +5 -7
- package/dist/melonjs.mjs/camera/camera2d.js +1 -1
- package/dist/melonjs.mjs/const.js +1 -1
- package/dist/melonjs.mjs/entity/entity.js +43 -9
- package/dist/melonjs.mjs/geometries/ellipse.js +2 -3
- package/dist/melonjs.mjs/geometries/line.js +1 -1
- package/dist/melonjs.mjs/geometries/path2d.js +20 -44
- package/dist/melonjs.mjs/geometries/point.js +1 -6
- package/dist/melonjs.mjs/geometries/poly.js +2 -5
- package/dist/melonjs.mjs/geometries/rectangle.js +13 -9
- package/dist/melonjs.mjs/geometries/roundrect.js +1 -1
- package/dist/melonjs.mjs/index.js +10 -6
- package/dist/melonjs.mjs/input/gamepad.js +10 -16
- package/dist/melonjs.mjs/input/input.js +1 -1
- package/dist/melonjs.mjs/input/keyboard.js +1 -1
- package/dist/melonjs.mjs/input/pointer.js +1 -1
- package/dist/melonjs.mjs/input/pointerevent.js +3 -17
- package/dist/melonjs.mjs/lang/console.js +1 -1
- package/dist/melonjs.mjs/lang/deprecated.js +1 -1
- package/dist/melonjs.mjs/level/level.js +3 -3
- package/dist/melonjs.mjs/level/tiled/TMXGroup.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXLayer.js +1 -8
- package/dist/melonjs.mjs/level/tiled/TMXObject.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXTile.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +8 -4
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +5 -5
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +1 -1
- package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +1 -1
- package/dist/melonjs.mjs/loader/cache.js +24 -0
- package/dist/melonjs.mjs/loader/loader.js +331 -716
- package/dist/melonjs.mjs/loader/loadingscreen.js +4 -4
- package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
- package/dist/melonjs.mjs/loader/parser.js +281 -0
- package/dist/melonjs.mjs/loader/settings.js +91 -0
- package/dist/melonjs.mjs/math/color.js +9 -8
- package/dist/melonjs.mjs/math/math.js +1 -1
- package/dist/melonjs.mjs/math/matrix2.js +7 -9
- package/dist/melonjs.mjs/math/matrix3.js +18 -21
- package/dist/melonjs.mjs/math/observable_vector2.js +3 -3
- package/dist/melonjs.mjs/math/observable_vector3.js +3 -4
- package/dist/melonjs.mjs/math/vector2.js +3 -3
- package/dist/melonjs.mjs/math/vector3.js +3 -4
- 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 +1 -1
- package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +1 -1
- package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +1 -1
- package/dist/melonjs.mjs/particles/emitter.js +3 -3
- package/dist/melonjs.mjs/particles/particle.js +1 -1
- package/dist/melonjs.mjs/particles/settings.js +1 -1
- package/dist/melonjs.mjs/physics/body.js +18 -14
- package/dist/melonjs.mjs/physics/bounds.js +18 -70
- package/dist/melonjs.mjs/physics/collision.js +1 -1
- package/dist/melonjs.mjs/physics/detector.js +1 -1
- package/dist/melonjs.mjs/physics/quadtree.js +1 -1
- package/dist/melonjs.mjs/physics/response.js +1 -1
- package/dist/melonjs.mjs/physics/sat.js +1 -1
- package/dist/melonjs.mjs/physics/world.js +1 -1
- package/dist/melonjs.mjs/plugin/plugin.js +3 -3
- package/dist/melonjs.mjs/renderable/collectable.js +1 -1
- package/dist/melonjs.mjs/renderable/colorlayer.js +1 -1
- package/dist/melonjs.mjs/renderable/container.js +25 -19
- package/dist/melonjs.mjs/renderable/dragndrop.js +1 -1
- package/dist/melonjs.mjs/renderable/imagelayer.js +7 -1
- package/dist/melonjs.mjs/renderable/light2d.js +1 -1
- package/dist/melonjs.mjs/renderable/nineslicesprite.js +1 -1
- package/dist/melonjs.mjs/renderable/renderable.js +148 -105
- package/dist/melonjs.mjs/renderable/sprite.js +33 -54
- package/dist/melonjs.mjs/renderable/trigger.js +1 -1
- package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +1 -1
- package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +1 -1
- package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +1 -3
- package/dist/melonjs.mjs/state/stage.js +1 -1
- package/dist/melonjs.mjs/state/state.js +2 -2
- 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 +1 -1
- package/dist/melonjs.mjs/system/platform.js +1 -1
- package/dist/melonjs.mjs/system/pooling.js +8 -18
- package/dist/melonjs.mjs/system/save.js +1 -1
- package/dist/melonjs.mjs/system/timer.js +1 -1
- package/dist/melonjs.mjs/text/bitmaptext.js +66 -8
- package/dist/melonjs.mjs/text/bitmaptextdata.js +1 -1
- package/dist/melonjs.mjs/text/glyph.js +1 -1
- package/dist/melonjs.mjs/text/text.js +56 -86
- package/dist/melonjs.mjs/text/textmetrics.js +1 -1
- package/dist/melonjs.mjs/text/textstyle.js +4 -6
- package/dist/melonjs.mjs/tweens/easing.js +1 -1
- package/dist/melonjs.mjs/tweens/interpolation.js +1 -1
- package/dist/melonjs.mjs/tweens/tween.js +1 -1
- package/dist/melonjs.mjs/utils/agent.js +1 -1
- package/dist/melonjs.mjs/utils/array.js +1 -1
- package/dist/melonjs.mjs/utils/file.js +1 -1
- package/dist/melonjs.mjs/utils/function.js +1 -1
- package/dist/melonjs.mjs/utils/string.js +2 -2
- package/dist/melonjs.mjs/utils/utils.js +2 -4
- package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +7 -11
- package/dist/melonjs.mjs/video/renderer.js +2 -13
- package/dist/melonjs.mjs/video/texture/atlas.js +12 -17
- package/dist/melonjs.mjs/video/texture/cache.js +3 -3
- package/dist/melonjs.mjs/video/texture/canvas_texture.js +1 -1
- 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 +21 -17
- package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +235 -0
- package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +77 -0
- package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +249 -0
- package/dist/melonjs.mjs/video/webgl/{webgl_compositor.js → compositors/webgl_compositor.js} +20 -205
- package/dist/melonjs.mjs/video/webgl/glshader.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +2 -2
- package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +2 -2
- package/dist/melonjs.mjs/video/webgl/utils/attributes.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/precision.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/program.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/string.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +1 -1
- package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +139 -149
- package/dist/melonjs.module.js +26320 -26376
- package/dist/types/entity/entity.d.ts +3 -3
- package/dist/types/geometries/path2d.d.ts +5 -31
- package/dist/types/geometries/point.d.ts +2 -7
- package/dist/types/geometries/poly.d.ts +0 -1
- package/dist/types/index.d.ts +5 -3
- package/dist/types/loader/cache.d.ts +7 -0
- package/dist/types/loader/loader.d.ts +166 -181
- package/dist/types/loader/parser.d.ts +41 -0
- package/dist/types/loader/settings.d.ts +57 -0
- package/dist/types/particles/emitter.d.ts +4 -4
- package/dist/types/physics/bounds.d.ts +29 -84
- package/dist/types/renderable/container.d.ts +0 -11
- package/dist/types/renderable/renderable.d.ts +43 -31
- package/dist/types/renderable/sprite.d.ts +3 -3
- package/dist/types/renderable/ui/uitextbutton.d.ts +0 -1
- package/dist/types/state/state.d.ts +1 -1
- package/dist/types/system/pooling.d.ts +2 -2
- package/dist/types/text/text.d.ts +6 -20
- package/dist/types/text/textstyle.d.ts +1 -1
- package/dist/types/video/canvas/canvas_renderer.d.ts +0 -5
- package/dist/types/video/renderer.d.ts +1 -5
- package/dist/types/video/webgl/buffer/vertex.d.ts +3 -3
- package/dist/types/video/webgl/compositors/compositor.d.ts +107 -0
- package/dist/types/video/webgl/compositors/primitive_compositor.d.ts +22 -0
- package/dist/types/video/webgl/compositors/quad_compositor.d.ts +72 -0
- package/dist/types/video/webgl/compositors/webgl_compositor.d.ts +86 -0
- package/dist/types/video/webgl/webgl_compositor.d.ts +2 -3
- package/dist/types/video/webgl/webgl_renderer.d.ts +34 -28
- package/package.json +18 -18
- package/src/audio/audio.js +4 -6
- package/src/entity/entity.js +42 -8
- package/src/geometries/ellipse.js +1 -2
- package/src/geometries/path2d.js +19 -43
- package/src/geometries/point.js +0 -5
- package/src/geometries/poly.js +1 -4
- package/src/geometries/rectangle.js +12 -8
- package/src/index.js +7 -3
- package/src/input/gamepad.js +9 -15
- package/src/input/pointerevent.js +1 -15
- package/src/level/level.js +2 -2
- package/src/level/tiled/TMXLayer.js +0 -7
- package/src/level/tiled/TMXTileMap.js +7 -3
- package/src/level/tiled/TMXTileset.js +4 -4
- package/src/loader/cache.js +16 -0
- package/src/loader/loader.js +339 -711
- package/src/loader/loadingscreen.js +3 -3
- package/src/loader/parser.js +279 -0
- package/src/loader/settings.js +85 -0
- package/src/math/color.js +8 -7
- package/src/math/matrix2.js +6 -8
- package/src/math/matrix3.js +17 -20
- package/src/math/observable_vector2.js +2 -2
- package/src/math/observable_vector3.js +2 -3
- package/src/math/vector2.js +2 -2
- package/src/math/vector3.js +2 -3
- package/src/particles/emitter.js +2 -2
- package/src/physics/body.js +17 -13
- package/src/physics/bounds.js +17 -69
- package/src/polyfill/index.js +0 -2
- package/src/renderable/container.js +24 -18
- package/src/renderable/imagelayer.js +6 -0
- package/src/renderable/renderable.js +147 -104
- package/src/renderable/sprite.js +32 -53
- package/src/renderable/ui/uitextbutton.js +0 -2
- package/src/state/state.js +1 -1
- package/src/system/device.js +1 -1
- package/src/system/pooling.js +7 -17
- package/src/text/bitmaptext.js +65 -7
- package/src/text/text.js +55 -85
- package/src/text/textstyle.js +3 -5
- package/src/utils/string.js +1 -1
- package/src/utils/utils.js +1 -3
- package/src/video/canvas/canvas_renderer.js +5 -9
- package/src/video/renderer.js +0 -11
- package/src/video/texture/atlas.js +11 -16
- package/src/video/texture/cache.js +2 -2
- package/src/video/video.js +1 -1
- package/src/video/webgl/buffer/vertex.js +20 -16
- package/src/video/webgl/compositors/compositor.js +226 -0
- package/src/video/webgl/compositors/primitive_compositor.js +68 -0
- package/src/video/webgl/compositors/quad_compositor.js +240 -0
- package/src/video/webgl/shaders/primitive.vert +2 -5
- package/src/video/webgl/shaders/quad.vert +3 -1
- package/src/video/webgl/webgl_renderer.js +137 -147
- package/dist/melonjs.mjs/_virtual/make-built-in.js +0 -10
- package/dist/melonjs.mjs/_virtual/object-define-property.js +0 -10
- package/dist/melonjs.mjs/_virtual/object-get-own-property-descriptor.js +0 -10
- package/dist/melonjs.mjs/_virtual/object-get-own-property-names.js +0 -10
- package/dist/melonjs.mjs/_virtual/object-get-own-property-symbols.js +0 -10
- package/dist/melonjs.mjs/_virtual/object-property-is-enumerable.js +0 -10
- package/dist/melonjs.mjs/_virtual/shared.js +0 -10
- package/dist/melonjs.mjs/game.js +0 -29
- package/dist/melonjs.mjs/polyfill/console.js +0 -18
- package/dist/melonjs.mjs/polyfill/performance.js +0 -27
- package/dist/melonjs.mjs/polyfill/requestAnimationFrame.js +0 -46
- package/dist/melonjs.mjs/polyfill/roundrect.js +0 -242
- package/dist/melonjs.mjs/renderable/re_container.js +0 -1016
- package/dist/melonjs.mjs/video/utils/resize.js +0 -116
- package/src/polyfill/performance.js +0 -20
- package/src/polyfill/requestAnimationFrame.js +0 -39
- package/src/video/webgl/webgl_compositor.js +0 -486
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine -
|
|
2
|
+
* melonJS Game Engine - v15.0.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -167,7 +167,7 @@ function createDefaultParticleTexture(w = 8, h = 8) {
|
|
|
167
167
|
|
|
168
168
|
/**
|
|
169
169
|
* Launch particles from emitter constantly (e.g. for stream)
|
|
170
|
-
* @param {number} duration -
|
|
170
|
+
* @param {number} [duration] - time that the emitter releases particles in ms
|
|
171
171
|
*/
|
|
172
172
|
streamParticles(duration) {
|
|
173
173
|
this._enabled = true;
|
|
@@ -185,7 +185,7 @@ function createDefaultParticleTexture(w = 8, h = 8) {
|
|
|
185
185
|
|
|
186
186
|
/**
|
|
187
187
|
* Launch all particles from emitter and stop (e.g. for explosion)
|
|
188
|
-
* @param {number} total -
|
|
188
|
+
* @param {number} [total] - number of particles to launch
|
|
189
189
|
*/
|
|
190
190
|
burstParticles(total) {
|
|
191
191
|
this._enabled = true;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine -
|
|
2
|
+
* melonJS Game Engine - v15.0.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -565,20 +565,24 @@ import Point from '../geometries/point.js';
|
|
|
565
565
|
* @returns {Body} Reference to this object for method chaining
|
|
566
566
|
*/
|
|
567
567
|
rotate(angle, v = this.getBounds().center) {
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
shape.
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
568
|
+
if (angle !== 0) {
|
|
569
|
+
this.bounds.clear();
|
|
570
|
+
this.forEach((shape) => {
|
|
571
|
+
shape.rotate(angle, v);
|
|
572
|
+
this.bounds.addBounds(shape.getBounds());
|
|
573
|
+
/*
|
|
574
|
+
if (!(shape instanceof Ellipse)) {
|
|
575
|
+
// ellipse position is center
|
|
576
|
+
this.bounds.translate(shape.pos);
|
|
577
|
+
}
|
|
578
|
+
*/
|
|
579
|
+
});
|
|
580
|
+
/*
|
|
581
|
+
if (typeof this.onBodyUpdate === "function") {
|
|
582
|
+
this.onBodyUpdate(this);
|
|
580
583
|
}
|
|
581
|
-
|
|
584
|
+
*/
|
|
585
|
+
}
|
|
582
586
|
return this;
|
|
583
587
|
}
|
|
584
588
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine -
|
|
2
|
+
* melonJS Game Engine - v15.0.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -14,7 +14,7 @@ import Vector2d from '../math/vector2.js';
|
|
|
14
14
|
*/
|
|
15
15
|
class Bounds {
|
|
16
16
|
/**
|
|
17
|
-
* @param {Vector2d[]} [vertices] - an array of
|
|
17
|
+
* @param {Vector2d[]|Point[]} [vertices] - an array of Vector2d or Point
|
|
18
18
|
*/
|
|
19
19
|
constructor(vertices) {
|
|
20
20
|
// @ignore
|
|
@@ -39,8 +39,6 @@ import Vector2d from '../math/vector2.js';
|
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* reset the bound
|
|
42
|
-
* @name clear
|
|
43
|
-
* @memberof Bounds
|
|
44
42
|
*/
|
|
45
43
|
clear() {
|
|
46
44
|
this.setMinMax(Infinity, Infinity, -Infinity, -Infinity);
|
|
@@ -49,8 +47,6 @@ import Vector2d from '../math/vector2.js';
|
|
|
49
47
|
|
|
50
48
|
/**
|
|
51
49
|
* sets the bounds to the given min and max value
|
|
52
|
-
* @name setMinMax
|
|
53
|
-
* @memberof Bounds
|
|
54
50
|
* @param {number} minX
|
|
55
51
|
* @param {number} minY
|
|
56
52
|
* @param {number} maxX
|
|
@@ -66,10 +62,7 @@ import Vector2d from '../math/vector2.js';
|
|
|
66
62
|
|
|
67
63
|
/**
|
|
68
64
|
* x position of the bound
|
|
69
|
-
* @public
|
|
70
65
|
* @type {number}
|
|
71
|
-
* @name x
|
|
72
|
-
* @memberof Bounds
|
|
73
66
|
*/
|
|
74
67
|
get x() {
|
|
75
68
|
return this.min.x;
|
|
@@ -83,10 +76,7 @@ import Vector2d from '../math/vector2.js';
|
|
|
83
76
|
|
|
84
77
|
/**
|
|
85
78
|
* y position of the bounds
|
|
86
|
-
* @public
|
|
87
79
|
* @type {number}
|
|
88
|
-
* @name y
|
|
89
|
-
* @memberof Bounds
|
|
90
80
|
*/
|
|
91
81
|
get y() {
|
|
92
82
|
return this.min.y;
|
|
@@ -101,10 +91,7 @@ import Vector2d from '../math/vector2.js';
|
|
|
101
91
|
|
|
102
92
|
/**
|
|
103
93
|
* width of the bounds
|
|
104
|
-
* @public
|
|
105
94
|
* @type {number}
|
|
106
|
-
* @name width
|
|
107
|
-
* @memberof Bounds
|
|
108
95
|
*/
|
|
109
96
|
get width() {
|
|
110
97
|
return this.max.x - this.min.x;
|
|
@@ -116,10 +103,7 @@ import Vector2d from '../math/vector2.js';
|
|
|
116
103
|
|
|
117
104
|
/**
|
|
118
105
|
* width of the bounds
|
|
119
|
-
* @public
|
|
120
106
|
* @type {number}
|
|
121
|
-
* @name width
|
|
122
|
-
* @memberof Bounds
|
|
123
107
|
*/
|
|
124
108
|
get height() {
|
|
125
109
|
return this.max.y - this.min.y;
|
|
@@ -131,10 +115,7 @@ import Vector2d from '../math/vector2.js';
|
|
|
131
115
|
|
|
132
116
|
/**
|
|
133
117
|
* left coordinate of the bound
|
|
134
|
-
* @public
|
|
135
118
|
* @type {number}
|
|
136
|
-
* @name left
|
|
137
|
-
* @memberof Bounds
|
|
138
119
|
*/
|
|
139
120
|
get left() {
|
|
140
121
|
return this.min.x;
|
|
@@ -142,10 +123,7 @@ import Vector2d from '../math/vector2.js';
|
|
|
142
123
|
|
|
143
124
|
/**
|
|
144
125
|
* right coordinate of the bound
|
|
145
|
-
* @public
|
|
146
126
|
* @type {number}
|
|
147
|
-
* @name right
|
|
148
|
-
* @memberof Bounds
|
|
149
127
|
*/
|
|
150
128
|
get right() {
|
|
151
129
|
return this.max.x;
|
|
@@ -153,10 +131,7 @@ import Vector2d from '../math/vector2.js';
|
|
|
153
131
|
|
|
154
132
|
/**
|
|
155
133
|
* top coordinate of the bound
|
|
156
|
-
* @public
|
|
157
134
|
* @type {number}
|
|
158
|
-
* @name top
|
|
159
|
-
* @memberof Bounds
|
|
160
135
|
*/
|
|
161
136
|
get top() {
|
|
162
137
|
return this.min.y;
|
|
@@ -164,10 +139,7 @@ import Vector2d from '../math/vector2.js';
|
|
|
164
139
|
|
|
165
140
|
/**
|
|
166
141
|
* bottom coordinate of the bound
|
|
167
|
-
* @public
|
|
168
142
|
* @type {number}
|
|
169
|
-
* @name bottom
|
|
170
|
-
* @memberof Bounds
|
|
171
143
|
*/
|
|
172
144
|
get bottom() {
|
|
173
145
|
return this.max.y;
|
|
@@ -175,10 +147,7 @@ import Vector2d from '../math/vector2.js';
|
|
|
175
147
|
|
|
176
148
|
/**
|
|
177
149
|
* center position of the bound on the x axis
|
|
178
|
-
* @public
|
|
179
150
|
* @type {number}
|
|
180
|
-
* @name centerX
|
|
181
|
-
* @memberof Bounds
|
|
182
151
|
*/
|
|
183
152
|
get centerX() {
|
|
184
153
|
return this.min.x + (this.width / 2);
|
|
@@ -186,10 +155,7 @@ import Vector2d from '../math/vector2.js';
|
|
|
186
155
|
|
|
187
156
|
/**
|
|
188
157
|
* center position of the bound on the y axis
|
|
189
|
-
* @public
|
|
190
158
|
* @type {number}
|
|
191
|
-
* @name centerY
|
|
192
|
-
* @memberof Bounds
|
|
193
159
|
*/
|
|
194
160
|
get centerY() {
|
|
195
161
|
return this.min.y + (this.height / 2);
|
|
@@ -197,20 +163,25 @@ import Vector2d from '../math/vector2.js';
|
|
|
197
163
|
|
|
198
164
|
/**
|
|
199
165
|
* return the center position of the bound
|
|
200
|
-
* @public
|
|
201
166
|
* @type {Vector2d}
|
|
202
|
-
* @name center
|
|
203
|
-
* @memberof Bounds
|
|
204
167
|
*/
|
|
205
168
|
get center() {
|
|
206
169
|
return this._center.set(this.centerX, this.centerY);
|
|
207
170
|
}
|
|
208
171
|
|
|
172
|
+
/**
|
|
173
|
+
* center the bounds position around the given coordinates
|
|
174
|
+
* @param {number} x - the x coordinate around which to center this bounds
|
|
175
|
+
* @param {number} y - the y coordinate around which to center this bounds
|
|
176
|
+
*/
|
|
177
|
+
centerOn(x, y) {
|
|
178
|
+
this.shift(x - this.width / 2, y - this.height / 2);
|
|
179
|
+
return this;
|
|
180
|
+
}
|
|
181
|
+
|
|
209
182
|
/**
|
|
210
183
|
* Updates bounds using the given vertices
|
|
211
|
-
* @
|
|
212
|
-
* @memberof Bounds
|
|
213
|
-
* @param {Vector2d[]} vertices - an array of me.Vector2d points
|
|
184
|
+
* @param {Vector2d[]|Point[]} vertices - an array of Vector2d or Point
|
|
214
185
|
*/
|
|
215
186
|
update(vertices) {
|
|
216
187
|
this.add(vertices, true);
|
|
@@ -218,9 +189,7 @@ import Vector2d from '../math/vector2.js';
|
|
|
218
189
|
|
|
219
190
|
/**
|
|
220
191
|
* add the given vertices to the bounds definition.
|
|
221
|
-
* @
|
|
222
|
-
* @memberof Bounds
|
|
223
|
-
* @param {Vector2d[]} vertices - an array of me.Vector2d points
|
|
192
|
+
* @param {Vector2d[]|Point[]} vertices - an array of Vector2d or Point
|
|
224
193
|
* @param {boolean} [clear=false] - either to reset the bounds before adding the new vertices
|
|
225
194
|
*/
|
|
226
195
|
add(vertices, clear = false) {
|
|
@@ -238,8 +207,6 @@ import Vector2d from '../math/vector2.js';
|
|
|
238
207
|
|
|
239
208
|
/**
|
|
240
209
|
* add the given bounds to the bounds definition.
|
|
241
|
-
* @name addBounds
|
|
242
|
-
* @memberof Bounds
|
|
243
210
|
* @param {Bounds} bounds
|
|
244
211
|
* @param {boolean} [clear=false] - either to reset the bounds before adding the new vertices
|
|
245
212
|
*/
|
|
@@ -259,13 +226,11 @@ import Vector2d from '../math/vector2.js';
|
|
|
259
226
|
|
|
260
227
|
/**
|
|
261
228
|
* add the given point to the bounds definition.
|
|
262
|
-
* @
|
|
263
|
-
* @
|
|
264
|
-
* @param {Vector2d|Point} point - the point to be added to the bounds
|
|
265
|
-
* @param {Matrix2d} [m] - an optional transform to apply to the given point (only if the given point is a vector)
|
|
229
|
+
* @param {Vector2d|Point} point - the vector or point to be added to the bounds
|
|
230
|
+
* @param {Matrix2d} [m] - an optional transform to apply to the given point (if the given point is a Vector2d)
|
|
266
231
|
*/
|
|
267
232
|
addPoint(point, m) {
|
|
268
|
-
if ((typeof m !== "undefined")
|
|
233
|
+
if ((typeof m !== "undefined")) {
|
|
269
234
|
// only Vectors object have a rotate function
|
|
270
235
|
point = m.apply(point);
|
|
271
236
|
}
|
|
@@ -277,8 +242,6 @@ import Vector2d from '../math/vector2.js';
|
|
|
277
242
|
|
|
278
243
|
/**
|
|
279
244
|
* add the given quad coordinates to this bound definition, multiplied by the given matrix
|
|
280
|
-
* @name addFrame
|
|
281
|
-
* @memberof Bounds
|
|
282
245
|
* @param {number} x0 - left X coordinates of the quad
|
|
283
246
|
* @param {number} y0 - top Y coordinates of the quad
|
|
284
247
|
* @param {number} x1 - right X coordinates of the quad
|
|
@@ -286,9 +249,8 @@ import Vector2d from '../math/vector2.js';
|
|
|
286
249
|
* @param {Matrix2d} [m] - an optional transform to apply to the given frame coordinates
|
|
287
250
|
*/
|
|
288
251
|
addFrame(x0, y0, x1, y1, m) {
|
|
289
|
-
var v = pool.pull("
|
|
252
|
+
var v = pool.pull("Point");
|
|
290
253
|
|
|
291
|
-
// transform all points and add to the bound definition
|
|
292
254
|
this.addPoint(v.set(x0, y0), m);
|
|
293
255
|
this.addPoint(v.set(x1, y0), m);
|
|
294
256
|
this.addPoint(v.set(x0, y1), m);
|
|
@@ -307,8 +269,6 @@ import Vector2d from '../math/vector2.js';
|
|
|
307
269
|
*/
|
|
308
270
|
/**
|
|
309
271
|
* Returns true if the bounds contains the given point.
|
|
310
|
-
* @name contains
|
|
311
|
-
* @memberof Bounds
|
|
312
272
|
* @param {number} x
|
|
313
273
|
* @param {number} y
|
|
314
274
|
* @returns {boolean} True if the bounds contain the point, otherwise false
|
|
@@ -340,8 +300,6 @@ import Vector2d from '../math/vector2.js';
|
|
|
340
300
|
|
|
341
301
|
/**
|
|
342
302
|
* Returns true if the two bounds intersect.
|
|
343
|
-
* @name overlaps
|
|
344
|
-
* @memberof Bounds
|
|
345
303
|
* @param {Bounds|Rect} bounds
|
|
346
304
|
* @returns {boolean} True if the bounds overlap, otherwise false
|
|
347
305
|
*/
|
|
@@ -352,8 +310,6 @@ import Vector2d from '../math/vector2.js';
|
|
|
352
310
|
|
|
353
311
|
/**
|
|
354
312
|
* determines whether all coordinates of this bounds are finite numbers.
|
|
355
|
-
* @name isFinite
|
|
356
|
-
* @memberof Bounds
|
|
357
313
|
* @returns {boolean} false if all coordinates are positive or negative Infinity or NaN; otherwise, true.
|
|
358
314
|
*/
|
|
359
315
|
isFinite() {
|
|
@@ -369,8 +325,6 @@ import Vector2d from '../math/vector2.js';
|
|
|
369
325
|
*/
|
|
370
326
|
/**
|
|
371
327
|
* Translates the bounds by x on the x axis, and y on the y axis
|
|
372
|
-
* @name translate
|
|
373
|
-
* @memberof Bounds
|
|
374
328
|
* @param {number} x
|
|
375
329
|
* @param {number} y
|
|
376
330
|
*/
|
|
@@ -400,8 +354,6 @@ import Vector2d from '../math/vector2.js';
|
|
|
400
354
|
*/
|
|
401
355
|
/**
|
|
402
356
|
* Shifts the bounds to the given x, y position.
|
|
403
|
-
* @name shift
|
|
404
|
-
* @memberof Bounds
|
|
405
357
|
* @param {number} x
|
|
406
358
|
* @param {number} y
|
|
407
359
|
*/
|
|
@@ -429,8 +381,6 @@ import Vector2d from '../math/vector2.js';
|
|
|
429
381
|
|
|
430
382
|
/**
|
|
431
383
|
* clone this bounds
|
|
432
|
-
* @name clone
|
|
433
|
-
* @memberof Bounds
|
|
434
384
|
* @returns {Bounds}
|
|
435
385
|
*/
|
|
436
386
|
clone() {
|
|
@@ -441,8 +391,6 @@ import Vector2d from '../math/vector2.js';
|
|
|
441
391
|
|
|
442
392
|
/**
|
|
443
393
|
* Returns a polygon whose edges are the same as this bounds.
|
|
444
|
-
* @name toPolygon
|
|
445
|
-
* @memberof Bounds
|
|
446
394
|
* @returns {Polygon} a new Polygon that represents this bounds.
|
|
447
395
|
*/
|
|
448
396
|
toPolygon () {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine -
|
|
2
|
+
* melonJS Game Engine - v15.0.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -24,10 +24,10 @@ class BasePlugin {
|
|
|
24
24
|
* this can be overridden by the plugin
|
|
25
25
|
* @public
|
|
26
26
|
* @type {string}
|
|
27
|
-
* @default "
|
|
27
|
+
* @default "15.0.0"
|
|
28
28
|
* @name plugin.Base#version
|
|
29
29
|
*/
|
|
30
|
-
this.version = "
|
|
30
|
+
this.version = "15.0.0";
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine -
|
|
2
|
+
* melonJS Game Engine - v15.0.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -136,7 +136,13 @@ let globalFloatingCounter = 0;
|
|
|
136
136
|
// subscribe on the canvas resize event
|
|
137
137
|
if (this.root === true) {
|
|
138
138
|
// Workaround for not updating container child-bounds automatically (it's expensive!)
|
|
139
|
-
on(CANVAS_ONRESIZE,
|
|
139
|
+
on(CANVAS_ONRESIZE, () => {
|
|
140
|
+
// temporarly enable the enableChildBoundsUpdate flag
|
|
141
|
+
this.enableChildBoundsUpdate === true;
|
|
142
|
+
// update bounds
|
|
143
|
+
this.updateBounds();
|
|
144
|
+
this.enableChildBoundsUpdate === false;
|
|
145
|
+
});
|
|
140
146
|
}
|
|
141
147
|
}
|
|
142
148
|
|
|
@@ -196,6 +202,10 @@ let globalFloatingCounter = 0;
|
|
|
196
202
|
|
|
197
203
|
child.ancestor = this;
|
|
198
204
|
this.getChildren().push(child);
|
|
205
|
+
if (typeof child.updateBounds === "function") {
|
|
206
|
+
// update child bounds to reflect the new ancestor
|
|
207
|
+
child.updateBounds();
|
|
208
|
+
}
|
|
199
209
|
|
|
200
210
|
// set the child z value if required
|
|
201
211
|
if (typeof(child.pos) !== "undefined") {
|
|
@@ -220,8 +230,8 @@ let globalFloatingCounter = 0;
|
|
|
220
230
|
}
|
|
221
231
|
|
|
222
232
|
// force bounds update if required
|
|
223
|
-
if (this.enableChildBoundsUpdate) {
|
|
224
|
-
this.updateBounds(
|
|
233
|
+
if (this.enableChildBoundsUpdate === true) {
|
|
234
|
+
this.updateBounds();
|
|
225
235
|
}
|
|
226
236
|
|
|
227
237
|
// if a physic body is defined, add it to the game world
|
|
@@ -269,8 +279,8 @@ let globalFloatingCounter = 0;
|
|
|
269
279
|
}
|
|
270
280
|
|
|
271
281
|
// force bounds update if required
|
|
272
|
-
if (this.enableChildBoundsUpdate) {
|
|
273
|
-
this.updateBounds(
|
|
282
|
+
if (this.enableChildBoundsUpdate === true) {
|
|
283
|
+
this.updateBounds();
|
|
274
284
|
}
|
|
275
285
|
|
|
276
286
|
// if a physic body is defined, add it to the game world
|
|
@@ -504,26 +514,25 @@ let globalFloatingCounter = 0;
|
|
|
504
514
|
/**
|
|
505
515
|
* update the bounding box for this shape.
|
|
506
516
|
* @ignore
|
|
517
|
+
* @param {boolean} absolute - update the bounds size and position in (world) absolute coordinates
|
|
507
518
|
* @returns {Bounds} this shape bounding box Rectangle object
|
|
508
519
|
*/
|
|
509
|
-
updateBounds(
|
|
520
|
+
updateBounds(absolute = true) {
|
|
521
|
+
var bounds = this.getBounds();
|
|
510
522
|
|
|
511
523
|
// call parent method
|
|
512
|
-
super.updateBounds();
|
|
524
|
+
super.updateBounds(absolute);
|
|
513
525
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
if (forceUpdateChildBounds === true || this.enableChildBoundsUpdate === true) {
|
|
526
|
+
if (this.enableChildBoundsUpdate === true) {
|
|
517
527
|
this.forEach((child) => {
|
|
518
528
|
if (child.isRenderable) {
|
|
519
529
|
var childBounds = child.getBounds();
|
|
520
530
|
if (childBounds.isFinite()) {
|
|
521
|
-
bounds.addBounds(
|
|
531
|
+
bounds.addBounds(childBounds);
|
|
522
532
|
}
|
|
523
533
|
}
|
|
524
534
|
});
|
|
525
535
|
}
|
|
526
|
-
|
|
527
536
|
return bounds;
|
|
528
537
|
}
|
|
529
538
|
|
|
@@ -551,7 +560,7 @@ let globalFloatingCounter = 0;
|
|
|
551
560
|
* update the cointainer's bounding rect (private)
|
|
552
561
|
* @ignore
|
|
553
562
|
*/
|
|
554
|
-
updateBoundsPos(newX, newY) {
|
|
563
|
+
updateBoundsPos(newX = this.pos.x, newY = this.pos.y) {
|
|
555
564
|
// call the parent method
|
|
556
565
|
super.updateBoundsPos(newX, newY);
|
|
557
566
|
|
|
@@ -559,14 +568,11 @@ let globalFloatingCounter = 0;
|
|
|
559
568
|
this.forEach((child) => {
|
|
560
569
|
if (child.isRenderable) {
|
|
561
570
|
child.updateBoundsPos(
|
|
562
|
-
// workaround on this.pos being updated after
|
|
563
|
-
// the callback being triggered
|
|
564
571
|
child.pos.x + newX - this.pos.x,
|
|
565
572
|
child.pos.y + newY - this.pos.y
|
|
566
573
|
);
|
|
567
574
|
}
|
|
568
575
|
});
|
|
569
|
-
return this.getBounds();
|
|
570
576
|
}
|
|
571
577
|
|
|
572
578
|
/**
|
|
@@ -638,8 +644,8 @@ let globalFloatingCounter = 0;
|
|
|
638
644
|
}
|
|
639
645
|
|
|
640
646
|
// force bounds update if required
|
|
641
|
-
if (this.enableChildBoundsUpdate) {
|
|
642
|
-
this.updateBounds(
|
|
647
|
+
if (this.enableChildBoundsUpdate === true) {
|
|
648
|
+
this.updateBounds();
|
|
643
649
|
}
|
|
644
650
|
|
|
645
651
|
// triggered callback if defined
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine -
|
|
2
|
+
* melonJS Game Engine - v15.0.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -241,11 +241,17 @@ import { isNumeric } from '../utils/string.js';
|
|
|
241
241
|
preDraw(renderer) {
|
|
242
242
|
// save the context
|
|
243
243
|
renderer.save();
|
|
244
|
+
|
|
244
245
|
// apply the defined alpha value
|
|
245
246
|
renderer.setGlobalAlpha(renderer.globalAlpha() * this.getOpacity());
|
|
246
247
|
|
|
247
248
|
// apply the defined tint, if any
|
|
248
249
|
renderer.setTint(this.tint);
|
|
250
|
+
|
|
251
|
+
// apply blending if different from "normal"
|
|
252
|
+
if (this.blendMode !== renderer.getBlendMode()) {
|
|
253
|
+
renderer.setBlendMode(this.blendMode);
|
|
254
|
+
}
|
|
249
255
|
}
|
|
250
256
|
|
|
251
257
|
/**
|