melonjs 15.3.0 → 15.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +53 -5
- package/dist/melonjs.mjs/application/header.js +2 -2
- package/dist/melonjs.mjs/application/resize.js +4 -8
- package/dist/melonjs.mjs/application/settings.js +5 -5
- 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 +26 -29
- 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 +2 -2
- 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 +26 -26
- 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 +2 -2
- package/dist/melonjs.mjs/state/state.js +1 -38
- package/dist/melonjs.mjs/system/device.js +49 -10
- package/dist/melonjs.mjs/system/dom.js +1 -1
- package/dist/melonjs.mjs/system/event.js +24 -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 +3 -7
- package/dist/melonjs.mjs/video/renderer.js +16 -16
- 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 +4 -4
- 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 +50 -52
- package/dist/melonjs.module.js +1137 -1576
- package/dist/types/application/application.d.ts +28 -4
- package/dist/types/application/header.d.ts +2 -2
- package/dist/types/application/settings.d.ts +23 -23
- package/dist/types/audio/audio.d.ts +3 -5
- 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/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 +9 -16
- 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/state.d.ts +11 -11
- package/dist/types/system/device.d.ts +15 -9
- package/dist/types/system/event.d.ts +20 -0
- package/dist/types/system/platform.d.ts +17 -17
- package/dist/types/utils/function.d.ts +1 -2
- package/dist/types/video/renderer.d.ts +13 -13
- package/dist/types/video/texture/canvas_texture.d.ts +14 -14
- package/dist/types/video/video.d.ts +2 -2
- 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 +47 -50
- package/package.json +15 -15
- package/src/application/application.js +51 -3
- package/src/application/header.js +1 -1
- package/src/application/resize.js +3 -7
- package/src/application/settings.js +4 -4
- 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 +25 -28
- 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 +1 -1
- 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 +25 -25
- 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 +1 -1
- package/src/state/state.js +0 -49
- package/src/system/device.js +48 -9
- package/src/system/event.js +22 -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 +2 -6
- package/src/video/renderer.js +15 -15
- package/src/video/texture/atlas.js +12 -12
- package/src/video/texture/canvas_texture.js +14 -14
- package/src/video/video.js +3 -3
- 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 +49 -51
- /package/src/{text → renderable/text}/textstyle.js +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.4.1
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -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, 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, 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,7 +24,7 @@ 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
|
|
@@ -88,10 +88,34 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
90
|
* the given settings used when creating this application
|
|
91
|
-
* @type {
|
|
91
|
+
* @type {object}
|
|
92
92
|
*/
|
|
93
93
|
this.settings = undefined;
|
|
94
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
|
+
|
|
95
119
|
// to know when we have to refresh the display
|
|
96
120
|
this.isDirty = true;
|
|
97
121
|
|
|
@@ -123,6 +147,9 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
123
147
|
|
|
124
148
|
/**
|
|
125
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
|
|
126
153
|
*/
|
|
127
154
|
init(width, height, options) {
|
|
128
155
|
|
|
@@ -238,6 +265,27 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
238
265
|
// render all game objects
|
|
239
266
|
this.draw();
|
|
240
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
|
+
});
|
|
241
289
|
}
|
|
242
290
|
|
|
243
291
|
/**
|
|
@@ -302,7 +350,7 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
302
350
|
|
|
303
351
|
/**
|
|
304
352
|
* Returns the parent HTML Element holding the main canvas of this application
|
|
305
|
-
* @returns {HTMLElement}
|
|
353
|
+
* @returns {HTMLElement} the parent HTML element
|
|
306
354
|
*/
|
|
307
355
|
getParentElement() {
|
|
308
356
|
return this.parentElement;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.4.1
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -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,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.4.1
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -49,7 +49,7 @@ 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
53
|
let nodeBounds;
|
|
54
54
|
|
|
55
55
|
if (settings.autoScale) {
|
|
@@ -115,13 +115,9 @@ function onresize(game) {
|
|
|
115
115
|
scaleX = scaleY = _max_height / settings.height;
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
|
|
119
|
-
// adjust scaling ratio based on the new scaling ratio
|
|
120
|
-
scale(game, scaleX, scaleY);
|
|
121
|
-
} else {
|
|
122
|
-
// adjust scaling ratio based on the given settings
|
|
123
|
-
scale(game, settings.scale, settings.scale);
|
|
124
118
|
}
|
|
119
|
+
// adjust scaling ratio
|
|
120
|
+
scale(game, scaleX, scaleY);
|
|
125
121
|
}
|
|
126
122
|
|
|
127
123
|
export { onresize };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.4.1
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -28,11 +28,11 @@ const defaultSettings = {
|
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Application & Renderer Settings definition.
|
|
31
|
-
* @typedef {
|
|
31
|
+
* @typedef {object} Settings
|
|
32
32
|
* @property {string|HTMLElement} [parent=document.body] - the DOM parent element to hold the canvas in the HTML file
|
|
33
33
|
* @property {number|Renderer} [renderer=AUTO] - renderer to use (CANVAS, WEBGL, AUTO), or a custom renderer class
|
|
34
34
|
* @property {number|string} [scale=1.0] - enable scaling of the canvas ('auto' for automatic scaling)
|
|
35
|
-
* @property {
|
|
35
|
+
* @property {"fit"|"fill-min"|"fill-max"|"flex"|"flex-width"|"flex-height"|"stretch"} [scaleMethod="fit"] - screen scaling modes : <br>
|
|
36
36
|
* - <i><b>`fit`</b></i> : Letterboxed; content is scaled to design aspect ratio <br>
|
|
37
37
|
* <center><img src="images/scale-fit.png"/></center><br>
|
|
38
38
|
* - <i><b>`fill-min`</b></i> : Canvas is resized to fit minimum design resolution; content is scaled to design aspect ratio <br>
|
|
@@ -49,8 +49,8 @@ const defaultSettings = {
|
|
|
49
49
|
* <center><img src="images/scale-stretch.png"/></center>
|
|
50
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
51
|
* @property {boolean} [preferWebGL1=false] - if true the renderer will only use WebGL 1
|
|
52
|
-
* @property {
|
|
53
|
-
* @property {
|
|
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
54
|
* @property {boolean} [transparent=false] - whether to allow transparent pixels in the front buffer (screen).
|
|
55
55
|
* @property {boolean} [antiAlias=false] - whether to enable or not video scaling interpolation
|
|
56
56
|
* @property {boolean} [consoleHeader=true] - whether to display melonJS version and basic device information in the console
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.4.1
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -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 {string} [format="mp3"] - audio format to prioritize
|
|
84
|
+
* @param {string} [format="mp3"] - audio format to prioritize ("mp3"|"mpeg"|"opus"|"ogg"|"oga"|"wav"|"aac"|"caf"|"m4a"|"m4b"|"mp4"|"weba"|"webm"|"dolby"|"flac")
|
|
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.1
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -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.1
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -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();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.4.1
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -11,7 +11,7 @@ import pool from '../system/pooling.js';
|
|
|
11
11
|
* @classdesc
|
|
12
12
|
* an ellipse Object
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
class Ellipse {
|
|
15
15
|
/**
|
|
16
16
|
* @param {number} x - the center x coordinate of the ellipse
|
|
17
17
|
* @param {number} y - the center y coordinate of the ellipse
|
|
@@ -23,8 +23,6 @@ import pool from '../system/pooling.js';
|
|
|
23
23
|
* the center coordinates of the ellipse
|
|
24
24
|
* @public
|
|
25
25
|
* @type {Vector2d}
|
|
26
|
-
* @name pos
|
|
27
|
-
* @memberof Ellipse
|
|
28
26
|
*/
|
|
29
27
|
this.pos = pool.pull("Vector2d");
|
|
30
28
|
|
|
@@ -38,8 +36,6 @@ import pool from '../system/pooling.js';
|
|
|
38
36
|
* Maximum radius of the ellipse
|
|
39
37
|
* @public
|
|
40
38
|
* @type {number}
|
|
41
|
-
* @name radius
|
|
42
|
-
* @memberof Ellipse
|
|
43
39
|
*/
|
|
44
40
|
this.radius = NaN;
|
|
45
41
|
|
|
@@ -47,8 +43,6 @@ import pool from '../system/pooling.js';
|
|
|
47
43
|
* Pre-scaled radius vector for ellipse
|
|
48
44
|
* @public
|
|
49
45
|
* @type {Vector2d}
|
|
50
|
-
* @name radiusV
|
|
51
|
-
* @memberof Ellipse
|
|
52
46
|
*/
|
|
53
47
|
this.radiusV = pool.pull("Vector2d");
|
|
54
48
|
|
|
@@ -56,8 +50,6 @@ import pool from '../system/pooling.js';
|
|
|
56
50
|
* Radius squared, for pythagorean theorom
|
|
57
51
|
* @public
|
|
58
52
|
* @type {Vector2d}
|
|
59
|
-
* @name radiusSq
|
|
60
|
-
* @memberof Ellipse
|
|
61
53
|
*/
|
|
62
54
|
this.radiusSq = pool.pull("Vector2d");
|
|
63
55
|
|
|
@@ -65,8 +57,6 @@ import pool from '../system/pooling.js';
|
|
|
65
57
|
* x/y scaling ratio for ellipse
|
|
66
58
|
* @public
|
|
67
59
|
* @type {Vector2d}
|
|
68
|
-
* @name ratio
|
|
69
|
-
* @memberof Ellipse
|
|
70
60
|
*/
|
|
71
61
|
this.ratio = pool.pull("Vector2d");
|
|
72
62
|
|
|
@@ -82,8 +72,6 @@ import pool from '../system/pooling.js';
|
|
|
82
72
|
|
|
83
73
|
/**
|
|
84
74
|
* set new value to the Ellipse shape
|
|
85
|
-
* @name setShape
|
|
86
|
-
* @memberof Ellipse
|
|
87
75
|
* @param {number} x - the center x coordinate of the ellipse
|
|
88
76
|
* @param {number} y - the center y coordinate of the ellipse
|
|
89
77
|
* @param {number} w - width (diameter) of the ellipse
|
|
@@ -111,8 +99,6 @@ import pool from '../system/pooling.js';
|
|
|
111
99
|
|
|
112
100
|
/**
|
|
113
101
|
* Rotate this Ellipse (counter-clockwise) by the specified angle (in radians).
|
|
114
|
-
* @name rotate
|
|
115
|
-
* @memberof Ellipse
|
|
116
102
|
* @param {number} angle - The angle to rotate (in radians)
|
|
117
103
|
* @param {Vector2d|ObservableVector2d} [v] - an optional point to rotate around
|
|
118
104
|
* @returns {Ellipse} Reference to this object for method chaining
|
|
@@ -127,10 +113,8 @@ import pool from '../system/pooling.js';
|
|
|
127
113
|
|
|
128
114
|
/**
|
|
129
115
|
* Scale this Ellipse by the specified scalar.
|
|
130
|
-
* @
|
|
131
|
-
* @
|
|
132
|
-
* @param {number} x
|
|
133
|
-
* @param {number} [y=x]
|
|
116
|
+
* @param {number} x - the scale factor along the x-axis
|
|
117
|
+
* @param {number} [y=x] - the scale factor along the y-axis
|
|
134
118
|
* @returns {Ellipse} Reference to this object for method chaining
|
|
135
119
|
*/
|
|
136
120
|
scale(x, y = x) {
|
|
@@ -144,8 +128,6 @@ import pool from '../system/pooling.js';
|
|
|
144
128
|
|
|
145
129
|
/**
|
|
146
130
|
* Scale this Ellipse by the specified vector.
|
|
147
|
-
* @name scale
|
|
148
|
-
* @memberof Ellipse
|
|
149
131
|
* @param {Vector2d} v
|
|
150
132
|
* @returns {Ellipse} Reference to this object for method chaining
|
|
151
133
|
*/
|
|
@@ -155,8 +137,6 @@ import pool from '../system/pooling.js';
|
|
|
155
137
|
|
|
156
138
|
/**
|
|
157
139
|
* apply the given transformation matrix to this ellipse
|
|
158
|
-
* @name transform
|
|
159
|
-
* @memberof Ellipse
|
|
160
140
|
* @param {Matrix2d} matrix - the transformation matrix
|
|
161
141
|
* @returns {Polygon} Reference to this object for method chaining
|
|
162
142
|
*/
|
|
@@ -167,19 +147,13 @@ import pool from '../system/pooling.js';
|
|
|
167
147
|
|
|
168
148
|
/**
|
|
169
149
|
* translate the circle/ellipse by the specified offset
|
|
170
|
-
* @
|
|
171
|
-
* @
|
|
172
|
-
* @method
|
|
173
|
-
* @param {number} x - x offset
|
|
174
|
-
* @param {number} y - y offset
|
|
175
|
-
* @returns {Ellipse} this ellipse
|
|
176
|
-
*/
|
|
177
|
-
/**
|
|
178
|
-
* translate the circle/ellipse by the specified vector
|
|
179
|
-
* @name translate
|
|
180
|
-
* @memberof Ellipse
|
|
181
|
-
* @param {Vector2d} v - vector offset
|
|
150
|
+
* @param {number|Vector2d} x - x coordinate or a vector point to translate by
|
|
151
|
+
* @param {number} [y] - y offset
|
|
182
152
|
* @returns {Ellipse} this ellipse
|
|
153
|
+
* @example
|
|
154
|
+
* ellipse.translate(10, 10);
|
|
155
|
+
* // or
|
|
156
|
+
* ellipse.translate(myVector2d);
|
|
183
157
|
*/
|
|
184
158
|
translate() {
|
|
185
159
|
let _x, _y;
|
|
@@ -203,32 +177,29 @@ import pool from '../system/pooling.js';
|
|
|
203
177
|
|
|
204
178
|
/**
|
|
205
179
|
* check if this circle/ellipse contains the specified point
|
|
206
|
-
* @
|
|
207
|
-
* @
|
|
208
|
-
* @memberof Ellipse
|
|
209
|
-
* @param {Vector2d} point
|
|
210
|
-
* @returns {boolean} true if contains
|
|
211
|
-
*/
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* check if this circle/ellipse contains the specified point
|
|
215
|
-
* @name contains
|
|
216
|
-
* @memberof Ellipse
|
|
217
|
-
* @param {number} x - x coordinate
|
|
218
|
-
* @param {number} y - y coordinate
|
|
180
|
+
* @param {number|Vector2d} x - x coordinate or a vector point to check
|
|
181
|
+
* @param {number} [y] - y coordinate
|
|
219
182
|
* @returns {boolean} true if contains
|
|
183
|
+
* @example
|
|
184
|
+
* if (circle.contains(10, 10)) {
|
|
185
|
+
* // do something
|
|
186
|
+
* }
|
|
187
|
+
* // or
|
|
188
|
+
* if (circle.contains(myVector2d)) {
|
|
189
|
+
* // do something
|
|
190
|
+
* }
|
|
220
191
|
*/
|
|
221
192
|
contains() {
|
|
222
193
|
let _x, _y;
|
|
223
194
|
|
|
224
195
|
if (arguments.length === 2) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
196
|
+
// x, y
|
|
197
|
+
_x = arguments[0];
|
|
198
|
+
_y = arguments[1];
|
|
228
199
|
} else {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
200
|
+
// vector
|
|
201
|
+
_x = arguments[0].x;
|
|
202
|
+
_y = arguments[0].y;
|
|
232
203
|
}
|
|
233
204
|
|
|
234
205
|
// Make position relative to object center point.
|
|
@@ -243,8 +214,6 @@ import pool from '../system/pooling.js';
|
|
|
243
214
|
|
|
244
215
|
/**
|
|
245
216
|
* returns the bounding box for this shape, the smallest Rectangle object completely containing this shape.
|
|
246
|
-
* @name getBounds
|
|
247
|
-
* @memberof Ellipse
|
|
248
217
|
* @returns {Bounds} this shape bounding box Rectangle object
|
|
249
218
|
*/
|
|
250
219
|
getBounds() {
|
|
@@ -256,8 +225,6 @@ import pool from '../system/pooling.js';
|
|
|
256
225
|
|
|
257
226
|
/**
|
|
258
227
|
* clone this Ellipse
|
|
259
|
-
* @name clone
|
|
260
|
-
* @memberof Ellipse
|
|
261
228
|
* @returns {Ellipse} new Ellipse
|
|
262
229
|
*/
|
|
263
230
|
clone() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.4.1
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -17,36 +17,33 @@ import Polygon from './poly.js';
|
|
|
17
17
|
* @param {Vector2d[]} points - array of vectors defining the Line
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
class Line extends Polygon {
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Returns true if the Line contains the given point
|
|
24
|
-
* @
|
|
25
|
-
* @
|
|
26
|
-
* @method
|
|
27
|
-
* @param {Vector2d} point
|
|
28
|
-
* @returns {boolean} true if contains
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Returns true if the Line contains the given point
|
|
33
|
-
* @name contains
|
|
34
|
-
* @memberof Line
|
|
35
|
-
* @param {number} x - x coordinate
|
|
36
|
-
* @param {number} y - y coordinate
|
|
24
|
+
* @param {number|Vector2d} x - x coordinate or a vector point to check
|
|
25
|
+
* @param {number} [y] - y coordinate
|
|
37
26
|
* @returns {boolean} true if contains
|
|
27
|
+
* @example
|
|
28
|
+
* if (line.contains(10, 10)) {
|
|
29
|
+
* // do something
|
|
30
|
+
* }
|
|
31
|
+
* // or
|
|
32
|
+
* if (line.contains(myVector2d)) {
|
|
33
|
+
* // do something
|
|
34
|
+
* }
|
|
38
35
|
*/
|
|
39
36
|
contains() {
|
|
40
37
|
let _x, _y;
|
|
41
38
|
|
|
42
39
|
if (arguments.length === 2) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
// x, y
|
|
41
|
+
_x = arguments[0];
|
|
42
|
+
_y = arguments[1];
|
|
46
43
|
} else {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
// vector
|
|
45
|
+
_x = arguments[0].x;
|
|
46
|
+
_y = arguments[0].y;
|
|
50
47
|
}
|
|
51
48
|
|
|
52
49
|
// translate the given coordinates,
|
|
@@ -63,8 +60,6 @@ import Polygon from './poly.js';
|
|
|
63
60
|
/**
|
|
64
61
|
* Computes the calculated collision edges and normals.
|
|
65
62
|
* This **must** be called if the `points` array, `angle`, or `offset` is modified manually.
|
|
66
|
-
* @name recalc
|
|
67
|
-
* @memberof Line
|
|
68
63
|
* @returns {Line} this instance for objecf chaining
|
|
69
64
|
*/
|
|
70
65
|
recalc() {
|
|
@@ -98,8 +93,6 @@ import Polygon from './poly.js';
|
|
|
98
93
|
|
|
99
94
|
/**
|
|
100
95
|
* clone this line segment
|
|
101
|
-
* @name clone
|
|
102
|
-
* @memberof Line
|
|
103
96
|
* @returns {Line} new Line
|
|
104
97
|
*/
|
|
105
98
|
clone() {
|