melonjs 10.12.0 → 13.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/README.md +6 -6
- package/dist/melonjs.js +22651 -22529
- package/dist/melonjs.min.js +5 -6
- package/dist/melonjs.module.d.ts +195 -195
- package/dist/melonjs.module.js +22107 -21977
- package/package.json +14 -14
- package/src/application/application.js +231 -0
- package/src/audio/audio.js +13 -7
- package/src/camera/camera2d.js +6 -6
- package/src/game.js +9 -232
- package/src/index.js +3 -3
- package/src/input/keyboard.js +2 -2
- package/src/input/pointer.js +4 -5
- package/src/input/pointerevent.js +8 -8
- package/src/lang/deprecated.js +0 -29
- package/src/level/level.js +2 -2
- package/src/level/tiled/TMXLayer.js +2 -2
- package/src/level/tiled/TMXTileMap.js +3 -3
- package/src/loader/loader.js +64 -28
- package/src/loader/loadingscreen.js +28 -115
- package/src/loader/melonjs_logo.png +0 -0
- package/src/physics/body.js +27 -51
- package/src/physics/detector.js +3 -3
- package/src/physics/quadtree.js +58 -29
- package/src/physics/world.js +32 -3
- package/src/polyfill/index.js +4 -0
- package/src/renderable/container.js +2 -2
- package/src/renderable/imagelayer.js +8 -8
- package/src/renderable/light2d.js +40 -11
- package/src/renderable/trigger.js +4 -4
- package/src/state/stage.js +1 -1
- package/src/state/state.js +50 -3
- package/src/system/device.js +808 -1039
- package/src/system/dom.js +69 -0
- package/src/system/event.js +13 -1
- package/src/system/platform.js +32 -0
- package/src/system/save.js +23 -14
- package/src/system/timer.js +12 -35
- package/src/text/bitmaptext.js +1 -2
- package/src/text/text.js +10 -14
- package/src/text/textmetrics.js +1 -2
- package/src/tweens/tween.js +6 -6
- package/src/utils/string.js +13 -24
- package/src/video/canvas/canvas_renderer.js +3 -2
- package/src/video/renderer.js +2 -2
- package/src/video/texture/canvas_texture.js +36 -2
- package/src/video/video.js +15 -9
- package/src/video/webgl/glshader.js +1 -1
- package/src/video/webgl/webgl_renderer.js +1 -1
package/dist/melonjs.module.d.ts
CHANGED
|
@@ -234,22 +234,24 @@ export class Body {
|
|
|
234
234
|
*/
|
|
235
235
|
public collisionType: number;
|
|
236
236
|
/**
|
|
237
|
-
*
|
|
237
|
+
* The current velocity of the body.
|
|
238
|
+
* See to apply a force if you need to modify a body velocity
|
|
239
|
+
* @see Body.force
|
|
238
240
|
* @public
|
|
239
241
|
* @type {Vector2d}
|
|
240
242
|
* @default <0,0>
|
|
241
243
|
*/
|
|
242
244
|
public vel: Vector2d;
|
|
243
245
|
/**
|
|
244
|
-
* body force
|
|
245
|
-
*
|
|
246
|
+
* body force to apply to this the body in the current step.
|
|
247
|
+
* (any positive or negative force will be cancelled after every world/body update cycle)
|
|
246
248
|
* @public
|
|
247
249
|
* @type {Vector2d}
|
|
248
250
|
* @default <0,0>
|
|
249
251
|
* @see Body.setMaxVelocity
|
|
250
252
|
* @example
|
|
251
253
|
* // define a default maximum acceleration, initial force and friction
|
|
252
|
-
* this.body.force.set(
|
|
254
|
+
* this.body.force.set(1, 0);
|
|
253
255
|
* this.body.friction.set(0.4, 0);
|
|
254
256
|
* this.body.setMaxVelocity(3, 15);
|
|
255
257
|
*
|
|
@@ -259,8 +261,6 @@ export class Body {
|
|
|
259
261
|
* this.body.force.x = -this.body.maxVel.x;
|
|
260
262
|
* } else if (me.input.isKeyPressed("right")) {
|
|
261
263
|
* this.body.force.x = this.body.maxVel.x;
|
|
262
|
-
* } else {
|
|
263
|
-
* this.body.force.x = 0;
|
|
264
264
|
* }
|
|
265
265
|
* }
|
|
266
266
|
*/
|
|
@@ -486,23 +486,14 @@ export class Body {
|
|
|
486
486
|
* @param {number} y vertical friction
|
|
487
487
|
*/
|
|
488
488
|
setFriction(x?: number, y?: number): void;
|
|
489
|
-
/**
|
|
490
|
-
* compute the new velocity value
|
|
491
|
-
* @ignore
|
|
492
|
-
*/
|
|
493
|
-
computeVelocity(): void;
|
|
494
489
|
/**
|
|
495
490
|
* Updates the parent's position as well as computes the new body's velocity based
|
|
496
|
-
* on the values of force/friction
|
|
491
|
+
* on the values of force/friction. Velocity chages are proportional to the
|
|
497
492
|
* me.timer.tick value (which can be used to scale velocities). The approach to moving the
|
|
498
493
|
* parent renderable is to compute new values of the Body.vel property then add them to
|
|
499
494
|
* the parent.pos value thus changing the postion the amount of Body.vel each time the
|
|
500
495
|
* update call is made. <br>
|
|
501
496
|
* Updates to Body.vel are bounded by maxVel (which defaults to viewport size if not set) <br>
|
|
502
|
-
*
|
|
503
|
-
* In addition, when the gravity calcuation is made, if the Body.vel.y > 0 then the Body.falling
|
|
504
|
-
* property is set to true and Body.jumping is set to !Body.falling.
|
|
505
|
-
*
|
|
506
497
|
* At this time a call to Body.Update does not call the onBodyUpdate callback that is listed in the constructor arguments.
|
|
507
498
|
* @protected
|
|
508
499
|
* @param {number} dt time since the last update in milliseconds.
|
|
@@ -1956,7 +1947,7 @@ export class Container extends Renderable {
|
|
|
1956
1947
|
* @memberof Container
|
|
1957
1948
|
* @public
|
|
1958
1949
|
* @param {Renderable} child
|
|
1959
|
-
* @param {boolean} [keepalive=
|
|
1950
|
+
* @param {boolean} [keepalive=false] true to prevent calling child.destroy()
|
|
1960
1951
|
*/
|
|
1961
1952
|
public removeChild(child: Renderable, keepalive?: boolean): void;
|
|
1962
1953
|
/**
|
|
@@ -2806,11 +2797,12 @@ export class Light2d extends Renderable {
|
|
|
2806
2797
|
/**
|
|
2807
2798
|
* @param {number} x - The horizontal position of the light.
|
|
2808
2799
|
* @param {number} y - The vertical position of the light.
|
|
2809
|
-
* @param {number}
|
|
2800
|
+
* @param {number} radiusX - The horizontal radius of the light.
|
|
2801
|
+
* @param {number} [radiusY=radiusX] - The vertical radius of the light.
|
|
2810
2802
|
* @param {Color|string} [color="#FFF"] the color of the light
|
|
2811
2803
|
* @param {number} [intensity=0.7] - The intensity of the light.
|
|
2812
2804
|
*/
|
|
2813
|
-
constructor(x: number, y: number,
|
|
2805
|
+
constructor(x: number, y: number, radiusX: number, radiusY?: number, color?: Color | string, intensity?: number);
|
|
2814
2806
|
/**
|
|
2815
2807
|
* the color of the light
|
|
2816
2808
|
* @type {Color}
|
|
@@ -2818,10 +2810,15 @@ export class Light2d extends Renderable {
|
|
|
2818
2810
|
*/
|
|
2819
2811
|
color: Color;
|
|
2820
2812
|
/**
|
|
2821
|
-
* The radius of the light
|
|
2813
|
+
* The horizontal radius of the light
|
|
2822
2814
|
* @type {number}
|
|
2823
2815
|
*/
|
|
2824
|
-
|
|
2816
|
+
radiusX: number;
|
|
2817
|
+
/**
|
|
2818
|
+
* The vertical radius of the light
|
|
2819
|
+
* @type {number}
|
|
2820
|
+
*/
|
|
2821
|
+
radiusY: number;
|
|
2825
2822
|
/**
|
|
2826
2823
|
* The intensity of the light
|
|
2827
2824
|
* @type {number}
|
|
@@ -5403,16 +5400,18 @@ export class Polygon {
|
|
|
5403
5400
|
*/
|
|
5404
5401
|
export class QuadTree {
|
|
5405
5402
|
/**
|
|
5403
|
+
* @param {World} world the physic world this QuadTree belongs to
|
|
5406
5404
|
* @param {Bounds} bounds bounds of the node
|
|
5407
5405
|
* @param {number} [max_objects=4] max objects a node can hold before splitting into 4 subnodes
|
|
5408
5406
|
* @param {number} [max_levels=4] total max levels inside root Quadtree
|
|
5409
5407
|
* @param {number} [level] deepth level, required for subnodes
|
|
5410
5408
|
*/
|
|
5411
|
-
constructor(bounds: Bounds, max_objects?: number, max_levels?: number, level?: number);
|
|
5409
|
+
constructor(world: World, bounds: Bounds, max_objects?: number, max_levels?: number, level?: number);
|
|
5410
|
+
world: World;
|
|
5411
|
+
bounds: Bounds;
|
|
5412
5412
|
max_objects: number;
|
|
5413
5413
|
max_levels: number;
|
|
5414
5414
|
level: number;
|
|
5415
|
-
bounds: Bounds;
|
|
5416
5415
|
objects: any[];
|
|
5417
5416
|
nodes: any[];
|
|
5418
5417
|
split(): void;
|
|
@@ -6153,7 +6152,7 @@ export class Renderer {
|
|
|
6153
6152
|
* @param {number} options.width The width of the canvas without scaling
|
|
6154
6153
|
* @param {number} options.height The height of the canvas without scaling
|
|
6155
6154
|
* @param {HTMLCanvasElement} [options.canvas] The html canvas to draw to on screen
|
|
6156
|
-
* @param {boolean} [options.doubleBuffering=false] Whether to enable double buffering
|
|
6155
|
+
* @param {boolean} [options.doubleBuffering=false] Whether to enable double buffering (not applicable when using the WebGL Renderer)
|
|
6157
6156
|
* @param {boolean} [options.antiAlias=false] Whether to enable anti-aliasing, use false (default) for a pixelated effect.
|
|
6158
6157
|
* @param {boolean} [options.failIfMajorPerformanceCaveat=true] If true, the renderer will switch to CANVAS mode if the performances of a WebGL context would be dramatically lower than that of a native application making equivalent OpenGL calls.
|
|
6159
6158
|
* @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas (performance hit when enabled)
|
|
@@ -7624,9 +7623,6 @@ export class Text extends Renderable {
|
|
|
7624
7623
|
public fontSize: number;
|
|
7625
7624
|
canvasTexture: any;
|
|
7626
7625
|
metrics: TextMetrics;
|
|
7627
|
-
/** @ignore */
|
|
7628
|
-
onDeactivateEvent(): void;
|
|
7629
|
-
glTextureUnit: any;
|
|
7630
7626
|
/**
|
|
7631
7627
|
* make the font bold
|
|
7632
7628
|
* @returns {Text} this object for chaining
|
|
@@ -7654,6 +7650,7 @@ export class Text extends Renderable {
|
|
|
7654
7650
|
* @returns {Text} this object for chaining
|
|
7655
7651
|
*/
|
|
7656
7652
|
setText(value?: number | string | string[]): Text;
|
|
7653
|
+
glTextureUnit: any;
|
|
7657
7654
|
/**
|
|
7658
7655
|
* measure the given text size in pixels
|
|
7659
7656
|
* @param {CanvasRenderer|WebGLRenderer} renderer reference to the active renderer
|
|
@@ -9052,7 +9049,7 @@ export class WebGLRenderer extends Renderer {
|
|
|
9052
9049
|
* @param {number} options.width The width of the canvas without scaling
|
|
9053
9050
|
* @param {number} options.height The height of the canvas without scaling
|
|
9054
9051
|
* @param {HTMLCanvasElement} [options.canvas] The html canvas to draw to on screen
|
|
9055
|
-
* @param {boolean} [options.doubleBuffering=false] Whether to enable double buffering
|
|
9052
|
+
* @param {boolean} [options.doubleBuffering=false] Whether to enable double buffering (not applicable when using the WebGL Renderer)
|
|
9056
9053
|
* @param {boolean} [options.antiAlias=false] Whether to enable anti-aliasing
|
|
9057
9054
|
* @param {boolean} [options.failIfMajorPerformanceCaveat=true] If true, the renderer will switch to CANVAS mode if the performances of a WebGL context would be dramatically lower than that of a native application making equivalent OpenGL calls.
|
|
9058
9055
|
* @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas (performance hit when enabled)
|
|
@@ -9556,6 +9553,12 @@ export class World extends Container {
|
|
|
9556
9553
|
* @param {number} [height=game.viewport.height] height of the container
|
|
9557
9554
|
*/
|
|
9558
9555
|
constructor(x?: number, y?: number, width?: number, height?: number);
|
|
9556
|
+
/**
|
|
9557
|
+
* the application (game) this physic world belong to
|
|
9558
|
+
* @public
|
|
9559
|
+
* @type {Application}
|
|
9560
|
+
*/
|
|
9561
|
+
public app: Application;
|
|
9559
9562
|
/**
|
|
9560
9563
|
* the rate at which the game world is updated,
|
|
9561
9564
|
* may be greater than or lower than the display fps
|
|
@@ -9623,6 +9626,14 @@ export class World extends Container {
|
|
|
9623
9626
|
* @returns {World} this game world
|
|
9624
9627
|
*/
|
|
9625
9628
|
removeBody(body: Body): World;
|
|
9629
|
+
/**
|
|
9630
|
+
* Apply gravity to the given body
|
|
9631
|
+
* @name bodyApplyVelocity
|
|
9632
|
+
* @memberof World
|
|
9633
|
+
* @private
|
|
9634
|
+
* @param {Body} body
|
|
9635
|
+
*/
|
|
9636
|
+
private bodyApplyGravity;
|
|
9626
9637
|
}
|
|
9627
9638
|
export var audio: Readonly<{
|
|
9628
9639
|
__proto__: any;
|
|
@@ -9734,31 +9745,10 @@ export namespace collision {
|
|
|
9734
9745
|
*/
|
|
9735
9746
|
function rayCast(line: Line, result?: Renderable[]): Renderable[];
|
|
9736
9747
|
}
|
|
9737
|
-
export
|
|
9738
|
-
const devicePixelRatio: number;
|
|
9739
|
-
const isFullscreen: boolean;
|
|
9740
|
-
const sound: boolean;
|
|
9741
|
-
/**
|
|
9742
|
-
* @public
|
|
9743
|
-
* @name turnOnPointerLock
|
|
9744
|
-
* @returns {boolean} return true if the request was successfully submitted
|
|
9745
|
-
* @memberof device#
|
|
9746
|
-
* @deprecated since 10.3.0
|
|
9747
|
-
* @see input.requestPointerLock
|
|
9748
|
-
*/
|
|
9749
|
-
function turnOnPointerLock(): boolean;
|
|
9750
|
-
/**
|
|
9751
|
-
* @public
|
|
9752
|
-
* @name turnOffPointerLock
|
|
9753
|
-
* @returns {boolean} return true if the request was successfully submitted
|
|
9754
|
-
* @memberof device#
|
|
9755
|
-
* @deprecated since 10.3.0
|
|
9756
|
-
* @see input.exitPointerLock
|
|
9757
|
-
*/
|
|
9758
|
-
function turnOffPointerLock(): boolean;
|
|
9759
|
-
}
|
|
9748
|
+
export var device: any;
|
|
9760
9749
|
export var event: Readonly<{
|
|
9761
9750
|
__proto__: any;
|
|
9751
|
+
DOM_READY: string;
|
|
9762
9752
|
BOOT: string;
|
|
9763
9753
|
STATE_PAUSE: string;
|
|
9764
9754
|
STATE_RESUME: string;
|
|
@@ -9798,21 +9788,13 @@ export var event: Readonly<{
|
|
|
9798
9788
|
once: typeof once;
|
|
9799
9789
|
off: typeof off;
|
|
9800
9790
|
}>;
|
|
9801
|
-
|
|
9802
|
-
|
|
9803
|
-
|
|
9804
|
-
|
|
9805
|
-
|
|
9806
|
-
|
|
9807
|
-
|
|
9808
|
-
onLevelLoaded: typeof onLevelLoaded;
|
|
9809
|
-
reset: typeof reset;
|
|
9810
|
-
updateFrameRate: typeof updateFrameRate;
|
|
9811
|
-
getParentContainer: typeof getParentContainer;
|
|
9812
|
-
repaint: typeof repaint;
|
|
9813
|
-
update: typeof update;
|
|
9814
|
-
draw: typeof draw;
|
|
9815
|
-
}>;
|
|
9791
|
+
/**
|
|
9792
|
+
* game is a default instance of a melonJS Application and represents your current game,
|
|
9793
|
+
* it contains all the objects, tilemap layers, current viewport, collision map, etc...<br>
|
|
9794
|
+
* @namespace game
|
|
9795
|
+
* @see Application
|
|
9796
|
+
*/
|
|
9797
|
+
export let game: Application;
|
|
9816
9798
|
/**
|
|
9817
9799
|
* a flag indicating that melonJS is fully initialized
|
|
9818
9800
|
* @type {boolean}
|
|
@@ -10147,7 +10129,7 @@ export namespace level {
|
|
|
10147
10129
|
* @param {string} levelId level id
|
|
10148
10130
|
* @param {object} [options] additional optional parameters
|
|
10149
10131
|
* @param {Container} [options.container=game.world] container in which to load the specified level
|
|
10150
|
-
* @param {Function} [options.onLoaded=
|
|
10132
|
+
* @param {Function} [options.onLoaded=game.onLevelLoaded] callback for when the level is fully loaded
|
|
10151
10133
|
* @param {boolean} [options.flatten=game.mergeGroup] if true, flatten all objects into the given container
|
|
10152
10134
|
* @param {boolean} [options.setViewportBounds=true] if true, set the viewport bounds to the map size
|
|
10153
10135
|
* @returns {boolean} true if the level was successfully loaded
|
|
@@ -10192,7 +10174,7 @@ export namespace level {
|
|
|
10192
10174
|
* @param {string} levelId level id
|
|
10193
10175
|
* @param {object} [options] additional optional parameters
|
|
10194
10176
|
* @param {Container} [options.container=game.world] container in which to load the specified level
|
|
10195
|
-
* @param {Function} [options.onLoaded=
|
|
10177
|
+
* @param {Function} [options.onLoaded=game.onLevelLoaded] callback for when the level is fully loaded
|
|
10196
10178
|
* @param {boolean} [options.flatten=game.mergeGroup] if true, flatten all objects into the given container
|
|
10197
10179
|
* @param {boolean} [options.setViewportBounds=true] if true, set the viewport bounds to the map size
|
|
10198
10180
|
* @returns {boolean} true if the level was successfully loaded
|
|
@@ -10461,6 +10443,8 @@ export namespace loader {
|
|
|
10461
10443
|
* {name: "tileset-platformer", type: "image", src: "data/map/tileset.png"},
|
|
10462
10444
|
* // PNG packed texture
|
|
10463
10445
|
* {name: "texture", type:"image", src: "data/gfx/texture.png"}
|
|
10446
|
+
* // PNG base64 encoded image
|
|
10447
|
+
* {name: "texture", type:"image", src: "data:image/png;base64,iVBORw0KAAAQAAAAEACA..."}
|
|
10464
10448
|
* // TSX file
|
|
10465
10449
|
* {name: "meta_tiles", type: "tsx", src: "data/map/meta_tiles.tsx"},
|
|
10466
10450
|
* // TMX level (XML & JSON)
|
|
@@ -10471,6 +10455,8 @@ export namespace loader {
|
|
|
10471
10455
|
* // audio resources
|
|
10472
10456
|
* {name: "bgmusic", type: "audio", src: "data/audio/"},
|
|
10473
10457
|
* {name: "cling", type: "audio", src: "data/audio/"},
|
|
10458
|
+
* // base64 encoded audio resources
|
|
10459
|
+
* {name: "band", type: "audio", src: "data:audio/wav;base64,..."},
|
|
10474
10460
|
* // binary file
|
|
10475
10461
|
* {name: "ymTrack", type: "binary", src: "data/audio/main.ym"},
|
|
10476
10462
|
* // JSON file (used for texturePacker)
|
|
@@ -10508,6 +10494,8 @@ export namespace loader {
|
|
|
10508
10494
|
* {name: "tileset-platformer", type: "image", src: "data/map/tileset.png"},
|
|
10509
10495
|
* // PNG packed texture
|
|
10510
10496
|
* {name: "texture", type:"image", src: "data/gfx/texture.png"}
|
|
10497
|
+
* // PNG base64 encoded image
|
|
10498
|
+
* {name: "texture", type:"image", src: "data:image/png;base64,iVBORw0KAAAQAAAAEACA..."}
|
|
10511
10499
|
* // TSX file
|
|
10512
10500
|
* {name: "meta_tiles", type: "tsx", src: "data/map/meta_tiles.tsx"},
|
|
10513
10501
|
* // TMX level (XML & JSON)
|
|
@@ -10518,6 +10506,8 @@ export namespace loader {
|
|
|
10518
10506
|
* // audio resources
|
|
10519
10507
|
* {name: "bgmusic", type: "audio", src: "data/audio/"},
|
|
10520
10508
|
* {name: "cling", type: "audio", src: "data/audio/"},
|
|
10509
|
+
* // base64 encoded audio resources
|
|
10510
|
+
* {name: "band", type: "audio", src: "data:audio/wav;base64,..."},
|
|
10521
10511
|
* // binary file
|
|
10522
10512
|
* {name: "ymTrack", type: "binary", src: "data/audio/main.ym"},
|
|
10523
10513
|
* // JSON file (used for texturePacker)
|
|
@@ -10547,13 +10537,14 @@ export namespace loader {
|
|
|
10547
10537
|
* @param {string} res.type "audio", binary", "image", "json", "tmx", "tsx"
|
|
10548
10538
|
* @param {string} res.src path and/or file name of the resource (for audio assets only the path is required)
|
|
10549
10539
|
* @param {boolean} [res.stream] Set to true to force HTML5 Audio, which allows not to wait for large file to be downloaded before playing.
|
|
10550
|
-
* @param {Function} onload function to be called when the resource is loaded
|
|
10551
|
-
* @param {Function} onerror function to be called in case of error
|
|
10540
|
+
* @param {Function} [onload] function to be called when the resource is loaded
|
|
10541
|
+
* @param {Function} [onerror] function to be called in case of error
|
|
10552
10542
|
* @returns {number} the amount of corresponding resource to be preloaded
|
|
10553
10543
|
* @example
|
|
10554
10544
|
* // load an image asset
|
|
10555
10545
|
* me.loader.load({name: "avatar", type:"image", src: "data/avatar.png"}, this.onload.bind(this), this.onerror.bind(this));
|
|
10556
|
-
*
|
|
10546
|
+
* // load a base64 image asset
|
|
10547
|
+
* me.loader.load({name: "avatar", type:"image", src: "data:image/png;base64,iVBORw0KAAAQAAAAEACA..."};
|
|
10557
10548
|
* // start loading music
|
|
10558
10549
|
* me.loader.load({
|
|
10559
10550
|
* name : "bgmusic",
|
|
@@ -10568,7 +10559,7 @@ export namespace loader {
|
|
|
10568
10559
|
type: string;
|
|
10569
10560
|
src: string;
|
|
10570
10561
|
stream?: boolean;
|
|
10571
|
-
}, onload
|
|
10562
|
+
}, onload?: Function, onerror?: Function): number;
|
|
10572
10563
|
/**
|
|
10573
10564
|
* Load a single resource (to be used if you need to load additional resource during the game)
|
|
10574
10565
|
* @name load
|
|
@@ -10579,13 +10570,14 @@ export namespace loader {
|
|
|
10579
10570
|
* @param {string} res.type "audio", binary", "image", "json", "tmx", "tsx"
|
|
10580
10571
|
* @param {string} res.src path and/or file name of the resource (for audio assets only the path is required)
|
|
10581
10572
|
* @param {boolean} [res.stream] Set to true to force HTML5 Audio, which allows not to wait for large file to be downloaded before playing.
|
|
10582
|
-
* @param {Function} onload function to be called when the resource is loaded
|
|
10583
|
-
* @param {Function} onerror function to be called in case of error
|
|
10573
|
+
* @param {Function} [onload] function to be called when the resource is loaded
|
|
10574
|
+
* @param {Function} [onerror] function to be called in case of error
|
|
10584
10575
|
* @returns {number} the amount of corresponding resource to be preloaded
|
|
10585
10576
|
* @example
|
|
10586
10577
|
* // load an image asset
|
|
10587
10578
|
* me.loader.load({name: "avatar", type:"image", src: "data/avatar.png"}, this.onload.bind(this), this.onerror.bind(this));
|
|
10588
|
-
*
|
|
10579
|
+
* // load a base64 image asset
|
|
10580
|
+
* me.loader.load({name: "avatar", type:"image", src: "data:image/png;base64,iVBORw0KAAAQAAAAEACA..."};
|
|
10589
10581
|
* // start loading music
|
|
10590
10582
|
* me.loader.load({
|
|
10591
10583
|
* name : "bgmusic",
|
|
@@ -10600,7 +10592,7 @@ export namespace loader {
|
|
|
10600
10592
|
type: string;
|
|
10601
10593
|
src: string;
|
|
10602
10594
|
stream?: boolean;
|
|
10603
|
-
}, onload
|
|
10595
|
+
}, onload?: Function, onerror?: Function): number;
|
|
10604
10596
|
/**
|
|
10605
10597
|
* unload specified resource to free memory
|
|
10606
10598
|
* @name unload
|
|
@@ -11108,20 +11100,6 @@ export namespace state {
|
|
|
11108
11100
|
*/
|
|
11109
11101
|
export function isCurrent(state: number): boolean;
|
|
11110
11102
|
}
|
|
11111
|
-
/**
|
|
11112
|
-
* the default global Timer instance
|
|
11113
|
-
* @namespace timer
|
|
11114
|
-
* @see Timer
|
|
11115
|
-
* @example
|
|
11116
|
-
* // set a timer to call "myFunction" after 1000ms
|
|
11117
|
-
* timer.setTimeout(myFunction, 1000);
|
|
11118
|
-
* // set a timer to call "myFunction" after 1000ms (respecting the pause state) and passing param1 and param2
|
|
11119
|
-
* timer.setTimeout(myFunction, 1000, true, param1, param2);
|
|
11120
|
-
* // set a timer to call "myFunction" every 1000ms
|
|
11121
|
-
* timer.setInterval(myFunction, 1000);
|
|
11122
|
-
* // set a timer to call "myFunction" every 1000ms (respecting the pause state) and passing param1 and param2
|
|
11123
|
-
* timer.setInterval(myFunction, 1000, true, param1, param2);
|
|
11124
|
-
*/
|
|
11125
11103
|
export const timer: Timer;
|
|
11126
11104
|
export namespace utils {
|
|
11127
11105
|
export { agentUtils as agent };
|
|
@@ -11150,7 +11128,7 @@ export var video: Readonly<{
|
|
|
11150
11128
|
AUTO: 2;
|
|
11151
11129
|
readonly parent: HTMLElement;
|
|
11152
11130
|
scaleRatio: Vector2d;
|
|
11153
|
-
readonly renderer:
|
|
11131
|
+
readonly renderer: WebGLRenderer | CanvasRenderer;
|
|
11154
11132
|
init: typeof init;
|
|
11155
11133
|
createCanvas: typeof createCanvas;
|
|
11156
11134
|
getParent: typeof getParent;
|
|
@@ -11586,6 +11564,109 @@ declare class VertexArrayBuffer {
|
|
|
11586
11564
|
*/
|
|
11587
11565
|
isEmpty(): boolean;
|
|
11588
11566
|
}
|
|
11567
|
+
/**
|
|
11568
|
+
* @classdesc
|
|
11569
|
+
* An Application represents a single melonJS game.
|
|
11570
|
+
* An Application is responsible for updating (each frame) all the related object status and draw them.
|
|
11571
|
+
* @see game
|
|
11572
|
+
*/
|
|
11573
|
+
declare class Application {
|
|
11574
|
+
/**
|
|
11575
|
+
* a reference to the current active stage "default" camera
|
|
11576
|
+
* @public
|
|
11577
|
+
* @type {Camera2d}
|
|
11578
|
+
*/
|
|
11579
|
+
public viewport: Camera2d;
|
|
11580
|
+
/**
|
|
11581
|
+
* a reference to the game world, <br>
|
|
11582
|
+
* a world is a virtual environment containing all the game objects
|
|
11583
|
+
* @public
|
|
11584
|
+
* @type {World}
|
|
11585
|
+
*/
|
|
11586
|
+
public world: World;
|
|
11587
|
+
/**
|
|
11588
|
+
* when true, all objects will be added under the root world container.<br>
|
|
11589
|
+
* When false, a `me.Container` object will be created for each corresponding groups
|
|
11590
|
+
* @public
|
|
11591
|
+
* @type {boolean}
|
|
11592
|
+
* @default true
|
|
11593
|
+
*/
|
|
11594
|
+
public mergeGroup: boolean;
|
|
11595
|
+
/**
|
|
11596
|
+
* Specify the property to be used when sorting renderables.
|
|
11597
|
+
* Accepted values : "x", "y", "z"
|
|
11598
|
+
* @public
|
|
11599
|
+
* @type {string}
|
|
11600
|
+
* @default "z"
|
|
11601
|
+
*/
|
|
11602
|
+
public sortOn: string;
|
|
11603
|
+
/**
|
|
11604
|
+
* Last time the game update loop was executed. <br>
|
|
11605
|
+
* Use this value to implement frame prediction in drawing events,
|
|
11606
|
+
* for creating smooth motion while running game update logic at
|
|
11607
|
+
* a lower fps.
|
|
11608
|
+
* @public
|
|
11609
|
+
* @type {DOMHighResTimeStamp}
|
|
11610
|
+
* @name lastUpdate
|
|
11611
|
+
* @memberof Application
|
|
11612
|
+
*/
|
|
11613
|
+
public lastUpdate: DOMHighResTimeStamp;
|
|
11614
|
+
isDirty: boolean;
|
|
11615
|
+
isAlwaysDirty: boolean;
|
|
11616
|
+
frameCounter: number;
|
|
11617
|
+
frameRate: number;
|
|
11618
|
+
accumulator: number;
|
|
11619
|
+
accumulatorMax: number;
|
|
11620
|
+
accumulatorUpdateDelta: number;
|
|
11621
|
+
stepSize: number;
|
|
11622
|
+
updateDelta: number;
|
|
11623
|
+
lastUpdateStart: number;
|
|
11624
|
+
updateAverageDelta: number;
|
|
11625
|
+
/**
|
|
11626
|
+
* init the game instance (create a physic world, update starting time, etc..)
|
|
11627
|
+
*/
|
|
11628
|
+
init(): void;
|
|
11629
|
+
/**
|
|
11630
|
+
* reset the game Object manager
|
|
11631
|
+
* destroy all current objects
|
|
11632
|
+
*/
|
|
11633
|
+
reset(): void;
|
|
11634
|
+
/**
|
|
11635
|
+
* Fired when a level is fully loaded and all renderable instantiated. <br>
|
|
11636
|
+
* Additionnaly the level id will also be passed to the called function.
|
|
11637
|
+
* @example
|
|
11638
|
+
* // call myFunction () everytime a level is loaded
|
|
11639
|
+
* me.game.onLevelLoaded = this.myFunction.bind(this);
|
|
11640
|
+
*/
|
|
11641
|
+
onLevelLoaded(): void;
|
|
11642
|
+
/**
|
|
11643
|
+
* Update the renderer framerate using the system config variables.
|
|
11644
|
+
* @see timer.maxfps
|
|
11645
|
+
* @see World.fps
|
|
11646
|
+
*/
|
|
11647
|
+
updateFrameRate(): void;
|
|
11648
|
+
/**
|
|
11649
|
+
* Returns the parent container of the specified Child in the game world
|
|
11650
|
+
* @param {Renderable} child
|
|
11651
|
+
* @returns {Container}
|
|
11652
|
+
*/
|
|
11653
|
+
getParentContainer(child: Renderable): Container;
|
|
11654
|
+
/**
|
|
11655
|
+
* force the redraw (not update) of all objects
|
|
11656
|
+
*/
|
|
11657
|
+
repaint(): void;
|
|
11658
|
+
/**
|
|
11659
|
+
* update all objects related to this game active scene/stage
|
|
11660
|
+
* @param {number} time current timestamp as provided by the RAF callback
|
|
11661
|
+
* @param {Stage} stage the current stage
|
|
11662
|
+
*/
|
|
11663
|
+
update(time: number, stage: Stage): void;
|
|
11664
|
+
/**
|
|
11665
|
+
* draw the active scene/stage associated to this game
|
|
11666
|
+
* @param {Stage} stage the current stage
|
|
11667
|
+
*/
|
|
11668
|
+
draw(stage: Stage): void;
|
|
11669
|
+
}
|
|
11589
11670
|
/**
|
|
11590
11671
|
* Initialize and configure the audio support.<br>
|
|
11591
11672
|
* melonJS supports a wide array of audio codecs that have varying browser support :
|
|
@@ -11887,55 +11968,6 @@ declare function once(eventName: string | symbol, listener: Function, context?:
|
|
|
11887
11968
|
* me.event.off("event-name", myFunction);
|
|
11888
11969
|
*/
|
|
11889
11970
|
declare function off(eventName: string | symbol, listener: Function): {};
|
|
11890
|
-
/**
|
|
11891
|
-
* Fired when a level is fully loaded and all entities instantiated. <br>
|
|
11892
|
-
* Additionnaly the level id will also be passed to the called function.
|
|
11893
|
-
* @function game.onLevelLoaded
|
|
11894
|
-
* @example
|
|
11895
|
-
* // call myFunction () everytime a level is loaded
|
|
11896
|
-
* me.game.onLevelLoaded = this.myFunction.bind(this);
|
|
11897
|
-
*/
|
|
11898
|
-
declare function onLevelLoaded(): void;
|
|
11899
|
-
/**
|
|
11900
|
-
* reset the game Object manager<br>
|
|
11901
|
-
* destroy all current objects
|
|
11902
|
-
* @function game.reset
|
|
11903
|
-
*/
|
|
11904
|
-
declare function reset(): void;
|
|
11905
|
-
/**
|
|
11906
|
-
* Update the renderer framerate using the system config variables.
|
|
11907
|
-
* @function game.updateFrameRate
|
|
11908
|
-
* @see timer.maxfps
|
|
11909
|
-
* @see World.fps
|
|
11910
|
-
*/
|
|
11911
|
-
declare function updateFrameRate(): void;
|
|
11912
|
-
/**
|
|
11913
|
-
* Returns the parent container of the specified Child in the game world
|
|
11914
|
-
* @function game.getParentContainer
|
|
11915
|
-
* @param {Renderable} child
|
|
11916
|
-
* @returns {Container}
|
|
11917
|
-
*/
|
|
11918
|
-
declare function getParentContainer(child: Renderable): Container;
|
|
11919
|
-
/**
|
|
11920
|
-
* force the redraw (not update) of all objects
|
|
11921
|
-
* @function game.repaint
|
|
11922
|
-
*/
|
|
11923
|
-
declare function repaint(): void;
|
|
11924
|
-
/**
|
|
11925
|
-
* update all objects of the game manager
|
|
11926
|
-
* @ignore
|
|
11927
|
-
* @function game.update
|
|
11928
|
-
* @param {number} time current timestamp as provided by the RAF callback
|
|
11929
|
-
* @param {Stage} stage the current stage
|
|
11930
|
-
*/
|
|
11931
|
-
declare function update(time: number, stage: Stage): void;
|
|
11932
|
-
/**
|
|
11933
|
-
* draw the current scene/stage
|
|
11934
|
-
* @function game.draw
|
|
11935
|
-
* @ignore
|
|
11936
|
-
* @param {Stage} stage the current stage
|
|
11937
|
-
*/
|
|
11938
|
-
declare function draw(stage: Stage): void;
|
|
11939
11971
|
/**
|
|
11940
11972
|
* Translate the specified x and y values from the global (absolute)
|
|
11941
11973
|
* coordinate to local (viewport) relative coordinate.
|
|
@@ -12330,48 +12362,41 @@ declare class ObjectPool {
|
|
|
12330
12362
|
/**
|
|
12331
12363
|
* @classdesc
|
|
12332
12364
|
* a Timer class to manage timing related function (FPS, Game Tick, Time...)
|
|
12333
|
-
|
|
12365
|
+
* @see {@link timer} the default global timer instance
|
|
12334
12366
|
*/
|
|
12335
12367
|
declare class Timer {
|
|
12336
12368
|
/**
|
|
12337
|
-
* Last game tick value
|
|
12338
|
-
* Use this value to scale velocities during frame drops due to slow
|
|
12339
|
-
*
|
|
12340
|
-
* This feature is disabled by default. Enable me.timer.interpolation to
|
|
12341
|
-
* use it.
|
|
12369
|
+
* Last game tick value. <br>
|
|
12370
|
+
* Use this value to scale velocities during frame drops due to slow hardware or when setting an FPS limit.
|
|
12371
|
+
* This feature is disabled by default (Enable interpolation to use it).
|
|
12342
12372
|
* @public
|
|
12343
|
-
* @see
|
|
12373
|
+
* @see interpolation
|
|
12374
|
+
* @See maxfps
|
|
12344
12375
|
* @type {number}
|
|
12345
12376
|
* @name tick
|
|
12346
|
-
* @memberof timer
|
|
12347
12377
|
*/
|
|
12348
12378
|
public tick: number;
|
|
12349
12379
|
/**
|
|
12350
|
-
* Last measured fps rate.<br
|
|
12351
|
-
* This feature is disabled by default, unless the debugPanel is enabled/visible
|
|
12380
|
+
* Last measured fps rate.<br>
|
|
12381
|
+
* This feature is disabled by default, unless the debugPanel is enabled/visible.
|
|
12352
12382
|
* @public
|
|
12353
12383
|
* @type {number}
|
|
12354
12384
|
* @name fps
|
|
12355
|
-
* @memberof timer
|
|
12356
12385
|
*/
|
|
12357
12386
|
public fps: number;
|
|
12358
12387
|
/**
|
|
12359
12388
|
* Set the maximum target display frame per second
|
|
12360
12389
|
* @public
|
|
12361
|
-
* @see
|
|
12390
|
+
* @see tick
|
|
12362
12391
|
* @type {number}
|
|
12363
|
-
* @name maxfps
|
|
12364
12392
|
* @default 60
|
|
12365
|
-
* @memberof timer
|
|
12366
12393
|
*/
|
|
12367
12394
|
public maxfps: number;
|
|
12368
12395
|
/**
|
|
12369
12396
|
* Enable/disable frame interpolation
|
|
12370
|
-
* @see
|
|
12397
|
+
* @see tick
|
|
12371
12398
|
* @type {boolean}
|
|
12372
12399
|
* @default false
|
|
12373
|
-
* @name interpolation
|
|
12374
|
-
* @memberof timer
|
|
12375
12400
|
*/
|
|
12376
12401
|
interpolation: boolean;
|
|
12377
12402
|
framecount: number;
|
|
@@ -12385,15 +12410,11 @@ declare class Timer {
|
|
|
12385
12410
|
timerId: number;
|
|
12386
12411
|
/**
|
|
12387
12412
|
* reset time (e.g. usefull in case of pause)
|
|
12388
|
-
* @name reset
|
|
12389
|
-
* @memberof timer
|
|
12390
12413
|
* @ignore
|
|
12391
12414
|
*/
|
|
12392
12415
|
reset(): void;
|
|
12393
12416
|
/**
|
|
12394
12417
|
* Calls a function once after a specified delay. See me.timer.setInterval to repeativly call a function.
|
|
12395
|
-
* @name setTimeout
|
|
12396
|
-
* @memberof timer
|
|
12397
12418
|
* @param {Function} fn the function you want to execute after delay milliseconds.
|
|
12398
12419
|
* @param {number} delay the number of milliseconds (thousandths of a second) that the function call should be delayed by.
|
|
12399
12420
|
* @param {boolean} [pauseable=true] respects the pause state of the engine.
|
|
@@ -12408,8 +12429,6 @@ declare class Timer {
|
|
|
12408
12429
|
setTimeout(fn: Function, delay: number, pauseable?: boolean, ...args: any[]): number;
|
|
12409
12430
|
/**
|
|
12410
12431
|
* Calls a function continously at the specified interval. See setTimeout to call function a single time.
|
|
12411
|
-
* @name setInterval
|
|
12412
|
-
* @memberof timer
|
|
12413
12432
|
* @param {Function} fn the function to execute
|
|
12414
12433
|
* @param {number} delay the number of milliseconds (thousandths of a second) on how often to execute the function
|
|
12415
12434
|
* @param {boolean} [pauseable=true] respects the pause state of the engine.
|
|
@@ -12424,38 +12443,28 @@ declare class Timer {
|
|
|
12424
12443
|
setInterval(fn: Function, delay: number, pauseable?: boolean, ...args: any[]): number;
|
|
12425
12444
|
/**
|
|
12426
12445
|
* Clears the delay set by me.timer.setTimeout().
|
|
12427
|
-
* @name clearTimeout
|
|
12428
|
-
* @memberof timer
|
|
12429
12446
|
* @param {number} timeoutID ID of the timeout to be cleared
|
|
12430
12447
|
*/
|
|
12431
12448
|
clearTimeout(timeoutID: number): void;
|
|
12432
12449
|
/**
|
|
12433
12450
|
* Clears the Interval set by me.timer.setInterval().
|
|
12434
|
-
* @name clearInterval
|
|
12435
|
-
* @memberof timer
|
|
12436
12451
|
* @param {number} intervalID ID of the interval to be cleared
|
|
12437
12452
|
*/
|
|
12438
12453
|
clearInterval(intervalID: number): void;
|
|
12439
12454
|
/**
|
|
12440
12455
|
* Return the current timestamp in milliseconds <br>
|
|
12441
12456
|
* since the game has started or since linux epoch (based on browser support for High Resolution Timer)
|
|
12442
|
-
* @name getTime
|
|
12443
|
-
* @memberof timer
|
|
12444
12457
|
* @returns {number}
|
|
12445
12458
|
*/
|
|
12446
12459
|
getTime(): number;
|
|
12447
12460
|
/**
|
|
12448
12461
|
* Return elapsed time in milliseconds since the last update
|
|
12449
|
-
* @name getDelta
|
|
12450
|
-
* @memberof timer
|
|
12451
12462
|
* @returns {number}
|
|
12452
12463
|
*/
|
|
12453
12464
|
getDelta(): number;
|
|
12454
12465
|
/**
|
|
12455
12466
|
* compute the actual frame time and fps rate
|
|
12456
|
-
* @name computeFPS
|
|
12457
12467
|
* @ignore
|
|
12458
|
-
* @memberof timer
|
|
12459
12468
|
*/
|
|
12460
12469
|
countFPS(): void;
|
|
12461
12470
|
/**
|
|
@@ -12493,11 +12502,10 @@ declare var fileUtils: Readonly<{
|
|
|
12493
12502
|
declare var stringUtils: Readonly<{
|
|
12494
12503
|
__proto__: any;
|
|
12495
12504
|
capitalize: typeof capitalize;
|
|
12496
|
-
trimLeft: typeof trimLeft;
|
|
12497
|
-
trimRight: typeof trimRight;
|
|
12498
12505
|
isNumeric: typeof isNumeric;
|
|
12499
12506
|
isBoolean: typeof isBoolean;
|
|
12500
12507
|
toHex: typeof toHex$1;
|
|
12508
|
+
isDataUrl: typeof isDataUrl;
|
|
12501
12509
|
}>;
|
|
12502
12510
|
declare var fnUtils: Readonly<{
|
|
12503
12511
|
__proto__: any;
|
|
@@ -12563,10 +12571,10 @@ declare function init(width: number, height: number, options?: {
|
|
|
12563
12571
|
* @function video.createCanvas
|
|
12564
12572
|
* @param {number} width width
|
|
12565
12573
|
* @param {number} height height
|
|
12566
|
-
* @param {boolean} [
|
|
12574
|
+
* @param {boolean} [returnOffscreenCanvas=false] will return an OffscreenCanvas if supported
|
|
12567
12575
|
* @returns {HTMLCanvasElement|OffscreenCanvas}
|
|
12568
12576
|
*/
|
|
12569
|
-
declare function createCanvas(width: number, height: number,
|
|
12577
|
+
declare function createCanvas(width: number, height: number, returnOffscreenCanvas?: boolean): HTMLCanvasElement | OffscreenCanvas;
|
|
12570
12578
|
/**
|
|
12571
12579
|
* return a reference to the parent DOM element holding the main canvas
|
|
12572
12580
|
* @function video.getParent
|
|
@@ -12674,24 +12682,6 @@ declare function getExtension(path: string): string;
|
|
|
12674
12682
|
* @returns {string} the capitalized string
|
|
12675
12683
|
*/
|
|
12676
12684
|
declare function capitalize(str: string): string;
|
|
12677
|
-
/**
|
|
12678
|
-
* returns the string stripped of whitespace from the left.
|
|
12679
|
-
* @public
|
|
12680
|
-
* @memberof utils.string
|
|
12681
|
-
* @name trimLeft
|
|
12682
|
-
* @param {string} str the string to be trimmed
|
|
12683
|
-
* @returns {string} trimmed string
|
|
12684
|
-
*/
|
|
12685
|
-
declare function trimLeft(str: string): string;
|
|
12686
|
-
/**
|
|
12687
|
-
* returns the string stripped of whitespace from the right.
|
|
12688
|
-
* @public
|
|
12689
|
-
* @memberof utils.string
|
|
12690
|
-
* @name trimRight
|
|
12691
|
-
* @param {string} str the string to be trimmed
|
|
12692
|
-
* @returns {string} trimmed string
|
|
12693
|
-
*/
|
|
12694
|
-
declare function trimRight(str: string): string;
|
|
12695
12685
|
/**
|
|
12696
12686
|
* returns true if the given string contains a numeric integer or float value
|
|
12697
12687
|
* @public
|
|
@@ -12719,6 +12709,16 @@ declare function isBoolean(str: string): boolean;
|
|
|
12719
12709
|
* @returns {string} the converted hexadecimal value
|
|
12720
12710
|
*/
|
|
12721
12711
|
declare function toHex$1(str: string): string;
|
|
12712
|
+
/**
|
|
12713
|
+
* returns true if the given string is a data url in the `data:[<mediatype>][;base64],<data>` format.
|
|
12714
|
+
* (this will not test the validity of the Data or Base64 encoding)
|
|
12715
|
+
* @public
|
|
12716
|
+
* @memberof utils.string
|
|
12717
|
+
* @name isDataUrl
|
|
12718
|
+
* @param {string} str the string (url) to be tested
|
|
12719
|
+
* @returns {boolean} true if the string is a data url
|
|
12720
|
+
*/
|
|
12721
|
+
declare function isDataUrl(str: string): boolean;
|
|
12722
12722
|
/**
|
|
12723
12723
|
* a collection of utility functions
|
|
12724
12724
|
* @namespace utils.function
|