melonjs 15.2.1 → 15.4.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 +1 -1
- package/dist/melonjs.mjs/_virtual/_commonjsHelpers.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/application/application.js +75 -23
- package/dist/melonjs.mjs/application/header.js +2 -2
- package/dist/melonjs.mjs/application/resize.js +13 -11
- package/dist/melonjs.mjs/application/settings.js +37 -1
- package/dist/melonjs.mjs/audio/audio.js +4 -6
- package/dist/melonjs.mjs/camera/camera2d.js +12 -14
- package/dist/melonjs.mjs/const.js +1 -1
- package/dist/melonjs.mjs/entity/entity.js +3 -4
- package/dist/melonjs.mjs/geometries/ellipse.js +26 -59
- package/dist/melonjs.mjs/geometries/line.js +18 -25
- package/dist/melonjs.mjs/geometries/path2d.js +16 -13
- package/dist/melonjs.mjs/geometries/point.js +8 -16
- package/dist/melonjs.mjs/geometries/poly.js +40 -97
- package/dist/melonjs.mjs/geometries/rectangle.js +37 -91
- package/dist/melonjs.mjs/geometries/roundrect.js +26 -35
- package/dist/melonjs.mjs/index.js +6 -6
- package/dist/melonjs.mjs/input/gamepad.js +1 -1
- package/dist/melonjs.mjs/input/input.js +1 -1
- package/dist/melonjs.mjs/input/keyboard.js +3 -3
- package/dist/melonjs.mjs/input/pointer.js +4 -4
- package/dist/melonjs.mjs/input/pointerevent.js +6 -7
- package/dist/melonjs.mjs/lang/console.js +1 -1
- package/dist/melonjs.mjs/lang/deprecated.js +2 -2
- package/dist/melonjs.mjs/level/level.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXGroup.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXLayer.js +16 -33
- package/dist/melonjs.mjs/level/tiled/TMXObject.js +3 -4
- package/dist/melonjs.mjs/level/tiled/TMXTile.js +4 -4
- package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +3 -3
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +4 -7
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +2 -2
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +37 -47
- package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +3 -3
- package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +2 -2
- 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 +1 -1
- package/dist/melonjs.mjs/loader/loadingscreen.js +1 -1
- package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
- package/dist/melonjs.mjs/loader/parser.js +4 -5
- package/dist/melonjs.mjs/loader/settings.js +1 -1
- package/dist/melonjs.mjs/math/color.js +5 -5
- package/dist/melonjs.mjs/math/math.js +1 -1
- package/dist/melonjs.mjs/math/matrix2.js +5 -59
- package/dist/melonjs.mjs/math/matrix3.js +82 -141
- package/dist/melonjs.mjs/math/observable_vector2.js +7 -7
- package/dist/melonjs.mjs/math/observable_vector3.js +5 -5
- package/dist/melonjs.mjs/math/vector2.js +7 -91
- package/dist/melonjs.mjs/math/vector3.js +6 -90
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/arraymultimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/multimap.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 +2 -2
- package/dist/melonjs.mjs/particles/particle.js +2 -2
- package/dist/melonjs.mjs/particles/settings.js +1 -1
- package/dist/melonjs.mjs/physics/body.js +22 -20
- package/dist/melonjs.mjs/physics/bounds.js +27 -33
- package/dist/melonjs.mjs/physics/collision.js +5 -5
- package/dist/melonjs.mjs/physics/detector.js +10 -10
- package/dist/melonjs.mjs/physics/quadtree.js +5 -5
- package/dist/melonjs.mjs/physics/response.js +1 -1
- package/dist/melonjs.mjs/physics/sat.js +3 -4
- package/dist/melonjs.mjs/physics/world.js +6 -9
- package/dist/melonjs.mjs/plugin/plugin.js +3 -3
- package/dist/melonjs.mjs/renderable/collectable.js +2 -2
- package/dist/melonjs.mjs/renderable/colorlayer.js +4 -4
- package/dist/melonjs.mjs/renderable/container.js +25 -25
- package/dist/melonjs.mjs/renderable/draggable.js +1 -1
- package/dist/melonjs.mjs/renderable/dragndrop.js +1 -1
- package/dist/melonjs.mjs/renderable/imagelayer.js +4 -4
- package/dist/melonjs.mjs/renderable/light2d.js +3 -3
- package/dist/melonjs.mjs/renderable/nineslicesprite.js +2 -2
- package/dist/melonjs.mjs/renderable/renderable.js +31 -39
- package/dist/melonjs.mjs/renderable/sprite.js +3 -3
- package/dist/melonjs.mjs/renderable/text/bitmaptext.js +421 -0
- package/dist/melonjs.mjs/renderable/text/bitmaptextdata.js +195 -0
- package/dist/melonjs.mjs/renderable/text/glyph.js +65 -0
- package/dist/melonjs.mjs/renderable/text/text.js +422 -0
- package/dist/melonjs.mjs/renderable/text/textmetrics.js +175 -0
- package/dist/melonjs.mjs/renderable/text/textstyle.js +21 -0
- package/dist/melonjs.mjs/renderable/trigger.js +10 -10
- package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +7 -7
- package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +7 -7
- package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +3 -3
- package/dist/melonjs.mjs/state/stage.js +13 -14
- package/dist/melonjs.mjs/state/state.js +4 -51
- package/dist/melonjs.mjs/system/device.js +51 -10
- package/dist/melonjs.mjs/system/dom.js +1 -1
- package/dist/melonjs.mjs/system/event.js +46 -2
- package/dist/melonjs.mjs/system/platform.js +18 -18
- package/dist/melonjs.mjs/system/pooling.js +10 -10
- 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 +1 -1
- package/dist/melonjs.mjs/text/bitmaptextdata.js +3 -6
- package/dist/melonjs.mjs/text/glyph.js +1 -1
- package/dist/melonjs.mjs/text/text.js +1 -1
- package/dist/melonjs.mjs/text/textmetrics.js +1 -1
- package/dist/melonjs.mjs/text/textstyle.js +1 -1
- 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 +2 -2
- 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 +2 -3
- package/dist/melonjs.mjs/utils/string.js +1 -1
- package/dist/melonjs.mjs/utils/utils.js +1 -1
- package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +5 -18
- package/dist/melonjs.mjs/video/renderer.js +17 -30
- package/dist/melonjs.mjs/video/texture/atlas.js +13 -13
- package/dist/melonjs.mjs/video/texture/cache.js +1 -1
- package/dist/melonjs.mjs/video/texture/canvas_texture.js +15 -15
- package/dist/melonjs.mjs/video/utils/autodetect.js +1 -1
- package/dist/melonjs.mjs/video/video.js +5 -29
- package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +3 -3
- package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +13 -14
- package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +5 -5
- package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +2 -3
- package/dist/melonjs.mjs/video/webgl/glshader.js +2 -2
- 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 +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/precision.js +4 -4
- 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 +62 -67
- package/dist/melonjs.module.js +1272 -1713
- package/dist/types/application/application.d.ts +32 -31
- package/dist/types/application/header.d.ts +2 -2
- package/dist/types/application/settings.d.ts +80 -16
- package/dist/types/audio/audio.d.ts +4 -6
- package/dist/types/camera/camera2d.d.ts +13 -16
- package/dist/types/entity/entity.d.ts +0 -1
- package/dist/types/geometries/ellipse.d.ts +18 -50
- package/dist/types/geometries/path2d.d.ts +1 -1
- package/dist/types/geometries/point.d.ts +5 -13
- package/dist/types/geometries/poly.d.ts +26 -75
- package/dist/types/geometries/rectangle.d.ts +12 -58
- package/dist/types/geometries/roundrect.d.ts +2 -11
- package/dist/types/index.d.ts +3 -3
- package/dist/types/input/gamepad.d.ts +31 -31
- package/dist/types/input/keyboard.d.ts +105 -105
- package/dist/types/input/pointer.d.ts +21 -21
- package/dist/types/input/pointerevent.d.ts +6 -6
- package/dist/types/level/tiled/TMXLayer.d.ts +1 -1
- package/dist/types/level/tiled/TMXUtils.d.ts +4 -6
- package/dist/types/math/matrix2.d.ts +9 -63
- package/dist/types/math/matrix3.d.ts +9 -68
- package/dist/types/math/observable_vector2.d.ts +2 -2
- package/dist/types/math/observable_vector3.d.ts +2 -2
- package/dist/types/math/vector2.d.ts +8 -92
- package/dist/types/math/vector3.d.ts +8 -92
- package/dist/types/particles/settings.d.ts +29 -29
- package/dist/types/physics/body.d.ts +10 -8
- package/dist/types/physics/bounds.d.ts +24 -30
- package/dist/types/physics/collision.d.ts +12 -12
- package/dist/types/physics/detector.d.ts +1 -1
- package/dist/types/physics/world.d.ts +4 -7
- package/dist/types/renderable/container.d.ts +19 -19
- package/dist/types/renderable/imagelayer.d.ts +6 -6
- package/dist/types/renderable/light2d.d.ts +7 -7
- package/dist/types/renderable/renderable.d.ts +10 -18
- package/dist/types/renderable/text/bitmaptext.d.ts +151 -0
- package/dist/types/renderable/text/bitmaptextdata.d.ts +35 -0
- package/dist/types/renderable/text/glyph.d.ts +28 -0
- package/dist/types/renderable/text/text.d.ts +159 -0
- package/dist/types/renderable/text/textmetrics.d.ts +47 -0
- package/dist/types/renderable/text/textstyle.d.ts +5 -0
- package/dist/types/renderable/ui/uibaseelement.d.ts +0 -1
- package/dist/types/renderable/ui/uispriteelement.d.ts +0 -1
- package/dist/types/renderable/ui/uitextbutton.d.ts +2 -7
- package/dist/types/state/stage.d.ts +3 -2
- package/dist/types/state/state.d.ts +11 -11
- package/dist/types/system/device.d.ts +16 -9
- package/dist/types/system/event.d.ts +40 -0
- package/dist/types/system/platform.d.ts +17 -17
- package/dist/types/utils/function.d.ts +1 -2
- package/dist/types/video/canvas/canvas_renderer.d.ts +0 -23
- package/dist/types/video/renderer.d.ts +16 -43
- package/dist/types/video/texture/canvas_texture.d.ts +14 -14
- package/dist/types/video/video.d.ts +4 -38
- package/dist/types/video/webgl/buffer/vertex.d.ts +2 -2
- package/dist/types/video/webgl/compositors/compositor.d.ts +24 -13
- package/dist/types/video/webgl/compositors/primitive_compositor.d.ts +0 -1
- package/dist/types/video/webgl/compositors/quad_compositor.d.ts +0 -1
- package/dist/types/video/webgl/utils/precision.d.ts +1 -1
- package/dist/types/video/webgl/webgl_renderer.d.ts +48 -84
- package/package.json +15 -15
- package/src/application/application.js +73 -21
- package/src/application/header.js +1 -1
- package/src/application/resize.js +11 -9
- package/src/application/settings.js +36 -0
- package/src/audio/audio.js +3 -5
- package/src/camera/camera2d.js +11 -13
- package/src/entity/entity.js +2 -3
- package/src/geometries/ellipse.js +25 -58
- package/src/geometries/line.js +17 -24
- package/src/geometries/path2d.js +15 -12
- package/src/geometries/point.js +7 -15
- package/src/geometries/poly.js +39 -96
- package/src/geometries/rectangle.js +36 -90
- package/src/geometries/roundrect.js +25 -34
- package/src/index.js +4 -4
- package/src/input/keyboard.js +2 -2
- package/src/input/pointer.js +3 -3
- package/src/input/pointerevent.js +5 -6
- package/src/lang/deprecated.js +1 -1
- package/src/level/tiled/TMXLayer.js +15 -32
- package/src/level/tiled/TMXObject.js +2 -3
- package/src/level/tiled/TMXTile.js +3 -3
- package/src/level/tiled/TMXTileMap.js +2 -2
- package/src/level/tiled/TMXTileset.js +3 -6
- package/src/level/tiled/TMXTilesetGroup.js +1 -1
- package/src/level/tiled/TMXUtils.js +36 -46
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +2 -2
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
- package/src/loader/parser.js +3 -4
- package/src/math/color.js +4 -4
- package/src/math/matrix2.js +4 -58
- package/src/math/matrix3.js +81 -140
- package/src/math/observable_vector2.js +6 -6
- package/src/math/observable_vector3.js +4 -4
- package/src/math/vector2.js +6 -90
- package/src/math/vector3.js +5 -89
- package/src/particles/emitter.js +1 -1
- package/src/particles/particle.js +1 -1
- package/src/physics/body.js +21 -19
- package/src/physics/bounds.js +26 -32
- package/src/physics/collision.js +4 -4
- package/src/physics/detector.js +9 -9
- package/src/physics/quadtree.js +4 -4
- package/src/physics/sat.js +2 -3
- package/src/physics/world.js +5 -8
- package/src/polyfill/roundrect.js +163 -163
- package/src/renderable/collectable.js +1 -1
- package/src/renderable/colorlayer.js +3 -3
- package/src/renderable/container.js +24 -24
- package/src/renderable/imagelayer.js +3 -3
- package/src/renderable/light2d.js +2 -2
- package/src/renderable/nineslicesprite.js +1 -1
- package/src/renderable/renderable.js +30 -38
- package/src/renderable/sprite.js +2 -2
- package/src/{text → renderable/text}/bitmaptext.js +8 -8
- package/src/{text → renderable/text}/bitmaptextdata.js +4 -7
- package/src/{text → renderable/text}/glyph.js +1 -1
- package/src/{text → renderable/text}/text.js +16 -17
- package/src/{text → renderable/text}/textmetrics.js +2 -2
- package/src/renderable/trigger.js +9 -9
- package/src/renderable/ui/uibaseelement.js +6 -6
- package/src/renderable/ui/uispriteelement.js +6 -6
- package/src/renderable/ui/uitextbutton.js +2 -2
- package/src/state/stage.js +12 -13
- package/src/state/state.js +2 -61
- package/src/system/device.js +50 -9
- package/src/system/event.js +44 -0
- package/src/system/platform.js +18 -18
- package/src/system/pooling.js +9 -9
- package/src/tweens/tween.js +1 -1
- package/src/utils/function.js +1 -2
- package/src/video/canvas/canvas_renderer.js +4 -17
- package/src/video/renderer.js +16 -29
- package/src/video/texture/atlas.js +12 -12
- package/src/video/texture/canvas_texture.js +14 -14
- package/src/video/video.js +7 -28
- package/src/video/webgl/buffer/vertex.js +2 -2
- package/src/video/webgl/compositors/compositor.js +12 -13
- package/src/video/webgl/compositors/primitive_compositor.js +4 -4
- package/src/video/webgl/compositors/quad_compositor.js +1 -2
- package/src/video/webgl/glshader.js +1 -1
- package/src/video/webgl/utils/precision.js +3 -3
- package/src/video/webgl/webgl_renderer.js +61 -66
- /package/src/{text → renderable/text}/textstyle.js +0 -0
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ Compatibility
|
|
|
31
31
|
|
|
32
32
|
Graphics
|
|
33
33
|
- 2D sprite-based graphic engine
|
|
34
|
-
- Fast WebGL
|
|
34
|
+
- [Blazing Fast](https://melonjs.discourse.group/t/melonjs-benchmark/48/4) WebGL renderer for desktop and mobile devices with fallback to Canvas rendering
|
|
35
35
|
- High DPI resolution & Canvas advanced auto scaling
|
|
36
36
|
- Sprite with 9-slice scaling option, and animation management
|
|
37
37
|
- built-in effects such as tinting and masking
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.4.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
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { autoDetectRenderer } from '../video/utils/autodetect.js';
|
|
9
9
|
import CanvasRenderer from '../video/canvas/canvas_renderer.js';
|
|
10
10
|
import { getElement, platform, enableSwipe } from '../system/device.js';
|
|
11
|
-
import { on, emit, GAME_AFTER_UPDATE, GAME_BEFORE_DRAW, GAME_AFTER_DRAW, WINDOW_ONRESIZE, WINDOW_ONORIENTATION_CHANGE, GAME_INIT, GAME_RESET, GAME_BEFORE_UPDATE, GAME_UPDATE } from '../system/event.js';
|
|
11
|
+
import { on, emit, STATE_CHANGE, STATE_RESTART, STATE_RESUME, STAGE_RESET, GAME_AFTER_UPDATE, GAME_BEFORE_DRAW, GAME_AFTER_DRAW, WINDOW_ONRESIZE, WINDOW_ONORIENTATION_CHANGE, GAME_INIT, TICK, BLUR, FOCUS, GAME_RESET, GAME_BEFORE_UPDATE, GAME_UPDATE } from '../system/event.js';
|
|
12
12
|
import { getUriFragment } from '../utils/utils.js';
|
|
13
13
|
import timer from '../system/timer.js';
|
|
14
14
|
import state from '../state/state.js';
|
|
@@ -24,21 +24,11 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
24
24
|
* An Application is responsible for updating (each frame) all the related object status and draw them.
|
|
25
25
|
* @see game
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
class Application {
|
|
28
28
|
/**
|
|
29
29
|
* @param {number} width - The width of the canvas viewport
|
|
30
30
|
* @param {number} height - The height of the canvas viewport
|
|
31
|
-
* @param {
|
|
32
|
-
* @param {string|HTMLElement} [options.parent=document.body] - the DOM parent element to hold the canvas in the HTML file
|
|
33
|
-
* @param {number|Renderer} [options.renderer=AUTO] - renderer to use (CANVAS, WEBGL, AUTO), or a custom renderer class
|
|
34
|
-
* @param {number|string} [options.scale=1.0] - enable scaling of the canvas ('auto' for automatic scaling)
|
|
35
|
-
* @param {string} [options.scaleMethod="fit"] - screen scaling modes ('fit','fill-min','fill-max','flex','flex-width','flex-height','stretch')
|
|
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")
|
|
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.
|
|
39
|
-
* @param {boolean} [options.transparent=false] - whether to allow transparent pixels in the front buffer (screen).
|
|
40
|
-
* @param {boolean} [options.antiAlias=false] - whether to enable or not video scaling interpolation
|
|
41
|
-
* @param {boolean} [options.consoleHeader=true] - whether to display melonJS version and basic device information in the console
|
|
31
|
+
* @param {Application.Settings} [options] - The optional parameters for the application and default renderer
|
|
42
32
|
* @throws Will throw an exception if it fails to instantiate a renderer
|
|
43
33
|
* @example
|
|
44
34
|
* let my game = new Application(640, 480, {renderer: me.video.AUTO}) {
|
|
@@ -98,10 +88,34 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
98
88
|
|
|
99
89
|
/**
|
|
100
90
|
* the given settings used when creating this application
|
|
101
|
-
* @type {
|
|
91
|
+
* @type {object}
|
|
102
92
|
*/
|
|
103
93
|
this.settings = undefined;
|
|
104
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Specify whether to pause this app when losing focus
|
|
97
|
+
* @type {boolean}
|
|
98
|
+
* @default true
|
|
99
|
+
* @example
|
|
100
|
+
* // keep the default game instance running even when loosing focus
|
|
101
|
+
* me.game.pauseOnBlur = false;
|
|
102
|
+
*/
|
|
103
|
+
this.pauseOnBlur = true;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Specify whether to unpause this app when gaining back focus
|
|
107
|
+
* @type {boolean}
|
|
108
|
+
* @default true
|
|
109
|
+
*/
|
|
110
|
+
this.resumeOnFocus = true;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Specify whether to stop this app when losing focus
|
|
114
|
+
* @type {boolean}
|
|
115
|
+
* @default false
|
|
116
|
+
*/
|
|
117
|
+
this.stopOnBlur = false;
|
|
118
|
+
|
|
105
119
|
// to know when we have to refresh the display
|
|
106
120
|
this.isDirty = true;
|
|
107
121
|
|
|
@@ -133,6 +147,9 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
133
147
|
|
|
134
148
|
/**
|
|
135
149
|
* init the game instance (create a physic world, update starting time, etc..)
|
|
150
|
+
* @param {number} width - The width of the canvas viewport
|
|
151
|
+
* @param {number} height - The height of the canvas viewport
|
|
152
|
+
* @param {Application.Settings} [options] - The optional parameters for the application and default renderer
|
|
136
153
|
*/
|
|
137
154
|
init(width, height, options) {
|
|
138
155
|
|
|
@@ -173,6 +190,12 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
173
190
|
this.settings.zoomX = width * this.settings.scale;
|
|
174
191
|
this.settings.zoomY = height * this.settings.scale;
|
|
175
192
|
|
|
193
|
+
// identify parent element and/or the html target for resizing
|
|
194
|
+
this.parentElement = getElement(this.settings.parent);
|
|
195
|
+
if (typeof this.settings.scaleTarget !== "undefined" ) {
|
|
196
|
+
this.settings.scaleTarget = getElement(this.settings.scaleTarget);
|
|
197
|
+
}
|
|
198
|
+
|
|
176
199
|
if (typeof this.settings.renderer === "number") {
|
|
177
200
|
switch (this.settings.renderer) {
|
|
178
201
|
case AUTO:
|
|
@@ -194,7 +217,6 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
194
217
|
on(WINDOW_ONORIENTATION_CHANGE, () => onresize(this), this);
|
|
195
218
|
|
|
196
219
|
// add our canvas (default to document.body if settings.parent is undefined)
|
|
197
|
-
this.parentElement = getElement(this.settings.parent);
|
|
198
220
|
this.parentElement.appendChild(this.renderer.getCanvas());
|
|
199
221
|
|
|
200
222
|
// Mobile browser hacks
|
|
@@ -233,6 +255,37 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
233
255
|
this.isInitialized = true;
|
|
234
256
|
|
|
235
257
|
emit(GAME_INIT, this);
|
|
258
|
+
on(STATE_CHANGE, this.repaint, this);
|
|
259
|
+
on(STATE_RESTART, this.repaint, this);
|
|
260
|
+
on(STATE_RESUME, this.repaint, this);
|
|
261
|
+
on(STAGE_RESET, this.reset, this);
|
|
262
|
+
on(TICK, (time) => {
|
|
263
|
+
// update all game objects
|
|
264
|
+
this.update(time);
|
|
265
|
+
// render all game objects
|
|
266
|
+
this.draw();
|
|
267
|
+
}, this);
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
// on blur event, pause the current
|
|
271
|
+
on(BLUR, () => {
|
|
272
|
+
if (this.stopOnBlur === true) {
|
|
273
|
+
state.stop(true);
|
|
274
|
+
}
|
|
275
|
+
if (this.pauseOnBlur === true) {
|
|
276
|
+
state.pause(true);
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
// on focus event, restart or resume the current
|
|
281
|
+
on(FOCUS, () => {
|
|
282
|
+
if (this.stopOnBlur === true) {
|
|
283
|
+
state.restart(true);
|
|
284
|
+
}
|
|
285
|
+
if (this.resumeOnFocus === true) {
|
|
286
|
+
state.resume(true);
|
|
287
|
+
}
|
|
288
|
+
});
|
|
236
289
|
}
|
|
237
290
|
|
|
238
291
|
/**
|
|
@@ -297,7 +350,7 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
297
350
|
|
|
298
351
|
/**
|
|
299
352
|
* Returns the parent HTML Element holding the main canvas of this application
|
|
300
|
-
* @returns {HTMLElement}
|
|
353
|
+
* @returns {HTMLElement} the parent HTML element
|
|
301
354
|
*/
|
|
302
355
|
getParentElement() {
|
|
303
356
|
return this.parentElement;
|
|
@@ -313,9 +366,8 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
313
366
|
/**
|
|
314
367
|
* update all objects related to this game active scene/stage
|
|
315
368
|
* @param {number} time - current timestamp as provided by the RAF callback
|
|
316
|
-
* @param {Stage} stage - the current stage
|
|
317
369
|
*/
|
|
318
|
-
update(time
|
|
370
|
+
update(time) {
|
|
319
371
|
// handle frame skipping if required
|
|
320
372
|
if ((++this.frameCounter % this.frameRate) === 0) {
|
|
321
373
|
// reset the frame counter
|
|
@@ -339,7 +391,8 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
339
391
|
}
|
|
340
392
|
|
|
341
393
|
// update all objects (and pass the elapsed time since last frame)
|
|
342
|
-
this.isDirty =
|
|
394
|
+
this.isDirty = this.world.update(this.updateDelta);
|
|
395
|
+
this.isDirty = state.current().update(this.updateDelta) || this.isDirty;
|
|
343
396
|
|
|
344
397
|
this.lastUpdate = globalThis.performance.now();
|
|
345
398
|
this.updateAverageDelta = this.lastUpdate - this.lastUpdateStart;
|
|
@@ -358,9 +411,8 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
358
411
|
|
|
359
412
|
/**
|
|
360
413
|
* draw the active scene/stage associated to this game
|
|
361
|
-
* @param {Stage} stage - the current stage
|
|
362
414
|
*/
|
|
363
|
-
draw(
|
|
415
|
+
draw() {
|
|
364
416
|
if (this.renderer.isContextValid === true && (this.isDirty || this.isAlwaysDirty)) {
|
|
365
417
|
// publish notification
|
|
366
418
|
emit(GAME_BEFORE_DRAW, globalThis.performance.now());
|
|
@@ -369,7 +421,7 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
369
421
|
this.renderer.clear();
|
|
370
422
|
|
|
371
423
|
// render the stage
|
|
372
|
-
|
|
424
|
+
state.current().draw(this.renderer, this.world);
|
|
373
425
|
|
|
374
426
|
// set back to flag
|
|
375
427
|
this.isDirty = false;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.4.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
|
|
@@ -9,7 +9,7 @@ import { devicePixelRatio, platform, getScreenOrientation, language, hasWebAudio
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* display information
|
|
12
|
-
* @param {Application}
|
|
12
|
+
* @param {Application} app - the game application instance calling this function
|
|
13
13
|
*/
|
|
14
14
|
function consoleHeader(app) {
|
|
15
15
|
let renderType = app.renderer.type;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.4.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
|
-
import { getParentBounds, devicePixelRatio } from '../system/device.js';
|
|
8
|
+
import { getElementBounds, getParentBounds, devicePixelRatio } from '../system/device.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* scale the "displayed" canvas by the given scalar.
|
|
@@ -49,7 +49,8 @@ function scale(game, x, y) {
|
|
|
49
49
|
function onresize(game) {
|
|
50
50
|
let renderer = game.renderer;
|
|
51
51
|
let settings = renderer.settings;
|
|
52
|
-
let scaleX =
|
|
52
|
+
let scaleX = settings.scale, scaleY = settings.scale;
|
|
53
|
+
let nodeBounds;
|
|
53
54
|
|
|
54
55
|
if (settings.autoScale) {
|
|
55
56
|
|
|
@@ -63,8 +64,13 @@ function onresize(game) {
|
|
|
63
64
|
canvasMaxHeight = parseInt(style.maxHeight, 10) || Infinity;
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
if (typeof game.settings.scaleTarget !== "undefined") {
|
|
68
|
+
// get the bounds of the given scale target
|
|
69
|
+
nodeBounds = getElementBounds(game.settings.scaleTarget);
|
|
70
|
+
} else {
|
|
71
|
+
// get the maximum canvas size within the parent div containing the canvas container
|
|
72
|
+
nodeBounds = getParentBounds(game.getParentElement());
|
|
73
|
+
}
|
|
68
74
|
|
|
69
75
|
let _max_width = Math.min(canvasMaxWidth, nodeBounds.width);
|
|
70
76
|
let _max_height = Math.min(canvasMaxHeight, nodeBounds.height);
|
|
@@ -109,13 +115,9 @@ function onresize(game) {
|
|
|
109
115
|
scaleX = scaleY = _max_height / settings.height;
|
|
110
116
|
}
|
|
111
117
|
}
|
|
112
|
-
|
|
113
|
-
// adjust scaling ratio based on the new scaling ratio
|
|
114
|
-
scale(game, scaleX, scaleY);
|
|
115
|
-
} else {
|
|
116
|
-
// adjust scaling ratio based on the given settings
|
|
117
|
-
scale(game, settings.scale, settings.scale);
|
|
118
118
|
}
|
|
119
|
+
// adjust scaling ratio
|
|
120
|
+
scale(game, scaleX, scaleY);
|
|
119
121
|
}
|
|
120
122
|
|
|
121
123
|
export { onresize };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.4.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,6 +12,7 @@ const defaultSettings = {
|
|
|
12
12
|
autoScale : false,
|
|
13
13
|
scale : 1.0,
|
|
14
14
|
scaleMethod : "manual",
|
|
15
|
+
scaleTarget : undefined,
|
|
15
16
|
transparent : false,
|
|
16
17
|
premultipliedAlpha: true,
|
|
17
18
|
blendMode : "normal",
|
|
@@ -25,4 +26,39 @@ const defaultSettings = {
|
|
|
25
26
|
legacy : false
|
|
26
27
|
};
|
|
27
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Application & Renderer Settings definition.
|
|
31
|
+
* @typedef {object} Settings
|
|
32
|
+
* @property {string|HTMLElement} [parent=document.body] - the DOM parent element to hold the canvas in the HTML file
|
|
33
|
+
* @property {number|Renderer} [renderer=AUTO] - renderer to use (CANVAS, WEBGL, AUTO), or a custom renderer class
|
|
34
|
+
* @property {number|string} [scale=1.0] - enable scaling of the canvas ('auto' for automatic scaling)
|
|
35
|
+
* @property {"fit"|"fill-min"|"fill-max"|"flex"|"flex-width"|"flex-height"|"stretch"} [scaleMethod="fit"] - screen scaling modes : <br>
|
|
36
|
+
* - <i><b>`fit`</b></i> : Letterboxed; content is scaled to design aspect ratio <br>
|
|
37
|
+
* <center><img src="images/scale-fit.png"/></center><br>
|
|
38
|
+
* - <i><b>`fill-min`</b></i> : Canvas is resized to fit minimum design resolution; content is scaled to design aspect ratio <br>
|
|
39
|
+
* <center><img src="images/scale-fill-min.png"/></center><br>
|
|
40
|
+
* - <i><b>`fill-max`</b></i> : Canvas is resized to fit maximum design resolution; content is scaled to design aspect ratio <br>
|
|
41
|
+
* <center><img src="images/scale-fill-max.png"/></center><br>
|
|
42
|
+
* - <i><b>`flex`</b><</i> : Canvas width & height is resized to fit; content is scaled to design aspect ratio <br>
|
|
43
|
+
* <center><img src="images/scale-flex.png"/></center><br>
|
|
44
|
+
* - <i><b>`flex-width`</b></i> : Canvas width is resized to fit; content is scaled to design aspect ratio <br>
|
|
45
|
+
* <center><img src="images/scale-flex-width.png"/></center><br>
|
|
46
|
+
* - <i><b>`flex-height`</b></i> : Canvas height is resized to fit; content is scaled to design aspect ratio <br>
|
|
47
|
+
* <center><img src="images/scale-flex-height.png"/></center><br>
|
|
48
|
+
* - <i><b>`stretch`</b></i> : Canvas is resized to fit; content is scaled to screen aspect ratio <br>
|
|
49
|
+
* <center><img src="images/scale-stretch.png"/></center>
|
|
50
|
+
* @property {string|HTMLElement} [scaleTarget] - the HTML Element to be used as the reference target when using automatic scaling (by default melonJS will use the parent container of the div element containing the canvas)
|
|
51
|
+
* @property {boolean} [preferWebGL1=false] - if true the renderer will only use WebGL 1
|
|
52
|
+
* @property {"sorting"|"z-buffer"} [depthTest="sorting"] - ~Experimental~ the default method to sort object on the z axis in WebGL
|
|
53
|
+
* @property {("default"|"high-performance"|"low-power")} [powerPreference="default"] - a hint to the user agent indicating what configuration of GPU is suitable for the WebGL context. 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.
|
|
54
|
+
* @property {boolean} [transparent=false] - whether to allow transparent pixels in the front buffer (screen).
|
|
55
|
+
* @property {boolean} [antiAlias=false] - whether to enable or not video scaling interpolation
|
|
56
|
+
* @property {boolean} [consoleHeader=true] - whether to display melonJS version and basic device information in the console
|
|
57
|
+
* @param {number} [options.zoomX=width] - The actual width of the canvas with scaling applied
|
|
58
|
+
* @param {number} [options.zoomY=height] - The actual height of the canvas with scaling applied
|
|
59
|
+
* @param {Compositor} [options.compositor] - a custom compositor class (WebGL only)
|
|
60
|
+
* @see Application
|
|
61
|
+
* @memberof Application
|
|
62
|
+
*/
|
|
63
|
+
|
|
28
64
|
export { defaultSettings };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.4.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
|
|
@@ -75,15 +75,13 @@ let stopOnAudioError = true;
|
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* Initialize and configure the audio support.<br>
|
|
78
|
-
* melonJS supports a wide array of audio codecs that have varying browser support :
|
|
79
|
-
* <i> ("mp3", "mpeg", opus", "ogg", "oga", "wav", "aac", "caf", "m4a", "m4b", "mp4", "weba", "webm", "dolby", "flac")</i>.<br>
|
|
80
78
|
* For a maximum browser coverage the recommendation is to use at least two of them,
|
|
81
79
|
* typically default to webm and then fallback to mp3 for the best balance of small filesize and high quality,
|
|
82
80
|
* webm has nearly full browser coverage with a great combination of compression and quality, and mp3 will fallback gracefully for other browsers.
|
|
83
81
|
* It is important to remember that melonJS selects the first compatible sound based on the list of extensions and given order passed here.
|
|
84
82
|
* So if you want webm to be used before mp3, you need to put the audio format in that order.
|
|
85
83
|
* @function audio.init
|
|
86
|
-
* @param {
|
|
84
|
+
* @param {"mp3"|"mpeg"|"opus"|"ogg"|"oga"|"wav"|"aac"|"caf"|"m4a"|"m4b"|"mp4"|"weba"|"webm"|"dolby"|"flac"} [format="mp3"] - audio format to prioritize
|
|
87
85
|
* @returns {boolean} Indicates whether audio initialization was successful
|
|
88
86
|
* @example
|
|
89
87
|
* // initialize the "sound engine", giving "webm" as default desired audio format, and "mp3" as a fallback
|
|
@@ -92,7 +90,7 @@ let stopOnAudioError = true;
|
|
|
92
90
|
* return;
|
|
93
91
|
* }
|
|
94
92
|
*/
|
|
95
|
-
|
|
93
|
+
function init(format = "mp3") {
|
|
96
94
|
// convert it into an array
|
|
97
95
|
audioExts = format.split(",");
|
|
98
96
|
|
|
@@ -102,7 +100,7 @@ let stopOnAudioError = true;
|
|
|
102
100
|
/**
|
|
103
101
|
* check if the given audio format is supported
|
|
104
102
|
* @function audio.hasFormat
|
|
105
|
-
* @param {
|
|
103
|
+
* @param {"mp3"|"mpeg"|"opus"|"ogg"|"oga"|"wav"|"aac"|"caf"|"m4a"|"m4b"|"mp4"|"weba"|"webm"|"dolby"|"flac"} codec - the audio format to check for support
|
|
106
104
|
* @returns {boolean} return true if the given audio format is supported
|
|
107
105
|
*/
|
|
108
106
|
function hasFormat(codec) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.4.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
|
|
@@ -29,7 +29,7 @@ let targetV = new Vector2d();
|
|
|
29
29
|
* a 2D orthographic camera
|
|
30
30
|
* @augments Renderable
|
|
31
31
|
*/
|
|
32
|
-
|
|
32
|
+
class Camera2d extends Renderable {
|
|
33
33
|
/**
|
|
34
34
|
* @param {number} minX - start x offset
|
|
35
35
|
* @param {number} minY - start y offset
|
|
@@ -213,8 +213,8 @@ let targetV = new Vector2d();
|
|
|
213
213
|
* reset the camera position to specified coordinates
|
|
214
214
|
* @name reset
|
|
215
215
|
* @memberof Camera2d
|
|
216
|
-
* @param {number} [x=0]
|
|
217
|
-
* @param {number} [y=0]
|
|
216
|
+
* @param {number} [x=0] - initial position of the camera on the x axis
|
|
217
|
+
* @param {number} [y=0] - initial position of the camera on the y axis
|
|
218
218
|
*/
|
|
219
219
|
reset(x = 0, y = 0) {
|
|
220
220
|
// reset the initial camera position to 0,0
|
|
@@ -371,8 +371,8 @@ let targetV = new Vector2d();
|
|
|
371
371
|
* @name move
|
|
372
372
|
* @memberof Camera2d
|
|
373
373
|
* @see Camera2d.focusOn
|
|
374
|
-
* @param {number} x
|
|
375
|
-
* @param {number} y
|
|
374
|
+
* @param {number} x - horizontal offset
|
|
375
|
+
* @param {number} y - vertical offset
|
|
376
376
|
* @example
|
|
377
377
|
* // Move the camera up by four pixels
|
|
378
378
|
* me.game.viewport.move(0, -4);
|
|
@@ -593,7 +593,7 @@ let targetV = new Vector2d();
|
|
|
593
593
|
* @memberof Camera2d
|
|
594
594
|
* @param {Renderable|Entity|Sprite|NineSliceSprite} obj - to be checked against
|
|
595
595
|
* @param {boolean} [floating = obj.floating] - if visibility check should be done against screen coordinates
|
|
596
|
-
* @returns {boolean}
|
|
596
|
+
* @returns {boolean} true if within the viewport
|
|
597
597
|
*/
|
|
598
598
|
isVisible(obj, floating = obj.floating) {
|
|
599
599
|
if (floating === true || obj.floating === true) {
|
|
@@ -609,10 +609,9 @@ let targetV = new Vector2d();
|
|
|
609
609
|
* convert the given "local" (screen) coordinates into world coordinates
|
|
610
610
|
* @name localToWorld
|
|
611
611
|
* @memberof Camera2d
|
|
612
|
-
* @param {number} x
|
|
613
|
-
* @param {number} y
|
|
614
|
-
* @param {number} [v] - an optional vector object where to set the
|
|
615
|
-
* converted value
|
|
612
|
+
* @param {number} x - the x coordinate of the local point to be converted
|
|
613
|
+
* @param {number} y - the y coordinate of the local point to be converted
|
|
614
|
+
* @param {number} [v] - an optional vector object where to set the converted value
|
|
616
615
|
* @returns {Vector2d}
|
|
617
616
|
*/
|
|
618
617
|
localToWorld(x, y, v) {
|
|
@@ -631,9 +630,8 @@ let targetV = new Vector2d();
|
|
|
631
630
|
* @memberof Camera2d
|
|
632
631
|
* @param {number} x
|
|
633
632
|
* @param {number} y
|
|
634
|
-
* @param {number} [v] - an optional vector object where to set the
|
|
635
|
-
* converted
|
|
636
|
-
* @returns {Vector2d}
|
|
633
|
+
* @param {number} [v] - an optional vector object where to set the converted value
|
|
634
|
+
* @returns {Vector2d} a vector with the converted local coordinates
|
|
637
635
|
*/
|
|
638
636
|
worldToLocal(x, y, v) {
|
|
639
637
|
// TODO memoization for one set of coords (multitouch)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.4.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
|
|
@@ -16,7 +16,7 @@ import Body from '../physics/body.js';
|
|
|
16
16
|
* @augments Renderable
|
|
17
17
|
* @see Renderable
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
class Entity extends Renderable {
|
|
20
20
|
/**
|
|
21
21
|
* @param {number} x - the x coordinates of the entity object
|
|
22
22
|
* @param {number} y - the y coordinates of the entity object
|
|
@@ -186,7 +186,7 @@ import Body from '../physics/body.js';
|
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
if (absolute === true) {
|
|
189
|
-
|
|
189
|
+
let absPos = this.getAbsolutePosition();
|
|
190
190
|
bounds.centerOn(absPos.x + bounds.x + bounds.width / 2, absPos.y + bounds.y + bounds.height / 2);
|
|
191
191
|
}
|
|
192
192
|
|
|
@@ -198,7 +198,6 @@ import Body from '../physics/body.js';
|
|
|
198
198
|
* @ignore
|
|
199
199
|
* @name onBodyUpdate
|
|
200
200
|
* @memberof Entity
|
|
201
|
-
* @param {Body} body - the body whose bounds to update
|
|
202
201
|
*/
|
|
203
202
|
onBodyUpdate() {
|
|
204
203
|
this.updateBounds();
|