melonjs 12.0.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 +4 -6
- package/dist/melonjs.js +22325 -22327
- package/dist/melonjs.min.js +5 -6
- package/dist/melonjs.module.d.ts +184 -171
- package/dist/melonjs.module.js +20780 -20771
- package/package.json +12 -13
- package/src/application/application.js +231 -0
- package/src/audio/audio.js +8 -2
- 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 +27 -28
- 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/renderable/container.js +2 -2
- package/src/renderable/imagelayer.js +8 -8
- 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 +814 -981
- package/src/system/event.js +2 -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/text.js +9 -12
- package/src/tweens/tween.js +6 -6
- package/src/utils/string.js +13 -0
- 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
|
/**
|
|
@@ -5409,16 +5400,18 @@ export class Polygon {
|
|
|
5409
5400
|
*/
|
|
5410
5401
|
export class QuadTree {
|
|
5411
5402
|
/**
|
|
5403
|
+
* @param {World} world the physic world this QuadTree belongs to
|
|
5412
5404
|
* @param {Bounds} bounds bounds of the node
|
|
5413
5405
|
* @param {number} [max_objects=4] max objects a node can hold before splitting into 4 subnodes
|
|
5414
5406
|
* @param {number} [max_levels=4] total max levels inside root Quadtree
|
|
5415
5407
|
* @param {number} [level] deepth level, required for subnodes
|
|
5416
5408
|
*/
|
|
5417
|
-
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;
|
|
5418
5412
|
max_objects: number;
|
|
5419
5413
|
max_levels: number;
|
|
5420
5414
|
level: number;
|
|
5421
|
-
bounds: Bounds;
|
|
5422
5415
|
objects: any[];
|
|
5423
5416
|
nodes: any[];
|
|
5424
5417
|
split(): void;
|
|
@@ -6159,7 +6152,7 @@ export class Renderer {
|
|
|
6159
6152
|
* @param {number} options.width The width of the canvas without scaling
|
|
6160
6153
|
* @param {number} options.height The height of the canvas without scaling
|
|
6161
6154
|
* @param {HTMLCanvasElement} [options.canvas] The html canvas to draw to on screen
|
|
6162
|
-
* @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)
|
|
6163
6156
|
* @param {boolean} [options.antiAlias=false] Whether to enable anti-aliasing, use false (default) for a pixelated effect.
|
|
6164
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.
|
|
6165
6158
|
* @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas (performance hit when enabled)
|
|
@@ -7630,9 +7623,6 @@ export class Text extends Renderable {
|
|
|
7630
7623
|
public fontSize: number;
|
|
7631
7624
|
canvasTexture: any;
|
|
7632
7625
|
metrics: TextMetrics;
|
|
7633
|
-
/** @ignore */
|
|
7634
|
-
onDeactivateEvent(): void;
|
|
7635
|
-
glTextureUnit: any;
|
|
7636
7626
|
/**
|
|
7637
7627
|
* make the font bold
|
|
7638
7628
|
* @returns {Text} this object for chaining
|
|
@@ -7660,6 +7650,7 @@ export class Text extends Renderable {
|
|
|
7660
7650
|
* @returns {Text} this object for chaining
|
|
7661
7651
|
*/
|
|
7662
7652
|
setText(value?: number | string | string[]): Text;
|
|
7653
|
+
glTextureUnit: any;
|
|
7663
7654
|
/**
|
|
7664
7655
|
* measure the given text size in pixels
|
|
7665
7656
|
* @param {CanvasRenderer|WebGLRenderer} renderer reference to the active renderer
|
|
@@ -9058,7 +9049,7 @@ export class WebGLRenderer extends Renderer {
|
|
|
9058
9049
|
* @param {number} options.width The width of the canvas without scaling
|
|
9059
9050
|
* @param {number} options.height The height of the canvas without scaling
|
|
9060
9051
|
* @param {HTMLCanvasElement} [options.canvas] The html canvas to draw to on screen
|
|
9061
|
-
* @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)
|
|
9062
9053
|
* @param {boolean} [options.antiAlias=false] Whether to enable anti-aliasing
|
|
9063
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.
|
|
9064
9055
|
* @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas (performance hit when enabled)
|
|
@@ -9562,6 +9553,12 @@ export class World extends Container {
|
|
|
9562
9553
|
* @param {number} [height=game.viewport.height] height of the container
|
|
9563
9554
|
*/
|
|
9564
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;
|
|
9565
9562
|
/**
|
|
9566
9563
|
* the rate at which the game world is updated,
|
|
9567
9564
|
* may be greater than or lower than the display fps
|
|
@@ -9629,6 +9626,14 @@ export class World extends Container {
|
|
|
9629
9626
|
* @returns {World} this game world
|
|
9630
9627
|
*/
|
|
9631
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;
|
|
9632
9637
|
}
|
|
9633
9638
|
export var audio: Readonly<{
|
|
9634
9639
|
__proto__: any;
|
|
@@ -9740,29 +9745,7 @@ export namespace collision {
|
|
|
9740
9745
|
*/
|
|
9741
9746
|
function rayCast(line: Line, result?: Renderable[]): Renderable[];
|
|
9742
9747
|
}
|
|
9743
|
-
export
|
|
9744
|
-
const devicePixelRatio: number;
|
|
9745
|
-
const isFullscreen: boolean;
|
|
9746
|
-
const sound: boolean;
|
|
9747
|
-
/**
|
|
9748
|
-
* @public
|
|
9749
|
-
* @name turnOnPointerLock
|
|
9750
|
-
* @returns {boolean} return true if the request was successfully submitted
|
|
9751
|
-
* @memberof device#
|
|
9752
|
-
* @deprecated since 10.3.0
|
|
9753
|
-
* @see input.requestPointerLock
|
|
9754
|
-
*/
|
|
9755
|
-
function turnOnPointerLock(): boolean;
|
|
9756
|
-
/**
|
|
9757
|
-
* @public
|
|
9758
|
-
* @name turnOffPointerLock
|
|
9759
|
-
* @returns {boolean} return true if the request was successfully submitted
|
|
9760
|
-
* @memberof device#
|
|
9761
|
-
* @deprecated since 10.3.0
|
|
9762
|
-
* @see input.exitPointerLock
|
|
9763
|
-
*/
|
|
9764
|
-
function turnOffPointerLock(): boolean;
|
|
9765
|
-
}
|
|
9748
|
+
export var device: any;
|
|
9766
9749
|
export var event: Readonly<{
|
|
9767
9750
|
__proto__: any;
|
|
9768
9751
|
DOM_READY: string;
|
|
@@ -9805,21 +9788,13 @@ export var event: Readonly<{
|
|
|
9805
9788
|
once: typeof once;
|
|
9806
9789
|
off: typeof off;
|
|
9807
9790
|
}>;
|
|
9808
|
-
|
|
9809
|
-
|
|
9810
|
-
|
|
9811
|
-
|
|
9812
|
-
|
|
9813
|
-
|
|
9814
|
-
|
|
9815
|
-
onLevelLoaded: typeof onLevelLoaded;
|
|
9816
|
-
reset: typeof reset;
|
|
9817
|
-
updateFrameRate: typeof updateFrameRate;
|
|
9818
|
-
getParentContainer: typeof getParentContainer;
|
|
9819
|
-
repaint: typeof repaint;
|
|
9820
|
-
update: typeof update;
|
|
9821
|
-
draw: typeof draw;
|
|
9822
|
-
}>;
|
|
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;
|
|
9823
9798
|
/**
|
|
9824
9799
|
* a flag indicating that melonJS is fully initialized
|
|
9825
9800
|
* @type {boolean}
|
|
@@ -10154,7 +10129,7 @@ export namespace level {
|
|
|
10154
10129
|
* @param {string} levelId level id
|
|
10155
10130
|
* @param {object} [options] additional optional parameters
|
|
10156
10131
|
* @param {Container} [options.container=game.world] container in which to load the specified level
|
|
10157
|
-
* @param {Function} [options.onLoaded=
|
|
10132
|
+
* @param {Function} [options.onLoaded=game.onLevelLoaded] callback for when the level is fully loaded
|
|
10158
10133
|
* @param {boolean} [options.flatten=game.mergeGroup] if true, flatten all objects into the given container
|
|
10159
10134
|
* @param {boolean} [options.setViewportBounds=true] if true, set the viewport bounds to the map size
|
|
10160
10135
|
* @returns {boolean} true if the level was successfully loaded
|
|
@@ -10199,7 +10174,7 @@ export namespace level {
|
|
|
10199
10174
|
* @param {string} levelId level id
|
|
10200
10175
|
* @param {object} [options] additional optional parameters
|
|
10201
10176
|
* @param {Container} [options.container=game.world] container in which to load the specified level
|
|
10202
|
-
* @param {Function} [options.onLoaded=
|
|
10177
|
+
* @param {Function} [options.onLoaded=game.onLevelLoaded] callback for when the level is fully loaded
|
|
10203
10178
|
* @param {boolean} [options.flatten=game.mergeGroup] if true, flatten all objects into the given container
|
|
10204
10179
|
* @param {boolean} [options.setViewportBounds=true] if true, set the viewport bounds to the map size
|
|
10205
10180
|
* @returns {boolean} true if the level was successfully loaded
|
|
@@ -10468,6 +10443,8 @@ export namespace loader {
|
|
|
10468
10443
|
* {name: "tileset-platformer", type: "image", src: "data/map/tileset.png"},
|
|
10469
10444
|
* // PNG packed texture
|
|
10470
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..."}
|
|
10471
10448
|
* // TSX file
|
|
10472
10449
|
* {name: "meta_tiles", type: "tsx", src: "data/map/meta_tiles.tsx"},
|
|
10473
10450
|
* // TMX level (XML & JSON)
|
|
@@ -10478,6 +10455,8 @@ export namespace loader {
|
|
|
10478
10455
|
* // audio resources
|
|
10479
10456
|
* {name: "bgmusic", type: "audio", src: "data/audio/"},
|
|
10480
10457
|
* {name: "cling", type: "audio", src: "data/audio/"},
|
|
10458
|
+
* // base64 encoded audio resources
|
|
10459
|
+
* {name: "band", type: "audio", src: "data:audio/wav;base64,..."},
|
|
10481
10460
|
* // binary file
|
|
10482
10461
|
* {name: "ymTrack", type: "binary", src: "data/audio/main.ym"},
|
|
10483
10462
|
* // JSON file (used for texturePacker)
|
|
@@ -10515,6 +10494,8 @@ export namespace loader {
|
|
|
10515
10494
|
* {name: "tileset-platformer", type: "image", src: "data/map/tileset.png"},
|
|
10516
10495
|
* // PNG packed texture
|
|
10517
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..."}
|
|
10518
10499
|
* // TSX file
|
|
10519
10500
|
* {name: "meta_tiles", type: "tsx", src: "data/map/meta_tiles.tsx"},
|
|
10520
10501
|
* // TMX level (XML & JSON)
|
|
@@ -10525,6 +10506,8 @@ export namespace loader {
|
|
|
10525
10506
|
* // audio resources
|
|
10526
10507
|
* {name: "bgmusic", type: "audio", src: "data/audio/"},
|
|
10527
10508
|
* {name: "cling", type: "audio", src: "data/audio/"},
|
|
10509
|
+
* // base64 encoded audio resources
|
|
10510
|
+
* {name: "band", type: "audio", src: "data:audio/wav;base64,..."},
|
|
10528
10511
|
* // binary file
|
|
10529
10512
|
* {name: "ymTrack", type: "binary", src: "data/audio/main.ym"},
|
|
10530
10513
|
* // JSON file (used for texturePacker)
|
|
@@ -10554,13 +10537,14 @@ export namespace loader {
|
|
|
10554
10537
|
* @param {string} res.type "audio", binary", "image", "json", "tmx", "tsx"
|
|
10555
10538
|
* @param {string} res.src path and/or file name of the resource (for audio assets only the path is required)
|
|
10556
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.
|
|
10557
|
-
* @param {Function} onload function to be called when the resource is loaded
|
|
10558
|
-
* @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
|
|
10559
10542
|
* @returns {number} the amount of corresponding resource to be preloaded
|
|
10560
10543
|
* @example
|
|
10561
10544
|
* // load an image asset
|
|
10562
10545
|
* me.loader.load({name: "avatar", type:"image", src: "data/avatar.png"}, this.onload.bind(this), this.onerror.bind(this));
|
|
10563
|
-
*
|
|
10546
|
+
* // load a base64 image asset
|
|
10547
|
+
* me.loader.load({name: "avatar", type:"image", src: "data:image/png;base64,iVBORw0KAAAQAAAAEACA..."};
|
|
10564
10548
|
* // start loading music
|
|
10565
10549
|
* me.loader.load({
|
|
10566
10550
|
* name : "bgmusic",
|
|
@@ -10575,7 +10559,7 @@ export namespace loader {
|
|
|
10575
10559
|
type: string;
|
|
10576
10560
|
src: string;
|
|
10577
10561
|
stream?: boolean;
|
|
10578
|
-
}, onload
|
|
10562
|
+
}, onload?: Function, onerror?: Function): number;
|
|
10579
10563
|
/**
|
|
10580
10564
|
* Load a single resource (to be used if you need to load additional resource during the game)
|
|
10581
10565
|
* @name load
|
|
@@ -10586,13 +10570,14 @@ export namespace loader {
|
|
|
10586
10570
|
* @param {string} res.type "audio", binary", "image", "json", "tmx", "tsx"
|
|
10587
10571
|
* @param {string} res.src path and/or file name of the resource (for audio assets only the path is required)
|
|
10588
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.
|
|
10589
|
-
* @param {Function} onload function to be called when the resource is loaded
|
|
10590
|
-
* @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
|
|
10591
10575
|
* @returns {number} the amount of corresponding resource to be preloaded
|
|
10592
10576
|
* @example
|
|
10593
10577
|
* // load an image asset
|
|
10594
10578
|
* me.loader.load({name: "avatar", type:"image", src: "data/avatar.png"}, this.onload.bind(this), this.onerror.bind(this));
|
|
10595
|
-
*
|
|
10579
|
+
* // load a base64 image asset
|
|
10580
|
+
* me.loader.load({name: "avatar", type:"image", src: "data:image/png;base64,iVBORw0KAAAQAAAAEACA..."};
|
|
10596
10581
|
* // start loading music
|
|
10597
10582
|
* me.loader.load({
|
|
10598
10583
|
* name : "bgmusic",
|
|
@@ -10607,7 +10592,7 @@ export namespace loader {
|
|
|
10607
10592
|
type: string;
|
|
10608
10593
|
src: string;
|
|
10609
10594
|
stream?: boolean;
|
|
10610
|
-
}, onload
|
|
10595
|
+
}, onload?: Function, onerror?: Function): number;
|
|
10611
10596
|
/**
|
|
10612
10597
|
* unload specified resource to free memory
|
|
10613
10598
|
* @name unload
|
|
@@ -11115,20 +11100,6 @@ export namespace state {
|
|
|
11115
11100
|
*/
|
|
11116
11101
|
export function isCurrent(state: number): boolean;
|
|
11117
11102
|
}
|
|
11118
|
-
/**
|
|
11119
|
-
* the default global Timer instance
|
|
11120
|
-
* @namespace timer
|
|
11121
|
-
* @see Timer
|
|
11122
|
-
* @example
|
|
11123
|
-
* // set a timer to call "myFunction" after 1000ms
|
|
11124
|
-
* timer.setTimeout(myFunction, 1000);
|
|
11125
|
-
* // set a timer to call "myFunction" after 1000ms (respecting the pause state) and passing param1 and param2
|
|
11126
|
-
* timer.setTimeout(myFunction, 1000, true, param1, param2);
|
|
11127
|
-
* // set a timer to call "myFunction" every 1000ms
|
|
11128
|
-
* timer.setInterval(myFunction, 1000);
|
|
11129
|
-
* // set a timer to call "myFunction" every 1000ms (respecting the pause state) and passing param1 and param2
|
|
11130
|
-
* timer.setInterval(myFunction, 1000, true, param1, param2);
|
|
11131
|
-
*/
|
|
11132
11103
|
export const timer: Timer;
|
|
11133
11104
|
export namespace utils {
|
|
11134
11105
|
export { agentUtils as agent };
|
|
@@ -11157,7 +11128,7 @@ export var video: Readonly<{
|
|
|
11157
11128
|
AUTO: 2;
|
|
11158
11129
|
readonly parent: HTMLElement;
|
|
11159
11130
|
scaleRatio: Vector2d;
|
|
11160
|
-
readonly renderer:
|
|
11131
|
+
readonly renderer: WebGLRenderer | CanvasRenderer;
|
|
11161
11132
|
init: typeof init;
|
|
11162
11133
|
createCanvas: typeof createCanvas;
|
|
11163
11134
|
getParent: typeof getParent;
|
|
@@ -11593,6 +11564,109 @@ declare class VertexArrayBuffer {
|
|
|
11593
11564
|
*/
|
|
11594
11565
|
isEmpty(): boolean;
|
|
11595
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
|
+
}
|
|
11596
11670
|
/**
|
|
11597
11671
|
* Initialize and configure the audio support.<br>
|
|
11598
11672
|
* melonJS supports a wide array of audio codecs that have varying browser support :
|
|
@@ -11894,55 +11968,6 @@ declare function once(eventName: string | symbol, listener: Function, context?:
|
|
|
11894
11968
|
* me.event.off("event-name", myFunction);
|
|
11895
11969
|
*/
|
|
11896
11970
|
declare function off(eventName: string | symbol, listener: Function): {};
|
|
11897
|
-
/**
|
|
11898
|
-
* Fired when a level is fully loaded and all entities instantiated. <br>
|
|
11899
|
-
* Additionnaly the level id will also be passed to the called function.
|
|
11900
|
-
* @function game.onLevelLoaded
|
|
11901
|
-
* @example
|
|
11902
|
-
* // call myFunction () everytime a level is loaded
|
|
11903
|
-
* me.game.onLevelLoaded = this.myFunction.bind(this);
|
|
11904
|
-
*/
|
|
11905
|
-
declare function onLevelLoaded(): void;
|
|
11906
|
-
/**
|
|
11907
|
-
* reset the game Object manager<br>
|
|
11908
|
-
* destroy all current objects
|
|
11909
|
-
* @function game.reset
|
|
11910
|
-
*/
|
|
11911
|
-
declare function reset(): void;
|
|
11912
|
-
/**
|
|
11913
|
-
* Update the renderer framerate using the system config variables.
|
|
11914
|
-
* @function game.updateFrameRate
|
|
11915
|
-
* @see timer.maxfps
|
|
11916
|
-
* @see World.fps
|
|
11917
|
-
*/
|
|
11918
|
-
declare function updateFrameRate(): void;
|
|
11919
|
-
/**
|
|
11920
|
-
* Returns the parent container of the specified Child in the game world
|
|
11921
|
-
* @function game.getParentContainer
|
|
11922
|
-
* @param {Renderable} child
|
|
11923
|
-
* @returns {Container}
|
|
11924
|
-
*/
|
|
11925
|
-
declare function getParentContainer(child: Renderable): Container;
|
|
11926
|
-
/**
|
|
11927
|
-
* force the redraw (not update) of all objects
|
|
11928
|
-
* @function game.repaint
|
|
11929
|
-
*/
|
|
11930
|
-
declare function repaint(): void;
|
|
11931
|
-
/**
|
|
11932
|
-
* update all objects of the game manager
|
|
11933
|
-
* @ignore
|
|
11934
|
-
* @function game.update
|
|
11935
|
-
* @param {number} time current timestamp as provided by the RAF callback
|
|
11936
|
-
* @param {Stage} stage the current stage
|
|
11937
|
-
*/
|
|
11938
|
-
declare function update(time: number, stage: Stage): void;
|
|
11939
|
-
/**
|
|
11940
|
-
* draw the current scene/stage
|
|
11941
|
-
* @function game.draw
|
|
11942
|
-
* @ignore
|
|
11943
|
-
* @param {Stage} stage the current stage
|
|
11944
|
-
*/
|
|
11945
|
-
declare function draw(stage: Stage): void;
|
|
11946
11971
|
/**
|
|
11947
11972
|
* Translate the specified x and y values from the global (absolute)
|
|
11948
11973
|
* coordinate to local (viewport) relative coordinate.
|
|
@@ -12337,48 +12362,41 @@ declare class ObjectPool {
|
|
|
12337
12362
|
/**
|
|
12338
12363
|
* @classdesc
|
|
12339
12364
|
* a Timer class to manage timing related function (FPS, Game Tick, Time...)
|
|
12340
|
-
|
|
12365
|
+
* @see {@link timer} the default global timer instance
|
|
12341
12366
|
*/
|
|
12342
12367
|
declare class Timer {
|
|
12343
12368
|
/**
|
|
12344
|
-
* Last game tick value
|
|
12345
|
-
* Use this value to scale velocities during frame drops due to slow
|
|
12346
|
-
*
|
|
12347
|
-
* This feature is disabled by default. Enable me.timer.interpolation to
|
|
12348
|
-
* 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).
|
|
12349
12372
|
* @public
|
|
12350
|
-
* @see
|
|
12373
|
+
* @see interpolation
|
|
12374
|
+
* @See maxfps
|
|
12351
12375
|
* @type {number}
|
|
12352
12376
|
* @name tick
|
|
12353
|
-
* @memberof timer
|
|
12354
12377
|
*/
|
|
12355
12378
|
public tick: number;
|
|
12356
12379
|
/**
|
|
12357
|
-
* Last measured fps rate.<br
|
|
12358
|
-
* 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.
|
|
12359
12382
|
* @public
|
|
12360
12383
|
* @type {number}
|
|
12361
12384
|
* @name fps
|
|
12362
|
-
* @memberof timer
|
|
12363
12385
|
*/
|
|
12364
12386
|
public fps: number;
|
|
12365
12387
|
/**
|
|
12366
12388
|
* Set the maximum target display frame per second
|
|
12367
12389
|
* @public
|
|
12368
|
-
* @see
|
|
12390
|
+
* @see tick
|
|
12369
12391
|
* @type {number}
|
|
12370
|
-
* @name maxfps
|
|
12371
12392
|
* @default 60
|
|
12372
|
-
* @memberof timer
|
|
12373
12393
|
*/
|
|
12374
12394
|
public maxfps: number;
|
|
12375
12395
|
/**
|
|
12376
12396
|
* Enable/disable frame interpolation
|
|
12377
|
-
* @see
|
|
12397
|
+
* @see tick
|
|
12378
12398
|
* @type {boolean}
|
|
12379
12399
|
* @default false
|
|
12380
|
-
* @name interpolation
|
|
12381
|
-
* @memberof timer
|
|
12382
12400
|
*/
|
|
12383
12401
|
interpolation: boolean;
|
|
12384
12402
|
framecount: number;
|
|
@@ -12392,15 +12410,11 @@ declare class Timer {
|
|
|
12392
12410
|
timerId: number;
|
|
12393
12411
|
/**
|
|
12394
12412
|
* reset time (e.g. usefull in case of pause)
|
|
12395
|
-
* @name reset
|
|
12396
|
-
* @memberof timer
|
|
12397
12413
|
* @ignore
|
|
12398
12414
|
*/
|
|
12399
12415
|
reset(): void;
|
|
12400
12416
|
/**
|
|
12401
12417
|
* Calls a function once after a specified delay. See me.timer.setInterval to repeativly call a function.
|
|
12402
|
-
* @name setTimeout
|
|
12403
|
-
* @memberof timer
|
|
12404
12418
|
* @param {Function} fn the function you want to execute after delay milliseconds.
|
|
12405
12419
|
* @param {number} delay the number of milliseconds (thousandths of a second) that the function call should be delayed by.
|
|
12406
12420
|
* @param {boolean} [pauseable=true] respects the pause state of the engine.
|
|
@@ -12415,8 +12429,6 @@ declare class Timer {
|
|
|
12415
12429
|
setTimeout(fn: Function, delay: number, pauseable?: boolean, ...args: any[]): number;
|
|
12416
12430
|
/**
|
|
12417
12431
|
* Calls a function continously at the specified interval. See setTimeout to call function a single time.
|
|
12418
|
-
* @name setInterval
|
|
12419
|
-
* @memberof timer
|
|
12420
12432
|
* @param {Function} fn the function to execute
|
|
12421
12433
|
* @param {number} delay the number of milliseconds (thousandths of a second) on how often to execute the function
|
|
12422
12434
|
* @param {boolean} [pauseable=true] respects the pause state of the engine.
|
|
@@ -12431,38 +12443,28 @@ declare class Timer {
|
|
|
12431
12443
|
setInterval(fn: Function, delay: number, pauseable?: boolean, ...args: any[]): number;
|
|
12432
12444
|
/**
|
|
12433
12445
|
* Clears the delay set by me.timer.setTimeout().
|
|
12434
|
-
* @name clearTimeout
|
|
12435
|
-
* @memberof timer
|
|
12436
12446
|
* @param {number} timeoutID ID of the timeout to be cleared
|
|
12437
12447
|
*/
|
|
12438
12448
|
clearTimeout(timeoutID: number): void;
|
|
12439
12449
|
/**
|
|
12440
12450
|
* Clears the Interval set by me.timer.setInterval().
|
|
12441
|
-
* @name clearInterval
|
|
12442
|
-
* @memberof timer
|
|
12443
12451
|
* @param {number} intervalID ID of the interval to be cleared
|
|
12444
12452
|
*/
|
|
12445
12453
|
clearInterval(intervalID: number): void;
|
|
12446
12454
|
/**
|
|
12447
12455
|
* Return the current timestamp in milliseconds <br>
|
|
12448
12456
|
* since the game has started or since linux epoch (based on browser support for High Resolution Timer)
|
|
12449
|
-
* @name getTime
|
|
12450
|
-
* @memberof timer
|
|
12451
12457
|
* @returns {number}
|
|
12452
12458
|
*/
|
|
12453
12459
|
getTime(): number;
|
|
12454
12460
|
/**
|
|
12455
12461
|
* Return elapsed time in milliseconds since the last update
|
|
12456
|
-
* @name getDelta
|
|
12457
|
-
* @memberof timer
|
|
12458
12462
|
* @returns {number}
|
|
12459
12463
|
*/
|
|
12460
12464
|
getDelta(): number;
|
|
12461
12465
|
/**
|
|
12462
12466
|
* compute the actual frame time and fps rate
|
|
12463
|
-
* @name computeFPS
|
|
12464
12467
|
* @ignore
|
|
12465
|
-
* @memberof timer
|
|
12466
12468
|
*/
|
|
12467
12469
|
countFPS(): void;
|
|
12468
12470
|
/**
|
|
@@ -12503,6 +12505,7 @@ declare var stringUtils: Readonly<{
|
|
|
12503
12505
|
isNumeric: typeof isNumeric;
|
|
12504
12506
|
isBoolean: typeof isBoolean;
|
|
12505
12507
|
toHex: typeof toHex$1;
|
|
12508
|
+
isDataUrl: typeof isDataUrl;
|
|
12506
12509
|
}>;
|
|
12507
12510
|
declare var fnUtils: Readonly<{
|
|
12508
12511
|
__proto__: any;
|
|
@@ -12568,10 +12571,10 @@ declare function init(width: number, height: number, options?: {
|
|
|
12568
12571
|
* @function video.createCanvas
|
|
12569
12572
|
* @param {number} width width
|
|
12570
12573
|
* @param {number} height height
|
|
12571
|
-
* @param {boolean} [
|
|
12574
|
+
* @param {boolean} [returnOffscreenCanvas=false] will return an OffscreenCanvas if supported
|
|
12572
12575
|
* @returns {HTMLCanvasElement|OffscreenCanvas}
|
|
12573
12576
|
*/
|
|
12574
|
-
declare function createCanvas(width: number, height: number,
|
|
12577
|
+
declare function createCanvas(width: number, height: number, returnOffscreenCanvas?: boolean): HTMLCanvasElement | OffscreenCanvas;
|
|
12575
12578
|
/**
|
|
12576
12579
|
* return a reference to the parent DOM element holding the main canvas
|
|
12577
12580
|
* @function video.getParent
|
|
@@ -12706,6 +12709,16 @@ declare function isBoolean(str: string): boolean;
|
|
|
12706
12709
|
* @returns {string} the converted hexadecimal value
|
|
12707
12710
|
*/
|
|
12708
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;
|
|
12709
12722
|
/**
|
|
12710
12723
|
* a collection of utility functions
|
|
12711
12724
|
* @namespace utils.function
|