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
|
@@ -28,7 +28,6 @@ export default class QuadCompositor extends Compositor {
|
|
|
28
28
|
/**
|
|
29
29
|
* delete the given WebGL texture
|
|
30
30
|
* @param {WebGLTexture} [texture] - a WebGL texture to delete
|
|
31
|
-
* @param {number} [unit] - Texture unit to delete
|
|
32
31
|
*/
|
|
33
32
|
deleteTexture2D(texture?: WebGLTexture | undefined): void;
|
|
34
33
|
/**
|
|
@@ -7,7 +7,7 @@ export function setPrecision(src: any, precision: any): any;
|
|
|
7
7
|
/**
|
|
8
8
|
* return the highest precision format supported by this device for GL Shaders
|
|
9
9
|
* @ignore
|
|
10
|
-
* @param {WebGLRenderingContext} gl
|
|
10
|
+
* @param {WebGLRenderingContext} gl - the current WebGL context
|
|
11
11
|
* @returns {boolean} "lowp", "mediump", or "highp"
|
|
12
12
|
*/
|
|
13
13
|
export function getMaxShaderPrecision(gl: WebGLRenderingContext): boolean;
|
|
@@ -85,15 +85,15 @@ export default class WebGLRenderer extends Renderer {
|
|
|
85
85
|
/**
|
|
86
86
|
* add a new compositor to this renderer
|
|
87
87
|
* @param {Compositor} compositor - a compositor instance
|
|
88
|
-
* @param {
|
|
89
|
-
* @param {
|
|
88
|
+
* @param {string} name - a name uniquely identifying this compositor
|
|
89
|
+
* @param {boolean} [activate=false] - true if the given compositor should be set as the active one
|
|
90
90
|
*/
|
|
91
91
|
addCompositor(compositor: Compositor, name?: string, activate?: boolean | undefined): void;
|
|
92
92
|
/**
|
|
93
93
|
* set the active compositor for this renderer
|
|
94
|
-
* @param {
|
|
94
|
+
* @param {string} name - a compositor name
|
|
95
95
|
* @param {GLShader} [shader] - an optional shader program to be used, instead of the default one, when activating the compositor
|
|
96
|
-
* @
|
|
96
|
+
* @returns {Compositor} an instance to the current active compositor
|
|
97
97
|
*/
|
|
98
98
|
setCompositor(name?: string, shader?: any): Compositor;
|
|
99
99
|
/**
|
|
@@ -104,7 +104,7 @@ export default class WebGLRenderer extends Renderer {
|
|
|
104
104
|
* Create a pattern with the specified repetition
|
|
105
105
|
* @param {HTMLImageElement|SVGImageElement|HTMLVideoElement|HTMLCanvasElement|ImageBitmap|OffscreenCanvas|VideoFrame} image - Source image to be used as the pattern's image
|
|
106
106
|
* @param {string} repeat - Define how the pattern should be repeated
|
|
107
|
-
* @returns {TextureAtlas}
|
|
107
|
+
* @returns {TextureAtlas} the patterned texture created
|
|
108
108
|
* @see ImageLayer#repeat
|
|
109
109
|
* @example
|
|
110
110
|
* let tileable = renderer.createPattern(image, "repeat");
|
|
@@ -115,7 +115,7 @@ export default class WebGLRenderer extends Renderer {
|
|
|
115
115
|
createPattern(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas | VideoFrame, repeat: string): TextureAtlas;
|
|
116
116
|
/**
|
|
117
117
|
* set/change the current projection matrix (WebGL only)
|
|
118
|
-
* @param {Matrix3d} matrix
|
|
118
|
+
* @param {Matrix3d} matrix - the new projection matrix
|
|
119
119
|
*/
|
|
120
120
|
setProjection(matrix: Matrix3d): void;
|
|
121
121
|
/**
|
|
@@ -163,25 +163,25 @@ export default class WebGLRenderer extends Renderer {
|
|
|
163
163
|
/**
|
|
164
164
|
* Draw a pattern within the given rectangle.
|
|
165
165
|
* @param {TextureAtlas} pattern - Pattern object
|
|
166
|
-
* @param {number} x
|
|
167
|
-
* @param {number} y
|
|
168
|
-
* @param {number} width
|
|
169
|
-
* @param {number} height
|
|
166
|
+
* @param {number} x - x position where to draw the pattern
|
|
167
|
+
* @param {number} y - y position where to draw the pattern
|
|
168
|
+
* @param {number} width - width of the pattern
|
|
169
|
+
* @param {number} height - height of the pattern
|
|
170
170
|
* @see WebGLRenderer#createPattern
|
|
171
171
|
*/
|
|
172
172
|
drawPattern(pattern: TextureAtlas, x: number, y: number, width: number, height: number): void;
|
|
173
173
|
/**
|
|
174
174
|
* Returns the WebGL Context object of the given canvas element
|
|
175
|
-
* @param {HTMLCanvasElement} canvas
|
|
175
|
+
* @param {HTMLCanvasElement} canvas - the canvas element
|
|
176
176
|
* @param {boolean} [transparent=false] - use true to enable transparency
|
|
177
177
|
* @param {boolean} [depth=false] - use true to enable depth buffer testing
|
|
178
|
-
* @returns {WebGLRenderingContext}
|
|
178
|
+
* @returns {WebGLRenderingContext} the WebGL Context object
|
|
179
179
|
*/
|
|
180
180
|
getContextGL(canvas: HTMLCanvasElement, transparent?: boolean | undefined, depth?: boolean | undefined): WebGLRenderingContext;
|
|
181
181
|
/**
|
|
182
182
|
* Returns the WebGLContext instance for the renderer
|
|
183
183
|
* return a reference to the system 2d Context
|
|
184
|
-
* @returns {WebGLRenderingContext}
|
|
184
|
+
* @returns {WebGLRenderingContext} the current WebGL context
|
|
185
185
|
*/
|
|
186
186
|
getContext(): WebGLRenderingContext;
|
|
187
187
|
/**
|
|
@@ -197,10 +197,9 @@ export default class WebGLRenderer extends Renderer {
|
|
|
197
197
|
* <img src="images/screen-blendmode.png" width="510"/> <br>
|
|
198
198
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
|
|
199
199
|
* @param {string} [mode="normal"] - blend mode : "normal", "multiply", "lighter", "additive", "screen"
|
|
200
|
-
* @param {WebGLRenderingContext} [gl]
|
|
200
|
+
* @param {WebGLRenderingContext} [gl] - a WebGL context
|
|
201
201
|
*/
|
|
202
202
|
setBlendMode(mode?: string | undefined, gl?: WebGLRenderingContext | undefined): void;
|
|
203
|
-
currentBlendMode: any;
|
|
204
203
|
/**
|
|
205
204
|
* restores the canvas context
|
|
206
205
|
*/
|
|
@@ -216,8 +215,8 @@ export default class WebGLRenderer extends Renderer {
|
|
|
216
215
|
rotate(angle: number): void;
|
|
217
216
|
/**
|
|
218
217
|
* scales the uniform matrix
|
|
219
|
-
* @param {number} x
|
|
220
|
-
* @param {number} y
|
|
218
|
+
* @param {number} x - x-axis scale
|
|
219
|
+
* @param {number} y - y-axis scale
|
|
221
220
|
*/
|
|
222
221
|
scale(x: number, y: number): void;
|
|
223
222
|
/**
|
|
@@ -250,18 +249,18 @@ export default class WebGLRenderer extends Renderer {
|
|
|
250
249
|
* Stroke an arc at the specified coordinates with given radius, start and end points
|
|
251
250
|
* @param {number} x - arc center point x-axis
|
|
252
251
|
* @param {number} y - arc center point y-axis
|
|
253
|
-
* @param {number} radius
|
|
252
|
+
* @param {number} radius - arc radius
|
|
254
253
|
* @param {number} start - start angle in radians
|
|
255
254
|
* @param {number} end - end angle in radians
|
|
256
255
|
* @param {boolean} [antiClockwise=false] - draw arc anti-clockwise
|
|
257
|
-
* @param {boolean} [fill=false]
|
|
256
|
+
* @param {boolean} [fill=false] - also fill the shape with the current color if true
|
|
258
257
|
*/
|
|
259
258
|
strokeArc(x: number, y: number, radius: number, start: number, end: number, antiClockwise?: boolean | undefined, fill?: boolean | undefined): void;
|
|
260
259
|
/**
|
|
261
260
|
* Fill an arc at the specified coordinates with given radius, start and end points
|
|
262
261
|
* @param {number} x - arc center point x-axis
|
|
263
262
|
* @param {number} y - arc center point y-axis
|
|
264
|
-
* @param {number} radius
|
|
263
|
+
* @param {number} radius - arc radius
|
|
265
264
|
* @param {number} start - start angle in radians
|
|
266
265
|
* @param {number} end - end angle in radians
|
|
267
266
|
* @param {boolean} [antiClockwise=false] - draw arc anti-clockwise
|
|
@@ -313,52 +312,50 @@ export default class WebGLRenderer extends Renderer {
|
|
|
313
312
|
fillPolygon(poly: Polygon): void;
|
|
314
313
|
/**
|
|
315
314
|
* Draw a stroke rectangle at the specified coordinates
|
|
316
|
-
* @param {number} x
|
|
317
|
-
* @param {number} y
|
|
318
|
-
* @param {number} width
|
|
319
|
-
* @param {number} height
|
|
315
|
+
* @param {number} x - x axis of the coordinate for the rectangle starting point.
|
|
316
|
+
* @param {number} y - y axis of the coordinate for the rectangle starting point.
|
|
317
|
+
* @param {number} width - The rectangle's width.
|
|
318
|
+
* @param {number} height - The rectangle's height.
|
|
320
319
|
* @param {boolean} [fill=false] - also fill the shape with the current color if true
|
|
321
320
|
*/
|
|
322
321
|
strokeRect(x: number, y: number, width: number, height: number, fill?: boolean | undefined): void;
|
|
323
322
|
/**
|
|
324
323
|
* Draw a filled rectangle at the specified coordinates
|
|
325
|
-
* @param {number} x
|
|
326
|
-
* @param {number} y
|
|
327
|
-
* @param {number} width
|
|
328
|
-
* @param {number} height
|
|
324
|
+
* @param {number} x - x axis of the coordinate for the rectangle starting point.
|
|
325
|
+
* @param {number} y - y axis of the coordinate for the rectangle starting point.
|
|
326
|
+
* @param {number} width - The rectangle's width.
|
|
327
|
+
* @param {number} height - The rectangle's height.
|
|
329
328
|
*/
|
|
330
329
|
fillRect(x: number, y: number, width: number, height: number): void;
|
|
331
330
|
/**
|
|
332
331
|
* Stroke a rounded rectangle at the specified coordinates
|
|
333
|
-
* @param {number} x
|
|
334
|
-
* @param {number} y
|
|
335
|
-
* @param {number} width
|
|
336
|
-
* @param {number} height
|
|
337
|
-
* @param {number} radius
|
|
332
|
+
* @param {number} x - x axis of the coordinate for the rounded rectangle starting point.
|
|
333
|
+
* @param {number} y - y axis of the coordinate for the rounded rectangle starting point.
|
|
334
|
+
* @param {number} width - The rounded rectangle's width.
|
|
335
|
+
* @param {number} height - The rounded rectangle's height.
|
|
336
|
+
* @param {number} radius - The rounded corner's radius.
|
|
338
337
|
* @param {boolean} [fill=false] - also fill the shape with the current color if true
|
|
339
338
|
*/
|
|
340
339
|
strokeRoundRect(x: number, y: number, width: number, height: number, radius: number, fill?: boolean | undefined): void;
|
|
341
340
|
/**
|
|
342
341
|
* Draw a rounded filled rectangle at the specified coordinates
|
|
343
|
-
* @param {number} x
|
|
344
|
-
* @param {number} y
|
|
345
|
-
* @param {number} width
|
|
346
|
-
* @param {number} height
|
|
347
|
-
* @param {number} radius
|
|
342
|
+
* @param {number} x - x axis of the coordinate for the rounded rectangle starting point.
|
|
343
|
+
* @param {number} y - y axis of the coordinate for the rounded rectangle starting point.
|
|
344
|
+
* @param {number} width - The rounded rectangle's width.
|
|
345
|
+
* @param {number} height - The rounded rectangle's height.
|
|
346
|
+
* @param {number} radius - The rounded corner's radius.
|
|
348
347
|
*/
|
|
349
348
|
fillRoundRect(x: number, y: number, width: number, height: number, radius: number): void;
|
|
350
349
|
/**
|
|
351
350
|
* Stroke a Point at the specified coordinates
|
|
352
|
-
* @param {number} x
|
|
353
|
-
* @param {number} y
|
|
351
|
+
* @param {number} x - x axis of the coordinate for the point.
|
|
352
|
+
* @param {number} y - y axis of the coordinate for the point.
|
|
354
353
|
*/
|
|
355
354
|
strokePoint(x: number, y: number): void;
|
|
356
355
|
/**
|
|
357
356
|
* Draw a a point at the specified coordinates
|
|
358
|
-
* @param {number} x
|
|
359
|
-
* @param {number} y
|
|
360
|
-
* @param {number} width
|
|
361
|
-
* @param {number} height
|
|
357
|
+
* @param {number} x - x axis of the coordinate for the point.
|
|
358
|
+
* @param {number} y - y axis of the coordinate for the point.
|
|
362
359
|
*/
|
|
363
360
|
fillPoint(x: number, y: number): void;
|
|
364
361
|
/**
|
|
@@ -374,8 +371,8 @@ export default class WebGLRenderer extends Renderer {
|
|
|
374
371
|
transform(mat2d: Matrix2d): void;
|
|
375
372
|
/**
|
|
376
373
|
* Translates the uniform matrix by the given coordinates
|
|
377
|
-
* @param {number} x
|
|
378
|
-
* @param {number} y
|
|
374
|
+
* @param {number} x - x axis of the coordinate for the translation.
|
|
375
|
+
* @param {number} y - y axis of the coordinate for the translation.
|
|
379
376
|
*/
|
|
380
377
|
translate(x: number, y: number): void;
|
|
381
378
|
/**
|
|
@@ -384,10 +381,10 @@ export default class WebGLRenderer extends Renderer {
|
|
|
384
381
|
* You can however save the current region using the save(),
|
|
385
382
|
* and restore it (with the restore() method) any time in the future.
|
|
386
383
|
* (<u>this is an experimental feature !</u>)
|
|
387
|
-
* @param {number} x
|
|
388
|
-
* @param {number} y
|
|
389
|
-
* @param {number} width
|
|
390
|
-
* @param {number} height
|
|
384
|
+
* @param {number} x - x axis of the coordinate for the upper-left corner of the rectangle to start clipping from.
|
|
385
|
+
* @param {number} y - y axis of the coordinate for the upper-left corner of the rectangle to start clipping from.
|
|
386
|
+
* @param {number} width - the width of the rectangle to start clipping from.
|
|
387
|
+
* @param {number} height - the height of the rectangle to start clipping from.
|
|
391
388
|
*/
|
|
392
389
|
clipRect(x: number, y: number, width: number, height: number): void;
|
|
393
390
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "melonjs",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.4.1",
|
|
4
4
|
"description": "melonJS Game Engine",
|
|
5
5
|
"homepage": "http://www.melonjs.org/",
|
|
6
6
|
"type": "module",
|
|
@@ -53,37 +53,37 @@
|
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@teppeis/multimaps": "^3.0.0",
|
|
56
|
-
"core-js": "^3.
|
|
56
|
+
"core-js": "^3.31.0",
|
|
57
57
|
"earcut": "2.2.4",
|
|
58
58
|
"eventemitter3": "^5.0.1",
|
|
59
59
|
"howler": "2.2.3"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@babel/eslint-parser": "^7.
|
|
63
|
-
"@babel/plugin-syntax-import-assertions": "^7.
|
|
64
|
-
"@fastify/static": "^6.10.
|
|
62
|
+
"@babel/eslint-parser": "^7.22.5",
|
|
63
|
+
"@babel/plugin-syntax-import-assertions": "^7.22.5",
|
|
64
|
+
"@fastify/static": "^6.10.2",
|
|
65
65
|
"@melonjs/webdoc-theme": "^1.1.1",
|
|
66
|
-
"@rollup/plugin-commonjs": "^25.0.
|
|
66
|
+
"@rollup/plugin-commonjs": "^25.0.2",
|
|
67
67
|
"@rollup/plugin-image": "^3.0.2",
|
|
68
|
-
"@rollup/plugin-node-resolve": "^15.0
|
|
68
|
+
"@rollup/plugin-node-resolve": "^15.1.0",
|
|
69
69
|
"@rollup/plugin-replace": "^5.0.2",
|
|
70
70
|
"@webdoc/cli": "^2.2.0",
|
|
71
|
-
"chromedriver": "^
|
|
71
|
+
"chromedriver": "^114.0.2",
|
|
72
72
|
"cross-env": "^7.0.3",
|
|
73
73
|
"del-cli": "^5.0.0",
|
|
74
|
-
"eslint": "^8.
|
|
75
|
-
"eslint-plugin-jsdoc": "^
|
|
74
|
+
"eslint": "^8.43.0",
|
|
75
|
+
"eslint-plugin-jsdoc": "^46.2.6",
|
|
76
76
|
"expect": "^29.5.0",
|
|
77
77
|
"expect-mocha-image-snapshot": "^3.0.13",
|
|
78
|
-
"fastify": "^4.
|
|
78
|
+
"fastify": "^4.18.0",
|
|
79
79
|
"mocha": "^10.2.0",
|
|
80
80
|
"npm-self-link": "^1.1.7",
|
|
81
|
-
"puppeteer": "^20.3
|
|
82
|
-
"rollup": "^3.
|
|
81
|
+
"puppeteer": "^20.7.3",
|
|
82
|
+
"rollup": "^3.25.1",
|
|
83
83
|
"rollup-plugin-bundle-size": "^1.0.3",
|
|
84
84
|
"rollup-plugin-string": "^3.0.0",
|
|
85
|
-
"terser": "^5.
|
|
86
|
-
"typescript": "^5.
|
|
85
|
+
"terser": "^5.18.1",
|
|
86
|
+
"typescript": "^5.1.3"
|
|
87
87
|
},
|
|
88
88
|
"scripts": {
|
|
89
89
|
"build": "npm run lint && rollup -c --silent",
|
|
@@ -17,7 +17,7 @@ import { CANVAS, WEBGL, AUTO } from "../const.js";
|
|
|
17
17
|
* An Application is responsible for updating (each frame) all the related object status and draw them.
|
|
18
18
|
* @see game
|
|
19
19
|
*/
|
|
20
|
-
|
|
20
|
+
export default class Application {
|
|
21
21
|
/**
|
|
22
22
|
* @param {number} width - The width of the canvas viewport
|
|
23
23
|
* @param {number} height - The height of the canvas viewport
|
|
@@ -81,10 +81,34 @@ import { CANVAS, WEBGL, AUTO } from "../const.js";
|
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
* the given settings used when creating this application
|
|
84
|
-
* @type {
|
|
84
|
+
* @type {object}
|
|
85
85
|
*/
|
|
86
86
|
this.settings = undefined;
|
|
87
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Specify whether to pause this app when losing focus
|
|
90
|
+
* @type {boolean}
|
|
91
|
+
* @default true
|
|
92
|
+
* @example
|
|
93
|
+
* // keep the default game instance running even when loosing focus
|
|
94
|
+
* me.game.pauseOnBlur = false;
|
|
95
|
+
*/
|
|
96
|
+
this.pauseOnBlur = true;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Specify whether to unpause this app when gaining back focus
|
|
100
|
+
* @type {boolean}
|
|
101
|
+
* @default true
|
|
102
|
+
*/
|
|
103
|
+
this.resumeOnFocus = true;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Specify whether to stop this app when losing focus
|
|
107
|
+
* @type {boolean}
|
|
108
|
+
* @default false
|
|
109
|
+
*/
|
|
110
|
+
this.stopOnBlur = false;
|
|
111
|
+
|
|
88
112
|
// to know when we have to refresh the display
|
|
89
113
|
this.isDirty = true;
|
|
90
114
|
|
|
@@ -116,6 +140,9 @@ import { CANVAS, WEBGL, AUTO } from "../const.js";
|
|
|
116
140
|
|
|
117
141
|
/**
|
|
118
142
|
* init the game instance (create a physic world, update starting time, etc..)
|
|
143
|
+
* @param {number} width - The width of the canvas viewport
|
|
144
|
+
* @param {number} height - The height of the canvas viewport
|
|
145
|
+
* @param {Application.Settings} [options] - The optional parameters for the application and default renderer
|
|
119
146
|
*/
|
|
120
147
|
init(width, height, options) {
|
|
121
148
|
|
|
@@ -231,6 +258,27 @@ import { CANVAS, WEBGL, AUTO } from "../const.js";
|
|
|
231
258
|
// render all game objects
|
|
232
259
|
this.draw();
|
|
233
260
|
}, this);
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
// on blur event, pause the current
|
|
264
|
+
event.on(event.BLUR, () => {
|
|
265
|
+
if (this.stopOnBlur === true) {
|
|
266
|
+
state.stop(true);
|
|
267
|
+
}
|
|
268
|
+
if (this.pauseOnBlur === true) {
|
|
269
|
+
state.pause(true);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
// on focus event, restart or resume the current
|
|
274
|
+
event.on(event.FOCUS, () => {
|
|
275
|
+
if (this.stopOnBlur === true) {
|
|
276
|
+
state.restart(true);
|
|
277
|
+
}
|
|
278
|
+
if (this.resumeOnFocus === true) {
|
|
279
|
+
state.resume(true);
|
|
280
|
+
}
|
|
281
|
+
});
|
|
234
282
|
}
|
|
235
283
|
|
|
236
284
|
/**
|
|
@@ -295,7 +343,7 @@ import { CANVAS, WEBGL, AUTO } from "../const.js";
|
|
|
295
343
|
|
|
296
344
|
/**
|
|
297
345
|
* Returns the parent HTML Element holding the main canvas of this application
|
|
298
|
-
* @returns {HTMLElement}
|
|
346
|
+
* @returns {HTMLElement} the parent HTML element
|
|
299
347
|
*/
|
|
300
348
|
getParentElement() {
|
|
301
349
|
return this.parentElement;
|
|
@@ -2,7 +2,7 @@ import * as device from "../system/device";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* display information
|
|
5
|
-
* @param {Application}
|
|
5
|
+
* @param {Application} app - the game application instance calling this function
|
|
6
6
|
*/
|
|
7
7
|
export function consoleHeader(app) {
|
|
8
8
|
let renderType = app.renderer.type;
|
|
@@ -42,7 +42,7 @@ function scale(game, x, y) {
|
|
|
42
42
|
export function onresize(game) {
|
|
43
43
|
let renderer = game.renderer;
|
|
44
44
|
let settings = renderer.settings;
|
|
45
|
-
let scaleX =
|
|
45
|
+
let scaleX = settings.scale, scaleY = settings.scale;
|
|
46
46
|
let nodeBounds;
|
|
47
47
|
|
|
48
48
|
if (settings.autoScale) {
|
|
@@ -108,11 +108,7 @@ export function onresize(game) {
|
|
|
108
108
|
scaleX = scaleY = _max_height / settings.height;
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
|
|
112
|
-
// adjust scaling ratio based on the new scaling ratio
|
|
113
|
-
scale(game, scaleX, scaleY);
|
|
114
|
-
} else {
|
|
115
|
-
// adjust scaling ratio based on the given settings
|
|
116
|
-
scale(game, settings.scale, settings.scale);
|
|
117
111
|
}
|
|
112
|
+
// adjust scaling ratio
|
|
113
|
+
scale(game, scaleX, scaleY);
|
|
118
114
|
}
|
|
@@ -21,11 +21,11 @@ export const defaultSettings = {
|
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Application & Renderer Settings definition.
|
|
24
|
-
* @typedef {
|
|
24
|
+
* @typedef {object} Settings
|
|
25
25
|
* @property {string|HTMLElement} [parent=document.body] - the DOM parent element to hold the canvas in the HTML file
|
|
26
26
|
* @property {number|Renderer} [renderer=AUTO] - renderer to use (CANVAS, WEBGL, AUTO), or a custom renderer class
|
|
27
27
|
* @property {number|string} [scale=1.0] - enable scaling of the canvas ('auto' for automatic scaling)
|
|
28
|
-
* @property {
|
|
28
|
+
* @property {"fit"|"fill-min"|"fill-max"|"flex"|"flex-width"|"flex-height"|"stretch"} [scaleMethod="fit"] - screen scaling modes : <br>
|
|
29
29
|
* - <i><b>`fit`</b></i> : Letterboxed; content is scaled to design aspect ratio <br>
|
|
30
30
|
* <center><img src="images/scale-fit.png"/></center><br>
|
|
31
31
|
* - <i><b>`fill-min`</b></i> : Canvas is resized to fit minimum design resolution; content is scaled to design aspect ratio <br>
|
|
@@ -42,8 +42,8 @@ export const defaultSettings = {
|
|
|
42
42
|
* <center><img src="images/scale-stretch.png"/></center>
|
|
43
43
|
* @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)
|
|
44
44
|
* @property {boolean} [preferWebGL1=false] - if true the renderer will only use WebGL 1
|
|
45
|
-
* @property {
|
|
46
|
-
* @property {
|
|
45
|
+
* @property {"sorting"|"z-buffer"} [depthTest="sorting"] - ~Experimental~ the default method to sort object on the z axis in WebGL
|
|
46
|
+
* @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.
|
|
47
47
|
* @property {boolean} [transparent=false] - whether to allow transparent pixels in the front buffer (screen).
|
|
48
48
|
* @property {boolean} [antiAlias=false] - whether to enable or not video scaling interpolation
|
|
49
49
|
* @property {boolean} [consoleHeader=true] - whether to display melonJS version and basic device information in the console
|
package/src/audio/audio.js
CHANGED
|
@@ -76,15 +76,13 @@ export let stopOnAudioError = true;
|
|
|
76
76
|
|
|
77
77
|
/**
|
|
78
78
|
* Initialize and configure the audio support.<br>
|
|
79
|
-
* melonJS supports a wide array of audio codecs that have varying browser support :
|
|
80
|
-
* <i> ("mp3", "mpeg", opus", "ogg", "oga", "wav", "aac", "caf", "m4a", "m4b", "mp4", "weba", "webm", "dolby", "flac")</i>.<br>
|
|
81
79
|
* For a maximum browser coverage the recommendation is to use at least two of them,
|
|
82
80
|
* typically default to webm and then fallback to mp3 for the best balance of small filesize and high quality,
|
|
83
81
|
* webm has nearly full browser coverage with a great combination of compression and quality, and mp3 will fallback gracefully for other browsers.
|
|
84
82
|
* It is important to remember that melonJS selects the first compatible sound based on the list of extensions and given order passed here.
|
|
85
83
|
* So if you want webm to be used before mp3, you need to put the audio format in that order.
|
|
86
84
|
* @function audio.init
|
|
87
|
-
* @param {string} [format="mp3"] - audio format to prioritize
|
|
85
|
+
* @param {string} [format="mp3"] - audio format to prioritize ("mp3"|"mpeg"|"opus"|"ogg"|"oga"|"wav"|"aac"|"caf"|"m4a"|"m4b"|"mp4"|"weba"|"webm"|"dolby"|"flac")
|
|
88
86
|
* @returns {boolean} Indicates whether audio initialization was successful
|
|
89
87
|
* @example
|
|
90
88
|
* // initialize the "sound engine", giving "webm" as default desired audio format, and "mp3" as a fallback
|
|
@@ -93,7 +91,7 @@ export let stopOnAudioError = true;
|
|
|
93
91
|
* return;
|
|
94
92
|
* }
|
|
95
93
|
*/
|
|
96
|
-
|
|
94
|
+
export function init(format = "mp3") {
|
|
97
95
|
// convert it into an array
|
|
98
96
|
audioExts = format.split(",");
|
|
99
97
|
|
|
@@ -103,7 +101,7 @@ export let stopOnAudioError = true;
|
|
|
103
101
|
/**
|
|
104
102
|
* check if the given audio format is supported
|
|
105
103
|
* @function audio.hasFormat
|
|
106
|
-
* @param {
|
|
104
|
+
* @param {"mp3"|"mpeg"|"opus"|"ogg"|"oga"|"wav"|"aac"|"caf"|"m4a"|"m4b"|"mp4"|"weba"|"webm"|"dolby"|"flac"} codec - the audio format to check for support
|
|
107
105
|
* @returns {boolean} return true if the given audio format is supported
|
|
108
106
|
*/
|
|
109
107
|
export function hasFormat(codec) {
|
package/src/camera/camera2d.js
CHANGED
|
@@ -23,7 +23,7 @@ let targetV = new Vector2d();
|
|
|
23
23
|
* a 2D orthographic camera
|
|
24
24
|
* @augments Renderable
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
export default class Camera2d extends Renderable {
|
|
27
27
|
/**
|
|
28
28
|
* @param {number} minX - start x offset
|
|
29
29
|
* @param {number} minY - start y offset
|
|
@@ -207,8 +207,8 @@ let targetV = new Vector2d();
|
|
|
207
207
|
* reset the camera position to specified coordinates
|
|
208
208
|
* @name reset
|
|
209
209
|
* @memberof Camera2d
|
|
210
|
-
* @param {number} [x=0]
|
|
211
|
-
* @param {number} [y=0]
|
|
210
|
+
* @param {number} [x=0] - initial position of the camera on the x axis
|
|
211
|
+
* @param {number} [y=0] - initial position of the camera on the y axis
|
|
212
212
|
*/
|
|
213
213
|
reset(x = 0, y = 0) {
|
|
214
214
|
// reset the initial camera position to 0,0
|
|
@@ -365,8 +365,8 @@ let targetV = new Vector2d();
|
|
|
365
365
|
* @name move
|
|
366
366
|
* @memberof Camera2d
|
|
367
367
|
* @see Camera2d.focusOn
|
|
368
|
-
* @param {number} x
|
|
369
|
-
* @param {number} y
|
|
368
|
+
* @param {number} x - horizontal offset
|
|
369
|
+
* @param {number} y - vertical offset
|
|
370
370
|
* @example
|
|
371
371
|
* // Move the camera up by four pixels
|
|
372
372
|
* me.game.viewport.move(0, -4);
|
|
@@ -590,7 +590,7 @@ let targetV = new Vector2d();
|
|
|
590
590
|
* @memberof Camera2d
|
|
591
591
|
* @param {Renderable|Entity|Sprite|NineSliceSprite} obj - to be checked against
|
|
592
592
|
* @param {boolean} [floating = obj.floating] - if visibility check should be done against screen coordinates
|
|
593
|
-
* @returns {boolean}
|
|
593
|
+
* @returns {boolean} true if within the viewport
|
|
594
594
|
*/
|
|
595
595
|
isVisible(obj, floating = obj.floating) {
|
|
596
596
|
if (floating === true || obj.floating === true) {
|
|
@@ -606,10 +606,9 @@ let targetV = new Vector2d();
|
|
|
606
606
|
* convert the given "local" (screen) coordinates into world coordinates
|
|
607
607
|
* @name localToWorld
|
|
608
608
|
* @memberof Camera2d
|
|
609
|
-
* @param {number} x
|
|
610
|
-
* @param {number} y
|
|
611
|
-
* @param {number} [v] - an optional vector object where to set the
|
|
612
|
-
* converted value
|
|
609
|
+
* @param {number} x - the x coordinate of the local point to be converted
|
|
610
|
+
* @param {number} y - the y coordinate of the local point to be converted
|
|
611
|
+
* @param {number} [v] - an optional vector object where to set the converted value
|
|
613
612
|
* @returns {Vector2d}
|
|
614
613
|
*/
|
|
615
614
|
localToWorld(x, y, v) {
|
|
@@ -628,9 +627,8 @@ let targetV = new Vector2d();
|
|
|
628
627
|
* @memberof Camera2d
|
|
629
628
|
* @param {number} x
|
|
630
629
|
* @param {number} y
|
|
631
|
-
* @param {number} [v] - an optional vector object where to set the
|
|
632
|
-
* converted
|
|
633
|
-
* @returns {Vector2d}
|
|
630
|
+
* @param {number} [v] - an optional vector object where to set the converted value
|
|
631
|
+
* @returns {Vector2d} a vector with the converted local coordinates
|
|
634
632
|
*/
|
|
635
633
|
worldToLocal(x, y, v) {
|
|
636
634
|
// TODO memoization for one set of coords (multitouch)
|
package/src/entity/entity.js
CHANGED
|
@@ -10,7 +10,7 @@ import Body from "./../physics/body.js";
|
|
|
10
10
|
* @augments Renderable
|
|
11
11
|
* @see Renderable
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
export default class Entity extends Renderable {
|
|
14
14
|
/**
|
|
15
15
|
* @param {number} x - the x coordinates of the entity object
|
|
16
16
|
* @param {number} y - the y coordinates of the entity object
|
|
@@ -180,7 +180,7 @@ import Body from "./../physics/body.js";
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
if (absolute === true) {
|
|
183
|
-
|
|
183
|
+
let absPos = this.getAbsolutePosition();
|
|
184
184
|
bounds.centerOn(absPos.x + bounds.x + bounds.width / 2, absPos.y + bounds.y + bounds.height / 2);
|
|
185
185
|
}
|
|
186
186
|
|
|
@@ -192,7 +192,6 @@ import Body from "./../physics/body.js";
|
|
|
192
192
|
* @ignore
|
|
193
193
|
* @name onBodyUpdate
|
|
194
194
|
* @memberof Entity
|
|
195
|
-
* @param {Body} body - the body whose bounds to update
|
|
196
195
|
*/
|
|
197
196
|
onBodyUpdate() {
|
|
198
197
|
this.updateBounds();
|