melonjs 15.0.0 → 15.1.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 -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 +77 -59
- 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 +1747 -1809
- 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 +76 -58
- 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
package/README.md
CHANGED
|
@@ -2,7 +2,6 @@ melonJS 2
|
|
|
2
2
|
=========
|
|
3
3
|

|
|
4
4
|
|
|
5
|
-
[](https://travis-ci.org/melonjs/melonJS)
|
|
6
5
|
[](https://bundlephobia.com/result?p=melonjs)
|
|
7
6
|
[](https://bundlephobia.com/result?p=melonjs)
|
|
8
7
|
[](https://www.npmjs.com/package/melonjs)
|
|
@@ -15,7 +14,7 @@ A fresh, _modern_ & lightweight HTML5 game engine
|
|
|
15
14
|
-------------------------------------------------------------------------------
|
|
16
15
|

|
|
17
16
|
|
|
18
|
-
melonJS 2 is a modern version of the melonJS game engine. It has been rebuilt
|
|
17
|
+
melonJS 2 is a modern version of the melonJS game engine. It has been rebuilt entirely using ES6 class, inheritance and semantic, and bundled using Rollup to provide modern features such as transpiling and tree-shaking.
|
|
19
18
|
|
|
20
19
|
>Note: migrating an existing project to melonJS 2 (version 10.0 and higher) will definitely break your game (ES6 semantic, no more Jay inheritance, nodeJS event emitter, and no backward compatibility with deprecated legacy APIs), and you might want to read first this small step by step guide on [upgrading to melonJS 2](https://github.com/melonjs/melonJS/wiki/Upgrading-to-melonJS-2). If you are looking at the legacy version (9.x and lower) of melonJS, you can find it [here](https://github.com/melonjs/melonJS/tree/legacy) under the _legacy_ branch.
|
|
21
20
|
|
|
@@ -53,8 +52,8 @@ Input
|
|
|
53
52
|
- Device motion & accelerometer support
|
|
54
53
|
|
|
55
54
|
Level Editor
|
|
56
|
-
- Tiled map format version +1.0
|
|
57
|
-
- Uncompressed Plain, Base64, CSV and JSON encoded XML tilemap loading
|
|
55
|
+
- Tiled map format version +1.0 built-in support for easy level design
|
|
56
|
+
- Uncompressed and [compressed](https://github.com/melonjs/tiled-inflate-plugin) Plain, Base64, CSV and JSON encoded XML tilemap loading
|
|
58
57
|
- Orthogonal, Isometric and Hexagonal maps (both normal and staggered)
|
|
59
58
|
- Multiple layers (multiple background/foreground, collision and Image layers)
|
|
60
59
|
- Animated and multiple Tileset support
|
|
@@ -111,6 +110,7 @@ A few demos of melonJS capabilities :
|
|
|
111
110
|
* [Masking Demo](https://melonjs.github.io/examples/masking/) (WARNING: may potentially trigger seizures for people with photosensitive epilepsy)
|
|
112
111
|
* [Primitive Drawing Demo](https://melonjs.github.io/examples/graphics/)
|
|
113
112
|
* [UI Demo](https://melonjs.github.io/examples/UI/)
|
|
113
|
+
* [Tiled Map Loader Demo](https://melonjs.github.io/examples/tiled_example_loader/)
|
|
114
114
|
|
|
115
115
|
More examples are available [here](https://melonjs.github.io/examples/)
|
|
116
116
|
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.1.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
|
|
6
6
|
* @copyright (C) 2011 - 2023 Olivier Biot (AltByte Pte Ltd)
|
|
7
7
|
*/
|
|
8
|
-
var
|
|
8
|
+
var eventemitter3Exports = {};
|
|
9
|
+
var eventemitter3 = {
|
|
10
|
+
get exports(){ return eventemitter3Exports; },
|
|
11
|
+
set exports(v){ eventemitter3Exports = v; },
|
|
12
|
+
};
|
|
9
13
|
|
|
10
|
-
export {
|
|
14
|
+
export { eventemitter3 as __module, eventemitter3Exports as exports };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.1.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
|
|
@@ -34,13 +34,14 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
34
34
|
* @param {number|string} [options.scale=1.0] - enable scaling of the canvas ('auto' for automatic scaling)
|
|
35
35
|
* @param {string} [options.scaleMethod="fit"] - screen scaling modes ('fit','fill-min','fill-max','flex','flex-width','flex-height','stretch')
|
|
36
36
|
* @param {boolean} [options.preferWebGL1=false] - if true the renderer will only use WebGL 1
|
|
37
|
+
* @param {boolean} [options.depthTest="sorting"] - ~Experimental~ the default method to sort object on the z axis in WebGL ("sorting", "z-buffer")
|
|
37
38
|
* @param {string} [options.powerPreference="default"] - a hint to the user agent indicating what configuration of GPU is suitable for the WebGL context ("default", "high-performance", "low-power"). To be noted that Safari and Chrome (since version 80) both default to "low-power" to save battery life and improve the user experience on these dual-GPU machines.
|
|
38
39
|
* @param {boolean} [options.transparent=false] - whether to allow transparent pixels in the front buffer (screen).
|
|
39
40
|
* @param {boolean} [options.antiAlias=false] - whether to enable or not video scaling interpolation
|
|
40
41
|
* @param {boolean} [options.consoleHeader=true] - whether to display melonJS version and basic device information in the console
|
|
41
42
|
* @throws Will throw an exception if it fails to instantiate a renderer
|
|
42
43
|
* @example
|
|
43
|
-
*
|
|
44
|
+
* let my game = new Application(640, 480, {renderer: me.video.AUTO}) {
|
|
44
45
|
* ....
|
|
45
46
|
* }
|
|
46
47
|
*/
|
|
@@ -79,14 +80,6 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
79
80
|
*/
|
|
80
81
|
this.mergeGroup = true;
|
|
81
82
|
|
|
82
|
-
/**
|
|
83
|
-
* Specify the property to be used when sorting renderables.
|
|
84
|
-
* Accepted values : "x", "y", "z"
|
|
85
|
-
* @type {string}
|
|
86
|
-
* @default "z"
|
|
87
|
-
*/
|
|
88
|
-
this.sortOn = "z";
|
|
89
|
-
|
|
90
83
|
/**
|
|
91
84
|
* Last time the game update loop was executed. <br>
|
|
92
85
|
* Use this value to implement frame prediction in drawing events,
|
|
@@ -151,6 +144,7 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
151
144
|
this.settings.transparent = !!(this.settings.transparent);
|
|
152
145
|
this.settings.antiAlias = !!(this.settings.antiAlias);
|
|
153
146
|
this.settings.failIfMajorPerformanceCaveat = !!(this.settings.failIfMajorPerformanceCaveat);
|
|
147
|
+
this.settings.depthTest = this.settings.depthTest === "z-buffer" ? "z-buffer" : "sorting";
|
|
154
148
|
this.settings.subPixel = !!(this.settings.subPixel);
|
|
155
149
|
this.settings.verbose = !!(this.settings.verbose);
|
|
156
150
|
if (this.settings.scaleMethod.search(/^(fill-(min|max)|fit|flex(-(width|height))?|stretch)$/) !== -1) {
|
|
@@ -162,7 +156,7 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
162
156
|
}
|
|
163
157
|
|
|
164
158
|
// override renderer settings if &webgl or &canvas is defined in the URL
|
|
165
|
-
|
|
159
|
+
let uriFragment = utils.getUriFragment();
|
|
166
160
|
if (uriFragment.webgl === true || uriFragment.webgl1 === true || uriFragment.webgl2 === true) {
|
|
167
161
|
this.settings.renderer = WEBGL;
|
|
168
162
|
if (uriFragment.webgl1 === true) {
|
|
@@ -190,14 +184,14 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
190
184
|
break;
|
|
191
185
|
}
|
|
192
186
|
} else {
|
|
193
|
-
|
|
187
|
+
let CustomRenderer = this.settings.renderer;
|
|
194
188
|
// a renderer class
|
|
195
189
|
this.renderer = new CustomRenderer(this.settings);
|
|
196
190
|
}
|
|
197
191
|
|
|
198
192
|
// register to the channel
|
|
199
|
-
on(WINDOW_ONRESIZE, () =>
|
|
200
|
-
on(WINDOW_ONORIENTATION_CHANGE, () =>
|
|
193
|
+
on(WINDOW_ONRESIZE, () => onresize(this), this);
|
|
194
|
+
on(WINDOW_ONORIENTATION_CHANGE, () => onresize(this), this);
|
|
201
195
|
|
|
202
196
|
// add our canvas (default to document.body if settings.parent is undefined)
|
|
203
197
|
this.parentElement = getElement(this.settings.parent);
|
|
@@ -215,7 +209,7 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
215
209
|
// add an observer to detect when the dom tree is modified
|
|
216
210
|
if ("MutationObserver" in globalThis) {
|
|
217
211
|
// Create an observer instance linked to the callback function
|
|
218
|
-
|
|
212
|
+
let observer = new MutationObserver(() => onresize(this));
|
|
219
213
|
|
|
220
214
|
// Start observing the target node for configured mutations
|
|
221
215
|
observer.observe(this.parentElement, {
|
|
@@ -228,10 +222,13 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
228
222
|
}
|
|
229
223
|
|
|
230
224
|
// create a new physic world
|
|
231
|
-
this.world = new World();
|
|
225
|
+
this.world = new World(0, 0, this.settings.width, this.settings.height);
|
|
232
226
|
// set the reference to this application instance
|
|
233
227
|
this.world.app = this;
|
|
228
|
+
// app starting time
|
|
234
229
|
this.lastUpdate = globalThis.performance.now();
|
|
230
|
+
// manually sort child if depthTest setting is "sorting"
|
|
231
|
+
this.world.autoSort = !(this.renderer.type === "WEBGL" && this.settings.depthTest === "z-buffer");
|
|
235
232
|
|
|
236
233
|
this.isInitialized = true;
|
|
237
234
|
|
|
@@ -244,7 +241,7 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
244
241
|
*/
|
|
245
242
|
reset() {
|
|
246
243
|
// point to the current active stage "default" camera
|
|
247
|
-
|
|
244
|
+
let current = state.get();
|
|
248
245
|
if (typeof current !== "undefined") {
|
|
249
246
|
this.viewport = current.cameras.get("default");
|
|
250
247
|
}
|
|
@@ -256,6 +253,19 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
256
253
|
this.updateFrameRate();
|
|
257
254
|
}
|
|
258
255
|
|
|
256
|
+
/**
|
|
257
|
+
* Specify the property to be used when sorting renderables for this application game world.
|
|
258
|
+
* Accepted values : "x", "y", "z", "depth"
|
|
259
|
+
* @type {string}
|
|
260
|
+
* @see World.sortOn
|
|
261
|
+
*/
|
|
262
|
+
get sortOn() {
|
|
263
|
+
return this.world.sortOn;
|
|
264
|
+
}
|
|
265
|
+
set sortOn(value) {
|
|
266
|
+
this.world.sortOn = value;
|
|
267
|
+
}
|
|
268
|
+
|
|
259
269
|
/**
|
|
260
270
|
* Fired when a level is fully loaded and all renderable instantiated. <br>
|
|
261
271
|
* Additionnaly the level id will also be passed to the called function.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.1.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
|
|
@@ -12,13 +12,14 @@ import { devicePixelRatio, platform, getScreenOrientation, language, hasWebAudio
|
|
|
12
12
|
* @param {Application} game - the game application instance calling this function
|
|
13
13
|
*/
|
|
14
14
|
function consoleHeader(app) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
let renderType = app.renderer.type;
|
|
16
|
+
let gpu_renderer = (typeof app.renderer.GPURenderer === "string") ? " (" + app.renderer.GPURenderer + ")" : "";
|
|
17
|
+
let depthTesting = renderType.includes("WebGL") && app.renderer.depthTest === "z-buffer" ? "Depth Test | " : "";
|
|
18
|
+
let audioType = hasWebAudio ? "Web Audio" : "HTML5 Audio";
|
|
18
19
|
|
|
19
20
|
// output video information in the console
|
|
20
21
|
console.log(
|
|
21
|
-
renderType + " renderer" + gpu_renderer + " | " +
|
|
22
|
+
renderType + " renderer" + gpu_renderer + " | " + depthTesting +
|
|
22
23
|
audioType + " | " +
|
|
23
24
|
"pixel ratio " + devicePixelRatio + " | " +
|
|
24
25
|
(platform.nodeJS ? "node.js" : platform.isMobile ? "mobile" : "desktop") + " | " +
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.1.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
|
|
@@ -17,14 +17,14 @@ import { getParentBounds, devicePixelRatio } from '../system/device.js';
|
|
|
17
17
|
* @param {number} y - y scaling multiplier
|
|
18
18
|
*/
|
|
19
19
|
function scale(game, x, y) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
let renderer = game.renderer;
|
|
21
|
+
let canvas = renderer.getCanvas();
|
|
22
|
+
let context = renderer.getContext();
|
|
23
|
+
let settings = renderer.settings;
|
|
24
|
+
let pixelRatio = devicePixelRatio;
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
let w = settings.zoomX = canvas.width * x * pixelRatio;
|
|
27
|
+
let h = settings.zoomY = canvas.height * y * pixelRatio;
|
|
28
28
|
|
|
29
29
|
// update the global scale variable
|
|
30
30
|
renderer.scaleRatio.set(x * pixelRatio, y * pixelRatio);
|
|
@@ -47,37 +47,37 @@ function scale(game, x, y) {
|
|
|
47
47
|
* @param {Application} game - the game application instance triggering the resize
|
|
48
48
|
*/
|
|
49
49
|
function onresize(game) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
let renderer = game.renderer;
|
|
51
|
+
let settings = renderer.settings;
|
|
52
|
+
let scaleX = 1, scaleY = 1;
|
|
53
53
|
|
|
54
54
|
if (settings.autoScale) {
|
|
55
55
|
|
|
56
56
|
// set max the canvas max size if CSS values are defined
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
let canvasMaxWidth = Infinity;
|
|
58
|
+
let canvasMaxHeight = Infinity;
|
|
59
59
|
|
|
60
60
|
if (globalThis.getComputedStyle) {
|
|
61
|
-
|
|
61
|
+
let style = globalThis.getComputedStyle(renderer.getCanvas(), null);
|
|
62
62
|
canvasMaxWidth = parseInt(style.maxWidth, 10) || Infinity;
|
|
63
63
|
canvasMaxHeight = parseInt(style.maxHeight, 10) || Infinity;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
// get the maximum canvas size within the parent div containing the canvas container
|
|
67
|
-
|
|
67
|
+
let nodeBounds = getParentBounds(game.getParentElement());
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
let _max_width = Math.min(canvasMaxWidth, nodeBounds.width);
|
|
70
|
+
let _max_height = Math.min(canvasMaxHeight, nodeBounds.height);
|
|
71
71
|
|
|
72
72
|
// calculate final canvas width & height
|
|
73
|
-
|
|
73
|
+
let screenRatio = _max_width / _max_height;
|
|
74
74
|
|
|
75
75
|
if ((settings.scaleMethod === "fill-min" && screenRatio > renderer.designRatio) ||
|
|
76
76
|
(settings.scaleMethod === "fill-max" && screenRatio < renderer.designRatio) ||
|
|
77
77
|
(settings.scaleMethod === "flex-width")
|
|
78
78
|
) {
|
|
79
79
|
// resize the display canvas to fill the parent container
|
|
80
|
-
|
|
80
|
+
let sWidth = Math.min(canvasMaxWidth, settings.height * screenRatio);
|
|
81
81
|
scaleX = scaleY = _max_width / sWidth;
|
|
82
82
|
renderer.resize(Math.floor(sWidth), settings.height);
|
|
83
83
|
}
|
|
@@ -86,7 +86,7 @@ function onresize(game) {
|
|
|
86
86
|
(settings.scaleMethod === "flex-height")
|
|
87
87
|
) {
|
|
88
88
|
// resize the display canvas to fill the parent container
|
|
89
|
-
|
|
89
|
+
let sHeight = Math.min(canvasMaxHeight, settings.width * (_max_height / _max_width));
|
|
90
90
|
scaleX = scaleY = _max_height / sHeight;
|
|
91
91
|
renderer.resize(settings.width, Math.floor(sHeight));
|
|
92
92
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.1.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
|
|
@@ -49,7 +49,7 @@ let soundLoadError = function (sound_name, onerror_cb) {
|
|
|
49
49
|
// check the retry counter
|
|
50
50
|
if (retry_counter++ > 3) {
|
|
51
51
|
// something went wrong
|
|
52
|
-
|
|
52
|
+
let errmsg = "melonJS: failed loading " + sound_name;
|
|
53
53
|
{
|
|
54
54
|
// throw an exception and stop everything !
|
|
55
55
|
throw new Error(errmsg);
|
|
@@ -145,14 +145,14 @@ function disable() {
|
|
|
145
145
|
* @ignore
|
|
146
146
|
*/
|
|
147
147
|
function load(sound, html5, onload_cb, onerror_cb) {
|
|
148
|
-
|
|
148
|
+
let urls = [];
|
|
149
149
|
if (audioExts.length === 0) {
|
|
150
150
|
throw new Error("target audio extension(s) should be set through me.audio.init() before calling the preloader.");
|
|
151
151
|
}
|
|
152
152
|
if (isDataUrl(sound.src) === true) {
|
|
153
153
|
urls.push(sound.src);
|
|
154
154
|
} else {
|
|
155
|
-
for (
|
|
155
|
+
for (let i = 0; i < audioExts.length; i++) {
|
|
156
156
|
urls.push(sound.src + sound.name + "." + audioExts[i] + nocache);
|
|
157
157
|
}
|
|
158
158
|
}
|
|
@@ -201,9 +201,9 @@ function load(sound, html5, onload_cb, onerror_cb) {
|
|
|
201
201
|
* me.audio.play("gameover_sfx", false, null, 0.5);
|
|
202
202
|
*/
|
|
203
203
|
function play(sound_name, loop = false, onend, volume) {
|
|
204
|
-
|
|
204
|
+
let sound = audioTracks[sound_name];
|
|
205
205
|
if (sound && typeof sound !== "undefined") {
|
|
206
|
-
|
|
206
|
+
let id = sound.play();
|
|
207
207
|
if (typeof loop === "boolean") {
|
|
208
208
|
// arg[0] can take different types in howler 2.0
|
|
209
209
|
sound.loop(loop, id);
|
|
@@ -233,7 +233,7 @@ function play(sound_name, loop = false, onend, volume) {
|
|
|
233
233
|
* @param {number} [id] - the sound instance ID. If none is passed, all sounds in group will fade.
|
|
234
234
|
*/
|
|
235
235
|
function fade(sound_name, from, to, duration, id) {
|
|
236
|
-
|
|
236
|
+
let sound = audioTracks[sound_name];
|
|
237
237
|
if (sound && typeof sound !== "undefined") {
|
|
238
238
|
sound.fade(from, to, duration, id);
|
|
239
239
|
} else {
|
|
@@ -250,12 +250,12 @@ function fade(sound_name, from, to, duration, id) {
|
|
|
250
250
|
* @returns {number} return the current seek position (if no extra parameters were given)
|
|
251
251
|
* @example
|
|
252
252
|
* // return the current position of the background music
|
|
253
|
-
*
|
|
253
|
+
* let current_pos = me.audio.seek("dst-gameforest");
|
|
254
254
|
* // set back the position of the background music to the beginning
|
|
255
255
|
* me.audio.seek("dst-gameforest", 0);
|
|
256
256
|
*/
|
|
257
257
|
function seek(sound_name, ...args) {
|
|
258
|
-
|
|
258
|
+
let sound = audioTracks[sound_name];
|
|
259
259
|
if (sound && typeof sound !== "undefined") {
|
|
260
260
|
return sound.seek(...args);
|
|
261
261
|
} else {
|
|
@@ -272,12 +272,12 @@ function seek(sound_name, ...args) {
|
|
|
272
272
|
* @returns {number} return the current playback rate (if no extra parameters were given)
|
|
273
273
|
* @example
|
|
274
274
|
* // get the playback rate of the background music
|
|
275
|
-
*
|
|
275
|
+
* let rate = me.audio.rate("dst-gameforest");
|
|
276
276
|
* // speed up the playback of the background music
|
|
277
277
|
* me.audio.rate("dst-gameforest", 2.0);
|
|
278
278
|
*/
|
|
279
279
|
function rate(sound_name, ...args) {
|
|
280
|
-
|
|
280
|
+
let sound = audioTracks[sound_name];
|
|
281
281
|
if (sound && typeof sound !== "undefined") {
|
|
282
282
|
return sound.rate(...args);
|
|
283
283
|
} else {
|
|
@@ -295,7 +295,7 @@ function rate(sound_name, ...args) {
|
|
|
295
295
|
*/
|
|
296
296
|
function stop(sound_name, id) {
|
|
297
297
|
if (typeof sound_name !== "undefined") {
|
|
298
|
-
|
|
298
|
+
let sound = audioTracks[sound_name];
|
|
299
299
|
if (sound && typeof sound !== "undefined") {
|
|
300
300
|
sound.stop(id);
|
|
301
301
|
// remove the defined onend callback (if any defined)
|
|
@@ -318,7 +318,7 @@ function stop(sound_name, id) {
|
|
|
318
318
|
* me.audio.pause("cling");
|
|
319
319
|
*/
|
|
320
320
|
function pause(sound_name, id) {
|
|
321
|
-
|
|
321
|
+
let sound = audioTracks[sound_name];
|
|
322
322
|
if (sound && typeof sound !== "undefined") {
|
|
323
323
|
sound.pause(id);
|
|
324
324
|
} else {
|
|
@@ -333,7 +333,7 @@ function pause(sound_name, id) {
|
|
|
333
333
|
* @param {number} [id] - the sound instance ID. If none is passed, all sounds in group will resume.
|
|
334
334
|
* @example
|
|
335
335
|
* // play a audio clip
|
|
336
|
-
*
|
|
336
|
+
* let id = me.audio.play("myClip");
|
|
337
337
|
* ...
|
|
338
338
|
* // pause it
|
|
339
339
|
* me.audio.pause("myClip", id);
|
|
@@ -342,7 +342,7 @@ function pause(sound_name, id) {
|
|
|
342
342
|
* me.audio.resume("myClip", id);
|
|
343
343
|
*/
|
|
344
344
|
function resume(sound_name, id) {
|
|
345
|
-
|
|
345
|
+
let sound = audioTracks[sound_name];
|
|
346
346
|
if (sound && typeof sound !== "undefined") {
|
|
347
347
|
sound.play(id);
|
|
348
348
|
} else {
|
|
@@ -455,7 +455,7 @@ function getVolume() {
|
|
|
455
455
|
* me.audio.mute("awesome_music");
|
|
456
456
|
*/
|
|
457
457
|
function mute(sound_name, id, mute = true) {
|
|
458
|
-
|
|
458
|
+
let sound = audioTracks[sound_name];
|
|
459
459
|
if (sound && typeof(sound) !== "undefined") {
|
|
460
460
|
sound.mute(mute, id);
|
|
461
461
|
} else {
|
|
@@ -524,7 +524,7 @@ function unload(sound_name) {
|
|
|
524
524
|
* me.audio.unloadAll();
|
|
525
525
|
*/
|
|
526
526
|
function unloadAll() {
|
|
527
|
-
for (
|
|
527
|
+
for (let sound_name in audioTracks) {
|
|
528
528
|
if (audioTracks.hasOwnProperty(sound_name)) {
|
|
529
529
|
unload(sound_name);
|
|
530
530
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.1.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
|
|
@@ -22,7 +22,7 @@ import { game } from '../index.js';
|
|
|
22
22
|
// some ref shortcut
|
|
23
23
|
const MIN = Math.min, MAX = Math.max;
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
let targetV = new Vector2d();
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* @classdesc
|
|
@@ -184,7 +184,7 @@ var targetV = new Vector2d();
|
|
|
184
184
|
|
|
185
185
|
/** @ignore */
|
|
186
186
|
_followH(target) {
|
|
187
|
-
|
|
187
|
+
let targetX = this.pos.x;
|
|
188
188
|
if ((target.x - this.pos.x) > (this.deadzone.right)) {
|
|
189
189
|
targetX = MIN((target.x) - (this.deadzone.right), this.bounds.width - this.width);
|
|
190
190
|
}
|
|
@@ -197,7 +197,7 @@ var targetV = new Vector2d();
|
|
|
197
197
|
|
|
198
198
|
/** @ignore */
|
|
199
199
|
_followV(target) {
|
|
200
|
-
|
|
200
|
+
let targetY = this.pos.y;
|
|
201
201
|
if ((target.y - this.pos.y) > (this.deadzone.bottom)) {
|
|
202
202
|
targetY = MIN((target.y) - (this.deadzone.bottom), this.bounds.height - this.height);
|
|
203
203
|
}
|
|
@@ -390,8 +390,8 @@ var targetV = new Vector2d();
|
|
|
390
390
|
* @param {number} y
|
|
391
391
|
*/
|
|
392
392
|
moveTo(x, y) {
|
|
393
|
-
|
|
394
|
-
|
|
393
|
+
let _x = this.pos.x;
|
|
394
|
+
let _y = this.pos.y;
|
|
395
395
|
|
|
396
396
|
this.pos.x = clamp(
|
|
397
397
|
x,
|
|
@@ -564,7 +564,7 @@ var targetV = new Vector2d();
|
|
|
564
564
|
*/
|
|
565
565
|
fadeIn(color, duration = 1000, onComplete) {
|
|
566
566
|
this._fadeIn.color = pool.pull("Color").copy(color);
|
|
567
|
-
|
|
567
|
+
let _alpha = this._fadeIn.color.alpha;
|
|
568
568
|
this._fadeIn.color.alpha = 0.0;
|
|
569
569
|
this._fadeIn.tween = pool.pull("Tween", this._fadeIn.color)
|
|
570
570
|
.to({ alpha: _alpha }, duration)
|
|
@@ -580,7 +580,7 @@ var targetV = new Vector2d();
|
|
|
580
580
|
* @param {Renderable} target - the renderable to focus the camera on
|
|
581
581
|
*/
|
|
582
582
|
focusOn(target) {
|
|
583
|
-
|
|
583
|
+
let bounds = target.getBounds();
|
|
584
584
|
this.moveTo(
|
|
585
585
|
target.pos.x + bounds.left + (bounds.width / 2),
|
|
586
586
|
target.pos.y + bounds.top + (bounds.height / 2)
|
|
@@ -690,8 +690,8 @@ var targetV = new Vector2d();
|
|
|
690
690
|
* @ignore
|
|
691
691
|
*/
|
|
692
692
|
draw(renderer, container) {
|
|
693
|
-
|
|
694
|
-
|
|
693
|
+
let translateX = this.pos.x + this.offset.x;
|
|
694
|
+
let translateY = this.pos.y + this.offset.y;
|
|
695
695
|
|
|
696
696
|
// translate the world coordinates by default to screen coordinates
|
|
697
697
|
container.currentTransform.translate(-translateX, -translateY);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.1.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
|
|
@@ -114,7 +114,7 @@ import Body from '../physics/body.js';
|
|
|
114
114
|
pool.pull("Vector2d", 0, this.height)
|
|
115
115
|
]);
|
|
116
116
|
}
|
|
117
|
-
this.body = new Body(this, settings.shapes, this.onBodyUpdate
|
|
117
|
+
this.body = new Body(this, settings.shapes, () => this.onBodyUpdate());
|
|
118
118
|
|
|
119
119
|
// resize the entity if required
|
|
120
120
|
if (this.width === 0 && this.height === 0) {
|
|
@@ -166,7 +166,7 @@ import Body from '../physics/body.js';
|
|
|
166
166
|
* @returns {Bounds} this entity bounding box Rectangle object
|
|
167
167
|
*/
|
|
168
168
|
updateBounds(absolute = true) {
|
|
169
|
-
|
|
169
|
+
let bounds = this.getBounds();
|
|
170
170
|
|
|
171
171
|
bounds.clear();
|
|
172
172
|
bounds.addFrame(
|
|
@@ -236,7 +236,7 @@ import Body from '../physics/body.js';
|
|
|
236
236
|
* @param {Camera2d} [viewport] - the viewport to (re)draw
|
|
237
237
|
*/
|
|
238
238
|
draw(renderer, viewport) {
|
|
239
|
-
|
|
239
|
+
let renderable = this.renderable;
|
|
240
240
|
if (renderable instanceof Renderable) {
|
|
241
241
|
// predraw (apply transforms)
|
|
242
242
|
renderable.preDraw(renderer);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.1.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
|
|
@@ -91,14 +91,14 @@ import pool from '../system/pooling.js';
|
|
|
91
91
|
* @returns {Ellipse} this instance for objecf chaining
|
|
92
92
|
*/
|
|
93
93
|
setShape(x, y, w, h) {
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
const hW = w / 2;
|
|
95
|
+
const hH = h / 2;
|
|
96
96
|
|
|
97
97
|
this.pos.set(x, y);
|
|
98
98
|
this.radius = Math.max(hW, hH);
|
|
99
99
|
this.ratio.set(hW / this.radius, hH / this.radius);
|
|
100
100
|
this.radiusV.set(this.radius, this.radius).scaleV(this.ratio);
|
|
101
|
-
|
|
101
|
+
const r = this.radius * this.radius;
|
|
102
102
|
this.radiusSq.set(r, r).scaleV(this.ratio);
|
|
103
103
|
|
|
104
104
|
// update the corresponding bounds
|
|
@@ -182,7 +182,7 @@ import pool from '../system/pooling.js';
|
|
|
182
182
|
* @returns {Ellipse} this ellipse
|
|
183
183
|
*/
|
|
184
184
|
translate() {
|
|
185
|
-
|
|
185
|
+
let _x, _y;
|
|
186
186
|
|
|
187
187
|
if (arguments.length === 2) {
|
|
188
188
|
// x, y
|
|
@@ -219,7 +219,7 @@ import pool from '../system/pooling.js';
|
|
|
219
219
|
* @returns {boolean} true if contains
|
|
220
220
|
*/
|
|
221
221
|
contains() {
|
|
222
|
-
|
|
222
|
+
let _x, _y;
|
|
223
223
|
|
|
224
224
|
if (arguments.length === 2) {
|
|
225
225
|
// x, y
|