melonjs 15.1.6 → 15.2.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/README.md +6 -6
- 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 +3 -3
- package/dist/melonjs.mjs/application/header.js +1 -1
- package/dist/melonjs.mjs/application/resize.js +1 -1
- package/dist/melonjs.mjs/application/settings.js +1 -1
- package/dist/melonjs.mjs/audio/audio.js +1 -1
- package/dist/melonjs.mjs/camera/camera2d.js +1 -1
- package/dist/melonjs.mjs/const.js +1 -1
- package/dist/melonjs.mjs/entity/entity.js +1 -1
- package/dist/melonjs.mjs/geometries/ellipse.js +1 -1
- package/dist/melonjs.mjs/geometries/line.js +1 -1
- package/dist/melonjs.mjs/geometries/path2d.js +1 -1
- package/dist/melonjs.mjs/geometries/point.js +1 -1
- package/dist/melonjs.mjs/geometries/poly.js +1 -1
- package/dist/melonjs.mjs/geometries/rectangle.js +1 -1
- package/dist/melonjs.mjs/geometries/roundrect.js +1 -1
- package/dist/melonjs.mjs/index.js +12 -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 +1 -1
- package/dist/melonjs.mjs/input/pointer.js +1 -1
- package/dist/melonjs.mjs/input/pointerevent.js +1 -1
- package/dist/melonjs.mjs/lang/console.js +1 -1
- package/dist/melonjs.mjs/lang/deprecated.js +1 -1
- package/dist/melonjs.mjs/level/level.js +5 -4
- package/dist/melonjs.mjs/level/tiled/TMXGroup.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXLayer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXObject.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXTile.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +3 -3
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +127 -95
- package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
- 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 +1 -1
- package/dist/melonjs.mjs/loader/settings.js +1 -1
- package/dist/melonjs.mjs/math/color.js +1 -1
- package/dist/melonjs.mjs/math/math.js +1 -1
- package/dist/melonjs.mjs/math/matrix2.js +1 -1
- package/dist/melonjs.mjs/math/matrix3.js +1 -1
- package/dist/melonjs.mjs/math/observable_vector2.js +1 -1
- package/dist/melonjs.mjs/math/observable_vector3.js +1 -1
- package/dist/melonjs.mjs/math/vector2.js +1 -1
- package/dist/melonjs.mjs/math/vector3.js +1 -1
- 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 +1 -1
- package/dist/melonjs.mjs/particles/particle.js +1 -1
- package/dist/melonjs.mjs/particles/settings.js +1 -1
- package/dist/melonjs.mjs/physics/body.js +1 -1
- package/dist/melonjs.mjs/physics/bounds.js +1 -1
- package/dist/melonjs.mjs/physics/collision.js +1 -1
- package/dist/melonjs.mjs/physics/detector.js +1 -1
- package/dist/melonjs.mjs/physics/quadtree.js +1 -1
- package/dist/melonjs.mjs/physics/response.js +1 -1
- package/dist/melonjs.mjs/physics/sat.js +1 -1
- package/dist/melonjs.mjs/physics/world.js +1 -1
- package/dist/melonjs.mjs/plugin/plugin.js +106 -108
- package/dist/melonjs.mjs/renderable/collectable.js +1 -1
- package/dist/melonjs.mjs/renderable/colorlayer.js +1 -1
- package/dist/melonjs.mjs/renderable/container.js +7 -6
- 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 +1 -1
- package/dist/melonjs.mjs/renderable/light2d.js +1 -1
- package/dist/melonjs.mjs/renderable/nineslicesprite.js +1 -1
- package/dist/melonjs.mjs/renderable/renderable.js +1 -1
- package/dist/melonjs.mjs/renderable/sprite.js +1 -1
- package/dist/melonjs.mjs/renderable/trigger.js +1 -1
- package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +1 -1
- package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +1 -1
- package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +1 -1
- package/dist/melonjs.mjs/state/stage.js +1 -1
- package/dist/melonjs.mjs/state/state.js +1 -1
- package/dist/melonjs.mjs/system/device.js +1 -1
- package/dist/melonjs.mjs/system/dom.js +1 -1
- package/dist/melonjs.mjs/system/event.js +1 -1
- package/dist/melonjs.mjs/system/platform.js +1 -1
- package/dist/melonjs.mjs/system/pooling.js +1 -1
- package/dist/melonjs.mjs/system/save.js +1 -1
- package/dist/melonjs.mjs/system/timer.js +4 -4
- package/dist/melonjs.mjs/text/bitmaptext.js +1 -1
- package/dist/melonjs.mjs/text/bitmaptextdata.js +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist/melonjs.mjs/utils/string.js +1 -1
- package/dist/melonjs.mjs/utils/utils.js +105 -111
- package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +1 -1
- package/dist/melonjs.mjs/video/renderer.js +1 -1
- package/dist/melonjs.mjs/video/texture/atlas.js +1 -1
- package/dist/melonjs.mjs/video/texture/cache.js +1 -1
- package/dist/melonjs.mjs/video/texture/canvas_texture.js +1 -1
- package/dist/melonjs.mjs/video/utils/autodetect.js +1 -1
- package/dist/melonjs.mjs/video/video.js +6 -32
- package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +1 -1
- package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +1 -1
- package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +1 -1
- package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +1 -1
- package/dist/melonjs.mjs/video/webgl/glshader.js +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist/melonjs.module.js +595 -570
- package/dist/types/index.d.ts +5 -4
- package/dist/types/level/tiled/TMXUtils.d.ts +19 -36
- package/dist/types/plugin/plugin.d.ts +60 -5
- package/dist/types/utils/utils.d.ts +56 -17
- package/dist/types/video/video.d.ts +1 -21
- package/package.json +5 -5
- package/src/application/application.js +2 -2
- package/src/index.js +5 -2
- package/src/level/level.js +4 -3
- package/src/level/tiled/TMXTileMap.js +2 -2
- package/src/level/tiled/TMXUtils.js +126 -94
- package/src/plugin/plugin.js +103 -105
- package/src/renderable/container.js +6 -5
- package/src/system/timer.js +3 -3
- package/src/utils/utils.js +102 -111
- package/src/video/video.js +6 -8
package/dist/types/index.d.ts
CHANGED
|
@@ -40,9 +40,9 @@ import * as loader from "./loader/loader.js";
|
|
|
40
40
|
import level from "./level/level.js";
|
|
41
41
|
import * as input from "./input/input.js";
|
|
42
42
|
import * as Math from "./math/math.js";
|
|
43
|
-
import
|
|
44
|
-
import { plugins } from "./plugin/plugin.js";
|
|
45
|
-
import utils from "./utils/utils.js";
|
|
43
|
+
import * as plugin from "./plugin/plugin.js";
|
|
44
|
+
import { cache as plugins } from "./plugin/plugin.js";
|
|
45
|
+
import * as utils from "./utils/utils.js";
|
|
46
46
|
import save from "./system/save.js";
|
|
47
47
|
import timer from "./system/timer.js";
|
|
48
48
|
import pool from "./system/pooling.js";
|
|
@@ -100,6 +100,7 @@ import TMXTileset from "./level/tiled/TMXTileset.js";
|
|
|
100
100
|
import TMXTilesetGroup from "./level/tiled/TMXTilesetGroup.js";
|
|
101
101
|
import TMXTileMap from "./level/tiled/TMXTileMap.js";
|
|
102
102
|
import TMXLayer from "./level/tiled/TMXLayer.js";
|
|
103
|
+
import * as TMXUtils from "./level/tiled/TMXUtils.js";
|
|
103
104
|
import Pointer from "./input/pointer.js";
|
|
104
105
|
import Stage from "./state/stage.js";
|
|
105
106
|
import Camera2d from "./camera/camera2d.js";
|
|
@@ -110,4 +111,4 @@ import ParticleEmitterSettings from "./particles/settings.js";
|
|
|
110
111
|
import Particle from "./particles/particle.js";
|
|
111
112
|
import Entity from "./entity/entity.js";
|
|
112
113
|
import Application from "./application/application.js";
|
|
113
|
-
export { audio, collision, device, event, loader, level, input, Math, plugin, plugins, utils, save, timer, pool, state, video, Color, Vector2d, Vector3d, ObservableVector2d, ObservableVector3d, Matrix2d, Matrix3d, Polygon, Line, Ellipse, Point, Rect, RoundRect, Tween, QuadTree, GLShader, Compositor, PrimitiveCompositor, QuadCompositor, Renderer, WebGLRenderer, CanvasRenderer, CanvasTexture, TextureAtlas, Renderable, Body, Bounds, Text, BitmapText, BitmapTextData, ColorLayer, ImageLayer, Sprite, NineSliceSprite, UIBaseElement, UITextButton, UISpriteElement, Collectable, Trigger, Light2d, Draggable, DropTarget, TMXRenderer, TMXOrthogonalRenderer, TMXIsometricRenderer, TMXHexagonalRenderer, TMXStaggeredRenderer, Tile, TMXTileset, TMXTilesetGroup, TMXTileMap, TMXLayer, Pointer, Stage, Camera2d, Container, World, ParticleEmitter, ParticleEmitterSettings, Particle, Entity, Application };
|
|
114
|
+
export { audio, collision, device, event, loader, level, input, Math, plugin, plugins, utils, save, timer, pool, state, video, Color, Vector2d, Vector3d, ObservableVector2d, ObservableVector3d, Matrix2d, Matrix3d, Polygon, Line, Ellipse, Point, Rect, RoundRect, Tween, QuadTree, GLShader, Compositor, PrimitiveCompositor, QuadCompositor, Renderer, WebGLRenderer, CanvasRenderer, CanvasTexture, TextureAtlas, Renderable, Body, Bounds, Text, BitmapText, BitmapTextData, ColorLayer, ImageLayer, Sprite, NineSliceSprite, UIBaseElement, UITextButton, UISpriteElement, Collectable, Trigger, Light2d, Draggable, DropTarget, TMXRenderer, TMXOrthogonalRenderer, TMXIsometricRenderer, TMXHexagonalRenderer, TMXStaggeredRenderer, Tile, TMXTileset, TMXTilesetGroup, TMXTileMap, TMXLayer, TMXUtils, Pointer, Stage, Camera2d, Container, World, ParticleEmitter, ParticleEmitterSettings, Particle, Entity, Application };
|
|
@@ -1,48 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @
|
|
4
|
-
* @name decompress
|
|
5
|
-
* @param {string} input - Base64 encoded and compressed data
|
|
6
|
-
* @param {string} format - compressed data format ("gzip","zlib", "zstd")
|
|
7
|
-
* @returns {Uint32Array} Decoded and decompress data
|
|
2
|
+
* set the function used to inflate gzip/zlib data
|
|
3
|
+
* @param {Func} fn - inflate function
|
|
8
4
|
*/
|
|
9
|
-
export function
|
|
5
|
+
export function setInflateFunction(fn: Func): void;
|
|
10
6
|
/**
|
|
11
|
-
* Decode a
|
|
12
|
-
* @ignore
|
|
7
|
+
* Decode a encoded array into a binary array
|
|
13
8
|
* @name decodeCSV
|
|
14
|
-
* @
|
|
9
|
+
* @memberOf TMXUtils
|
|
10
|
+
* @param {string} data - data to be decoded
|
|
11
|
+
* @param {string} [encoding="none"] - data encoding ("csv", "base64", "xml")
|
|
15
12
|
* @returns {number[]} Decoded data
|
|
16
13
|
*/
|
|
17
|
-
export function
|
|
18
|
-
/**
|
|
19
|
-
* Decode a base64 encoded string into a byte array
|
|
20
|
-
* @ignore
|
|
21
|
-
* @name decodeBase64AsArray
|
|
22
|
-
* @param {string} input - Base64 encoded data
|
|
23
|
-
* @param {number} [bytes] - number of bytes per array entry
|
|
24
|
-
* @returns {Uint32Array} Decoded data
|
|
25
|
-
*/
|
|
26
|
-
export function decodeBase64AsArray(input: string, bytes?: number | undefined): Uint32Array;
|
|
27
|
-
/**
|
|
28
|
-
* Decode the given data
|
|
29
|
-
* @ignore
|
|
30
|
-
*/
|
|
31
|
-
export function decode(data: any, encoding: any, compression: any): any;
|
|
32
|
-
/**
|
|
33
|
-
* Normalize TMX format to Tiled JSON format
|
|
34
|
-
* @ignore
|
|
35
|
-
*/
|
|
36
|
-
export function normalize(obj: any, item: any): void;
|
|
14
|
+
export function decode(data: string, encoding?: string | undefined, compression: any): number[];
|
|
37
15
|
/**
|
|
38
16
|
* Parse a XML TMX object and returns the corresponding javascript object
|
|
39
|
-
* @
|
|
17
|
+
* @name parse
|
|
18
|
+
* @memberOf TMXUtils
|
|
19
|
+
* @param {Document} xml - XML TMX object
|
|
20
|
+
* @returns {object} Javascript object
|
|
40
21
|
*/
|
|
41
|
-
export function parse(xml:
|
|
42
|
-
text: string;
|
|
43
|
-
};
|
|
22
|
+
export function parse(xml: Document): object;
|
|
44
23
|
/**
|
|
45
24
|
* Apply TMX Properties to the given object
|
|
46
|
-
* @
|
|
25
|
+
* @name applyTMXProperties
|
|
26
|
+
* @memberOf TMXUtils
|
|
27
|
+
* @param {object} obj - object to apply the properties to
|
|
28
|
+
* @param {object} data - TMX data object
|
|
29
|
+
* @returns {object} obj
|
|
47
30
|
*/
|
|
48
|
-
export function applyTMXProperties(obj:
|
|
31
|
+
export function applyTMXProperties(obj: object, data: object): object;
|
|
@@ -1,10 +1,65 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @
|
|
4
|
-
* @
|
|
2
|
+
* patch a melonJS function
|
|
3
|
+
* @name patch
|
|
4
|
+
* @memberof plugin
|
|
5
|
+
* @param {object} proto - target object
|
|
6
|
+
* @param {string} name - target function
|
|
7
|
+
* @param {Function} fn - replacement function
|
|
8
|
+
* @example
|
|
9
|
+
* // redefine the me.game.update function with a new one
|
|
10
|
+
* me.plugin.patch(me.game, "update", function () {
|
|
11
|
+
* // display something in the console
|
|
12
|
+
* console.log("duh");
|
|
13
|
+
* // call the original me.game.update function
|
|
14
|
+
* this._patched();
|
|
15
|
+
* });
|
|
5
16
|
*/
|
|
6
|
-
export
|
|
17
|
+
export function patch(proto: object, name: string, fn: Function): void;
|
|
18
|
+
/**
|
|
19
|
+
* Register a plugin.
|
|
20
|
+
* @name register
|
|
21
|
+
* @memberof plugin
|
|
22
|
+
* @param {plugin.BasePlugin} plugin - Plugin object to instantiate and register
|
|
23
|
+
* @param {string} [name=plugin.constructor.name] - a unique name for this plugin
|
|
24
|
+
* @param {object} [...arguments] - all extra parameters will be passed to the plugin constructor
|
|
25
|
+
* @example
|
|
26
|
+
* // register a new plugin
|
|
27
|
+
* me.plugin.register(TestPlugin, "testPlugin");
|
|
28
|
+
* // the plugin then also become available
|
|
29
|
+
* // under then me.plugins namespace
|
|
30
|
+
* me.plugins.testPlugin.myfunction ();
|
|
31
|
+
*/
|
|
32
|
+
export function register(plugin: plugin.BasePlugin, name?: string | undefined, ...args: any[]): void;
|
|
33
|
+
/**
|
|
34
|
+
* Contains all registered plugins.
|
|
35
|
+
* @name cache
|
|
36
|
+
* @memberof plugin
|
|
37
|
+
*/
|
|
38
|
+
export let cache: {};
|
|
7
39
|
/**
|
|
8
40
|
* @namespace plugin
|
|
9
41
|
*/
|
|
10
|
-
|
|
42
|
+
/**
|
|
43
|
+
* a base Object class for plugin
|
|
44
|
+
* (plugin must be installed using the register function)
|
|
45
|
+
* @class
|
|
46
|
+
* @name BasePlugin
|
|
47
|
+
* @memberof plugin
|
|
48
|
+
*/
|
|
49
|
+
export class BasePlugin {
|
|
50
|
+
/**
|
|
51
|
+
* define the minimum required version of melonJS<br>
|
|
52
|
+
* this can be overridden by the plugin
|
|
53
|
+
* @type {string}
|
|
54
|
+
* @default "__VERSION__"
|
|
55
|
+
*/
|
|
56
|
+
version: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @class
|
|
60
|
+
* @name Base
|
|
61
|
+
* @memberof plugin
|
|
62
|
+
* @deprecated since 15.1.6, see {@link plugin.BasePlugin}
|
|
63
|
+
*/
|
|
64
|
+
export class Base extends BasePlugin {
|
|
65
|
+
}
|
|
@@ -1,17 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Compare two version strings
|
|
3
|
+
* @public
|
|
4
|
+
* @memberof utils
|
|
5
|
+
* @name checkVersion
|
|
6
|
+
* @param {string} first - First version string to compare
|
|
7
|
+
* @param {string} second - second version string to compare
|
|
8
|
+
* @returns {number} comparison result <br>< 0 : first < second<br>
|
|
9
|
+
* 0 : first == second<br>
|
|
10
|
+
* > 0 : first > second
|
|
11
|
+
* @example
|
|
12
|
+
* if (me.utils.checkVersion("7.0.0") > 0) {
|
|
13
|
+
* console.error(
|
|
14
|
+
* "melonJS is too old. Expected: 7.0.0, Got: 6.3.0"
|
|
15
|
+
* );
|
|
16
|
+
* }
|
|
17
|
+
*/
|
|
18
|
+
export function checkVersion(first: string, second: string): number;
|
|
19
|
+
/**
|
|
20
|
+
* parse the fragment (hash) from a URL and returns them into
|
|
21
|
+
* @public
|
|
22
|
+
* @memberof utils
|
|
23
|
+
* @name getUriFragment
|
|
24
|
+
* @param {string} [url=document.location] - an optional params string or URL containing fragment (hash) params to be parsed
|
|
25
|
+
* @returns {object} an object representing the deserialized params string.
|
|
26
|
+
* @property {boolean} [hitbox=false] draw the hitbox in the debug panel (if enabled)
|
|
27
|
+
* @property {boolean} [velocity=false] draw the entities velocity in the debug panel (if enabled)
|
|
28
|
+
* @property {boolean} [quadtree=false] draw the quadtree in the debug panel (if enabled)
|
|
29
|
+
* @property {boolean} [webgl=false] force the renderer to WebGL
|
|
30
|
+
* @property {boolean} [debug=false] display the debug panel (if preloaded)
|
|
31
|
+
* @property {string} [debugToggleKey="s"] show/hide the debug panel (if preloaded)
|
|
32
|
+
* @example
|
|
33
|
+
* // http://www.example.com/index.html#debug&hitbox=true&mytag=value
|
|
34
|
+
* let UriFragment = me.utils.getUriFragment();
|
|
35
|
+
* console.log(UriFragment["mytag"]); //> "value"
|
|
36
|
+
*/
|
|
37
|
+
export function getUriFragment(url?: string | undefined): object;
|
|
38
|
+
/**
|
|
39
|
+
* reset the GUID Base Name
|
|
40
|
+
* the idea here being to have a unique ID
|
|
41
|
+
* per level / object
|
|
42
|
+
* @ignore
|
|
43
|
+
*/
|
|
44
|
+
export function resetGUID(base: any, index?: number): void;
|
|
45
|
+
/**
|
|
46
|
+
* create and return a very simple GUID
|
|
47
|
+
* Game Unique ID
|
|
48
|
+
* @ignore
|
|
49
|
+
*/
|
|
50
|
+
export function createGUID(index?: number): string;
|
|
51
|
+
export * as agent from "./agent.js";
|
|
52
|
+
export * as array from "./array.js";
|
|
53
|
+
export * as file from "./file.js";
|
|
54
|
+
export * as string from "./string.js";
|
|
55
|
+
export * as _function from "./function.js";
|
|
56
|
+
export { _function as function };
|
|
@@ -64,30 +64,10 @@ export function createCanvas(width: number, height: number, returnOffscreenCanva
|
|
|
64
64
|
* @returns {HTMLElement}
|
|
65
65
|
*/
|
|
66
66
|
export function getParent(): HTMLElement;
|
|
67
|
-
/**
|
|
68
|
-
* @namespace video
|
|
69
|
-
*/
|
|
70
|
-
/**
|
|
71
|
-
* Select the HTML5 Canvas renderer
|
|
72
|
-
* @memberof video
|
|
73
|
-
* @static
|
|
74
|
-
*/
|
|
75
|
-
export const CANVAS: number;
|
|
76
|
-
/**
|
|
77
|
-
* Select the WebGL renderer
|
|
78
|
-
* @memberof video
|
|
79
|
-
* @static
|
|
80
|
-
*/
|
|
81
|
-
export const WEBGL: number;
|
|
82
|
-
/**
|
|
83
|
-
* Auto-select the renderer (Attempt WebGL first, with fallback to Canvas)
|
|
84
|
-
* @memberof video
|
|
85
|
-
* @static
|
|
86
|
-
*/
|
|
87
|
-
export const AUTO: number;
|
|
88
67
|
/**
|
|
89
68
|
* A reference to the active Canvas or WebGL active renderer renderer
|
|
90
69
|
* @memberof video
|
|
91
70
|
* @type {CanvasRenderer|WebGLRenderer}
|
|
92
71
|
*/
|
|
93
72
|
export let renderer: CanvasRenderer | WebGLRenderer;
|
|
73
|
+
export { CANVAS, WEBGL, AUTO } from "../const";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "melonjs",
|
|
3
|
-
"version": "15.1
|
|
3
|
+
"version": "15.2.1",
|
|
4
4
|
"description": "melonJS Game Engine",
|
|
5
5
|
"homepage": "http://www.melonjs.org/",
|
|
6
6
|
"type": "module",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"@babel/plugin-syntax-import-assertions": "^7.20.0",
|
|
64
64
|
"@fastify/static": "^6.10.1",
|
|
65
65
|
"@melonjs/webdoc-theme": "^1.1.1",
|
|
66
|
-
"@rollup/plugin-commonjs": "^
|
|
66
|
+
"@rollup/plugin-commonjs": "^25.0.0",
|
|
67
67
|
"@rollup/plugin-image": "^3.0.2",
|
|
68
68
|
"@rollup/plugin-node-resolve": "^15.0.2",
|
|
69
69
|
"@rollup/plugin-replace": "^5.0.2",
|
|
@@ -72,14 +72,14 @@
|
|
|
72
72
|
"cross-env": "^7.0.3",
|
|
73
73
|
"del-cli": "^5.0.0",
|
|
74
74
|
"eslint": "^8.40.0",
|
|
75
|
-
"eslint-plugin-jsdoc": "^44.
|
|
75
|
+
"eslint-plugin-jsdoc": "^44.2.3",
|
|
76
76
|
"expect": "^29.5.0",
|
|
77
77
|
"expect-mocha-image-snapshot": "^3.0.13",
|
|
78
78
|
"fastify": "^4.17.0",
|
|
79
79
|
"mocha": "^10.2.0",
|
|
80
80
|
"npm-self-link": "^1.1.7",
|
|
81
|
-
"puppeteer": "^20.
|
|
82
|
-
"rollup": "^3.21.
|
|
81
|
+
"puppeteer": "^20.2.0",
|
|
82
|
+
"rollup": "^3.21.7",
|
|
83
83
|
"rollup-plugin-bundle-size": "^1.0.3",
|
|
84
84
|
"rollup-plugin-string": "^3.0.0",
|
|
85
85
|
"terser": "^5.17.3",
|
|
@@ -2,7 +2,7 @@ import { autoDetectRenderer } from "../video/utils/autodetect.js";
|
|
|
2
2
|
import CanvasRenderer from "./../video/canvas/canvas_renderer.js";
|
|
3
3
|
import * as device from "./../system/device.js";
|
|
4
4
|
import * as event from "./../system/event.js";
|
|
5
|
-
import
|
|
5
|
+
import { getUriFragment } from "./../utils/utils.js";
|
|
6
6
|
import timer from "./../system/timer.js";
|
|
7
7
|
import state from "./../state/state.js";
|
|
8
8
|
import World from "./../physics/world.js";
|
|
@@ -149,7 +149,7 @@ import { CANVAS, WEBGL, AUTO } from "../const.js";
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
// override renderer settings if &webgl or &canvas is defined in the URL
|
|
152
|
-
let uriFragment =
|
|
152
|
+
let uriFragment = getUriFragment();
|
|
153
153
|
if (uriFragment.webgl === true || uriFragment.webgl1 === true || uriFragment.webgl2 === true) {
|
|
154
154
|
this.settings.renderer = WEBGL;
|
|
155
155
|
if (uriFragment.webgl1 === true) {
|
package/src/index.js
CHANGED
|
@@ -54,6 +54,7 @@ import TMXTileset from "./level/tiled/TMXTileset.js";
|
|
|
54
54
|
import TMXTilesetGroup from "./level/tiled/TMXTilesetGroup.js";
|
|
55
55
|
import TMXTileMap from "./level/tiled/TMXTileMap.js";
|
|
56
56
|
import TMXLayer from "./level/tiled/TMXLayer.js";
|
|
57
|
+
import * as TMXUtils from "./level/tiled/TMXUtils.js";
|
|
57
58
|
import Pointer from "./input/pointer.js";
|
|
58
59
|
import Stage from "./state/stage.js";
|
|
59
60
|
import Camera2d from "./camera/camera2d.js";
|
|
@@ -72,9 +73,10 @@ import * as event from "./system/event.js";
|
|
|
72
73
|
import * as device from "./system/device.js";
|
|
73
74
|
import * as loader from "./loader/loader.js";
|
|
74
75
|
import * as Math from "./math/math.js";
|
|
75
|
-
import utils from "./utils/utils.js";
|
|
76
|
+
import * as utils from "./utils/utils.js";
|
|
76
77
|
import * as input from "./input/input.js";
|
|
77
|
-
import
|
|
78
|
+
import * as plugin from "./plugin/plugin.js";
|
|
79
|
+
import { cache as plugins } from "./plugin/plugin.js";
|
|
78
80
|
import * as video from "./video/video.js";
|
|
79
81
|
import save from "./system/save.js";
|
|
80
82
|
import timer from "./system/timer.js";
|
|
@@ -166,6 +168,7 @@ export {
|
|
|
166
168
|
TMXTilesetGroup,
|
|
167
169
|
TMXTileMap,
|
|
168
170
|
TMXLayer,
|
|
171
|
+
TMXUtils,
|
|
169
172
|
Pointer,
|
|
170
173
|
Stage,
|
|
171
174
|
Camera2d,
|
package/src/level/level.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { resetGUID } from "./../utils/utils.js";
|
|
2
|
+
import { defer } from "../utils/function.js";
|
|
2
3
|
import * as event from "./../system/event.js";
|
|
3
4
|
import state from "./../state/state.js";
|
|
4
5
|
import { getTMX } from "./../loader/loader.js";
|
|
@@ -62,7 +63,7 @@ function loadTMXLevel(levelId, container, flatten, setViewportBounds) {
|
|
|
62
63
|
|
|
63
64
|
// reset the GUID generator
|
|
64
65
|
// and pass the level id as parameter
|
|
65
|
-
|
|
66
|
+
resetGUID(levelId, level.nextobjectid);
|
|
66
67
|
|
|
67
68
|
// Tiled use 0,0 anchor coordinates
|
|
68
69
|
container.anchorPoint.set(0, 0);
|
|
@@ -178,7 +179,7 @@ let level = {
|
|
|
178
179
|
// some silly side effects
|
|
179
180
|
state.stop();
|
|
180
181
|
|
|
181
|
-
|
|
182
|
+
defer(safeLoadLevel, this, levelId, options, true);
|
|
182
183
|
}
|
|
183
184
|
else {
|
|
184
185
|
safeLoadLevel(levelId, options);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import pool from "./../../system/pooling.js";
|
|
2
2
|
import * as event from "./../../system/event.js";
|
|
3
3
|
import { game } from "../../index.js";
|
|
4
|
-
import
|
|
4
|
+
import { checkVersion } from "./../../utils/utils.js";
|
|
5
5
|
import collision from "./../../physics/collision.js";
|
|
6
6
|
import Body from "./../../physics/body.js";
|
|
7
7
|
import TMXTileset from "./TMXTileset.js";
|
|
@@ -198,7 +198,7 @@ function readObjectGroup(map, data, z) {
|
|
|
198
198
|
// if version is undefined or empty it usually means the map was not created with Tiled
|
|
199
199
|
if (this.version !== "undefined" && this.version !== "") {
|
|
200
200
|
// deprecation warning if map tiled version is older than 1.5
|
|
201
|
-
if (
|
|
201
|
+
if (checkVersion(this.version, "1.5") < 0) {
|
|
202
202
|
warning("("+this.name+") Tiled Map format version 1.4 and below", "format 1.5 or higher", "10.4.4");
|
|
203
203
|
}
|
|
204
204
|
}
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { isBoolean, isNumeric } from "../../utils/string.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* a collection of utility functions for parsing TMX maps
|
|
5
|
+
* @namespace TMXUtils
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* the function used to decompress zlib/gzip data
|
|
11
|
+
* @ignore
|
|
12
|
+
*/
|
|
13
|
+
let inflateFunction;
|
|
2
14
|
|
|
3
15
|
/**
|
|
4
16
|
* set and interpret a TMX property value
|
|
@@ -25,11 +37,11 @@ function setTMXValue(name, type, value) {
|
|
|
25
37
|
|
|
26
38
|
default :
|
|
27
39
|
// try to parse it anyway
|
|
28
|
-
if (!value ||
|
|
40
|
+
if (!value || isBoolean(value)) {
|
|
29
41
|
// if value not defined or boolean
|
|
30
42
|
value = value ? (value === "true") : true;
|
|
31
43
|
}
|
|
32
|
-
else if (
|
|
44
|
+
else if (isNumeric(value)) {
|
|
33
45
|
// check if numeric
|
|
34
46
|
value = Number(value);
|
|
35
47
|
}
|
|
@@ -95,99 +107,11 @@ function parseAttributes(obj, elt) {
|
|
|
95
107
|
}
|
|
96
108
|
}
|
|
97
109
|
|
|
98
|
-
/**
|
|
99
|
-
* decompress and decode zlib/gzip data
|
|
100
|
-
* @ignore
|
|
101
|
-
* @name decompress
|
|
102
|
-
* @param {string} input - Base64 encoded and compressed data
|
|
103
|
-
* @param {string} format - compressed data format ("gzip","zlib", "zstd")
|
|
104
|
-
* @returns {Uint32Array} Decoded and decompress data
|
|
105
|
-
*/
|
|
106
|
-
export function decompress(data, format) {
|
|
107
|
-
if (typeof utils.inflateb64 === "function") {
|
|
108
|
-
return utils.inflateb64(data, format);
|
|
109
|
-
} else {
|
|
110
|
-
throw new Error("GZIP/ZLIB compressed TMX Tile Map not supported!");
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Decode a CSV encoded array into a binary array
|
|
116
|
-
* @ignore
|
|
117
|
-
* @name decodeCSV
|
|
118
|
-
* @param {string} input- - CSV formatted data (only numbers, everything else will be converted to NaN)
|
|
119
|
-
* @returns {number[]} Decoded data
|
|
120
|
-
*/
|
|
121
|
-
export function decodeCSV(input) {
|
|
122
|
-
let entries = input.replace("\n", "").trim().split(",");
|
|
123
|
-
|
|
124
|
-
let result = [];
|
|
125
|
-
for (let i = 0; i < entries.length; i++) {
|
|
126
|
-
result.push(+entries[i]);
|
|
127
|
-
}
|
|
128
|
-
return result;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Decode a base64 encoded string into a byte array
|
|
133
|
-
* @ignore
|
|
134
|
-
* @name decodeBase64AsArray
|
|
135
|
-
* @param {string} input - Base64 encoded data
|
|
136
|
-
* @param {number} [bytes] - number of bytes per array entry
|
|
137
|
-
* @returns {Uint32Array} Decoded data
|
|
138
|
-
*/
|
|
139
|
-
export function decodeBase64AsArray(input, bytes) {
|
|
140
|
-
bytes = bytes || 1;
|
|
141
|
-
|
|
142
|
-
let i, j, len;
|
|
143
|
-
let dec = globalThis.atob(input.replace(/[^A-Za-z0-9\+\/\=]/g, ""));
|
|
144
|
-
let ar = new Uint32Array(dec.length / bytes);
|
|
145
|
-
|
|
146
|
-
for (i = 0, len = dec.length / bytes; i < len; i++) {
|
|
147
|
-
ar[i] = 0;
|
|
148
|
-
for (j = bytes - 1; j >= 0; --j) {
|
|
149
|
-
ar[i] += dec.charCodeAt((i * bytes) + j) << (j << 3);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
return ar;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Decode the given data
|
|
157
|
-
* @ignore
|
|
158
|
-
*/
|
|
159
|
-
export function decode(data, encoding, compression) {
|
|
160
|
-
compression = compression || "none";
|
|
161
|
-
encoding = encoding || "none";
|
|
162
|
-
|
|
163
|
-
switch (encoding) {
|
|
164
|
-
case "csv":
|
|
165
|
-
return decodeCSV(data);
|
|
166
|
-
|
|
167
|
-
case "base64":
|
|
168
|
-
if (compression !== "none") {
|
|
169
|
-
data = decompress(data, compression);
|
|
170
|
-
} else {
|
|
171
|
-
data = decodeBase64AsArray(data, 4);
|
|
172
|
-
}
|
|
173
|
-
return data;
|
|
174
|
-
|
|
175
|
-
case "none":
|
|
176
|
-
return data;
|
|
177
|
-
|
|
178
|
-
case "xml":
|
|
179
|
-
throw new Error("XML encoding is deprecated, use base64 instead");
|
|
180
|
-
|
|
181
|
-
default:
|
|
182
|
-
throw new Error("Unknown layer encoding: " + encoding);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
110
|
/**
|
|
187
111
|
* Normalize TMX format to Tiled JSON format
|
|
188
112
|
* @ignore
|
|
189
113
|
*/
|
|
190
|
-
|
|
114
|
+
function normalize(obj, item) {
|
|
191
115
|
let nodeName = item.nodeName;
|
|
192
116
|
|
|
193
117
|
switch (nodeName) {
|
|
@@ -315,9 +239,113 @@ export function normalize(obj, item) {
|
|
|
315
239
|
}
|
|
316
240
|
}
|
|
317
241
|
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* decompress and decode zlib/gzip data
|
|
245
|
+
* @name decompress
|
|
246
|
+
* @memberOf TMXUtils
|
|
247
|
+
* @param {string} input - Base64 encoded and compressed data
|
|
248
|
+
* @param {string} format - compressed data format ("gzip","zlib", "zstd")
|
|
249
|
+
* @returns {Uint32Array} Decoded and decompress data
|
|
250
|
+
*/
|
|
251
|
+
function decompress(data, format) {
|
|
252
|
+
if (typeof inflateFunction === "function") {
|
|
253
|
+
return inflateFunction(data, format);
|
|
254
|
+
} else {
|
|
255
|
+
throw new Error("GZIP/ZLIB compressed TMX Tile Map not supported!");
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Decode a CSV encoded array into a binary array
|
|
261
|
+
* @name decodeCSV
|
|
262
|
+
* @memberOf TMXUtils
|
|
263
|
+
* @param {string} input- - CSV formatted data (only numbers, everything else will be converted to NaN)
|
|
264
|
+
* @returns {number[]} Decoded data
|
|
265
|
+
*/
|
|
266
|
+
function decodeCSV(input) {
|
|
267
|
+
let entries = input.replace("\n", "").trim().split(",");
|
|
268
|
+
|
|
269
|
+
let result = [];
|
|
270
|
+
for (let i = 0; i < entries.length; i++) {
|
|
271
|
+
result.push(+entries[i]);
|
|
272
|
+
}
|
|
273
|
+
return result;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Decode a base64 encoded string into a byte array
|
|
278
|
+
* @name decodeBase64AsArray
|
|
279
|
+
* @memberOf TMXUtils
|
|
280
|
+
* @param {string} input - Base64 encoded data
|
|
281
|
+
* @param {number} [bytes] - number of bytes per array entry
|
|
282
|
+
* @returns {Uint32Array} Decoded data
|
|
283
|
+
*/
|
|
284
|
+
function decodeBase64AsArray(input, bytes) {
|
|
285
|
+
bytes = bytes || 1;
|
|
286
|
+
|
|
287
|
+
let i, j, len;
|
|
288
|
+
let dec = globalThis.atob(input.replace(/[^A-Za-z0-9\+\/\=]/g, ""));
|
|
289
|
+
let ar = new Uint32Array(dec.length / bytes);
|
|
290
|
+
|
|
291
|
+
for (i = 0, len = dec.length / bytes; i < len; i++) {
|
|
292
|
+
ar[i] = 0;
|
|
293
|
+
for (j = bytes - 1; j >= 0; --j) {
|
|
294
|
+
ar[i] += dec.charCodeAt((i * bytes) + j) << (j << 3);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return ar;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* set the function used to inflate gzip/zlib data
|
|
302
|
+
* @param {Func} fn - inflate function
|
|
303
|
+
*/
|
|
304
|
+
export function setInflateFunction(fn) {
|
|
305
|
+
inflateFunction = fn;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Decode a encoded array into a binary array
|
|
310
|
+
* @name decodeCSV
|
|
311
|
+
* @memberOf TMXUtils
|
|
312
|
+
* @param {string} data - data to be decoded
|
|
313
|
+
* @param {string} [encoding="none"] - data encoding ("csv", "base64", "xml")
|
|
314
|
+
* @returns {number[]} Decoded data
|
|
315
|
+
*/
|
|
316
|
+
export function decode(data, encoding, compression) {
|
|
317
|
+
compression = compression || "none";
|
|
318
|
+
encoding = encoding || "none";
|
|
319
|
+
|
|
320
|
+
switch (encoding) {
|
|
321
|
+
case "csv":
|
|
322
|
+
return decodeCSV(data);
|
|
323
|
+
|
|
324
|
+
case "base64":
|
|
325
|
+
if (compression !== "none") {
|
|
326
|
+
data = decompress(data, compression);
|
|
327
|
+
} else {
|
|
328
|
+
data = decodeBase64AsArray(data, 4);
|
|
329
|
+
}
|
|
330
|
+
return data;
|
|
331
|
+
|
|
332
|
+
case "none":
|
|
333
|
+
return data;
|
|
334
|
+
|
|
335
|
+
case "xml":
|
|
336
|
+
throw new Error("XML encoding is deprecated, use base64 instead");
|
|
337
|
+
|
|
338
|
+
default:
|
|
339
|
+
throw new Error("Unknown layer encoding: " + encoding);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
318
343
|
/**
|
|
319
344
|
* Parse a XML TMX object and returns the corresponding javascript object
|
|
320
|
-
* @
|
|
345
|
+
* @name parse
|
|
346
|
+
* @memberOf TMXUtils
|
|
347
|
+
* @param {Document} xml - XML TMX object
|
|
348
|
+
* @returns {object} Javascript object
|
|
321
349
|
*/
|
|
322
350
|
export function parse(xml) {
|
|
323
351
|
// Create the return object
|
|
@@ -355,7 +383,11 @@ export function parse(xml) {
|
|
|
355
383
|
|
|
356
384
|
/**
|
|
357
385
|
* Apply TMX Properties to the given object
|
|
358
|
-
* @
|
|
386
|
+
* @name applyTMXProperties
|
|
387
|
+
* @memberOf TMXUtils
|
|
388
|
+
* @param {object} obj - object to apply the properties to
|
|
389
|
+
* @param {object} data - TMX data object
|
|
390
|
+
* @returns {object} obj
|
|
359
391
|
*/
|
|
360
392
|
export function applyTMXProperties(obj, data) {
|
|
361
393
|
let properties = data.properties;
|