melonjs 15.2.1 → 15.3.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/README.md +1 -1
- 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 +24 -20
- package/dist/melonjs.mjs/application/header.js +1 -1
- package/dist/melonjs.mjs/application/resize.js +10 -4
- package/dist/melonjs.mjs/application/settings.js +37 -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 +2 -2
- 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 +1 -1
- 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 +1 -1
- 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 +12 -19
- 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 +4 -4
- 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 +3 -3
- 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 +1 -1
- 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 +6 -14
- 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 +12 -13
- package/dist/melonjs.mjs/state/state.js +4 -14
- package/dist/melonjs.mjs/system/device.js +3 -1
- package/dist/melonjs.mjs/system/dom.js +1 -1
- package/dist/melonjs.mjs/system/event.js +24 -2
- package/dist/melonjs.mjs/system/platform.js +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 +1 -1
- 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 +1 -1
- package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +2 -11
- package/dist/melonjs.mjs/video/renderer.js +2 -15
- 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 +2 -26
- 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 +13 -16
- package/dist/melonjs.module.js +142 -144
- package/dist/types/application/application.d.ts +4 -27
- package/dist/types/application/settings.d.ts +64 -0
- package/dist/types/level/tiled/TMXUtils.d.ts +4 -6
- package/dist/types/renderable/renderable.d.ts +1 -2
- package/dist/types/state/stage.d.ts +3 -2
- package/dist/types/system/device.d.ts +1 -0
- package/dist/types/system/event.d.ts +20 -0
- package/dist/types/video/canvas/canvas_renderer.d.ts +0 -23
- package/dist/types/video/renderer.d.ts +3 -30
- package/dist/types/video/video.d.ts +2 -36
- package/dist/types/video/webgl/webgl_renderer.d.ts +1 -34
- package/package.json +6 -6
- package/src/application/application.js +22 -18
- package/src/application/resize.js +8 -2
- package/src/application/settings.js +36 -0
- package/src/level/tiled/TMXUtils.js +11 -18
- package/src/math/color.js +3 -3
- package/src/renderable/renderable.js +5 -13
- package/src/state/stage.js +11 -12
- package/src/state/state.js +2 -12
- package/src/system/device.js +2 -0
- package/src/system/event.js +22 -0
- package/src/video/canvas/canvas_renderer.js +1 -10
- package/src/video/renderer.js +1 -14
- package/src/video/video.js +4 -25
- package/src/video/webgl/webgl_renderer.js +12 -15
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ Compatibility
|
|
|
31
31
|
|
|
32
32
|
Graphics
|
|
33
33
|
- 2D sprite-based graphic engine
|
|
34
|
-
- Fast WebGL
|
|
34
|
+
- [Blazing Fast](https://melonjs.discourse.group/t/melonjs-benchmark/48/4) WebGL renderer for desktop and mobile devices with fallback to Canvas rendering
|
|
35
35
|
- High DPI resolution & Canvas advanced auto scaling
|
|
36
36
|
- Sprite with 9-slice scaling option, and animation management
|
|
37
37
|
- built-in effects such as tinting and masking
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.3.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { autoDetectRenderer } from '../video/utils/autodetect.js';
|
|
9
9
|
import CanvasRenderer from '../video/canvas/canvas_renderer.js';
|
|
10
10
|
import { getElement, platform, enableSwipe } from '../system/device.js';
|
|
11
|
-
import { on, emit, GAME_AFTER_UPDATE, GAME_BEFORE_DRAW, GAME_AFTER_DRAW, WINDOW_ONRESIZE, WINDOW_ONORIENTATION_CHANGE, GAME_INIT, GAME_RESET, GAME_BEFORE_UPDATE, GAME_UPDATE } from '../system/event.js';
|
|
11
|
+
import { on, emit, STATE_CHANGE, STATE_RESTART, STATE_RESUME, STAGE_RESET, GAME_AFTER_UPDATE, GAME_BEFORE_DRAW, GAME_AFTER_DRAW, WINDOW_ONRESIZE, WINDOW_ONORIENTATION_CHANGE, GAME_INIT, TICK, GAME_RESET, GAME_BEFORE_UPDATE, GAME_UPDATE } from '../system/event.js';
|
|
12
12
|
import { getUriFragment } from '../utils/utils.js';
|
|
13
13
|
import timer from '../system/timer.js';
|
|
14
14
|
import state from '../state/state.js';
|
|
@@ -28,17 +28,7 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
28
28
|
/**
|
|
29
29
|
* @param {number} width - The width of the canvas viewport
|
|
30
30
|
* @param {number} height - The height of the canvas viewport
|
|
31
|
-
* @param {
|
|
32
|
-
* @param {string|HTMLElement} [options.parent=document.body] - the DOM parent element to hold the canvas in the HTML file
|
|
33
|
-
* @param {number|Renderer} [options.renderer=AUTO] - renderer to use (CANVAS, WEBGL, AUTO), or a custom renderer class
|
|
34
|
-
* @param {number|string} [options.scale=1.0] - enable scaling of the canvas ('auto' for automatic scaling)
|
|
35
|
-
* @param {string} [options.scaleMethod="fit"] - screen scaling modes ('fit','fill-min','fill-max','flex','flex-width','flex-height','stretch')
|
|
36
|
-
* @param {boolean} [options.preferWebGL1=false] - if true the renderer will only use WebGL 1
|
|
37
|
-
* @param {boolean} [options.depthTest="sorting"] - ~Experimental~ the default method to sort object on the z axis in WebGL ("sorting", "z-buffer")
|
|
38
|
-
* @param {string} [options.powerPreference="default"] - a hint to the user agent indicating what configuration of GPU is suitable for the WebGL context ("default", "high-performance", "low-power"). To be noted that Safari and Chrome (since version 80) both default to "low-power" to save battery life and improve the user experience on these dual-GPU machines.
|
|
39
|
-
* @param {boolean} [options.transparent=false] - whether to allow transparent pixels in the front buffer (screen).
|
|
40
|
-
* @param {boolean} [options.antiAlias=false] - whether to enable or not video scaling interpolation
|
|
41
|
-
* @param {boolean} [options.consoleHeader=true] - whether to display melonJS version and basic device information in the console
|
|
31
|
+
* @param {Application.Settings} [options] - The optional parameters for the application and default renderer
|
|
42
32
|
* @throws Will throw an exception if it fails to instantiate a renderer
|
|
43
33
|
* @example
|
|
44
34
|
* let my game = new Application(640, 480, {renderer: me.video.AUTO}) {
|
|
@@ -173,6 +163,12 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
173
163
|
this.settings.zoomX = width * this.settings.scale;
|
|
174
164
|
this.settings.zoomY = height * this.settings.scale;
|
|
175
165
|
|
|
166
|
+
// identify parent element and/or the html target for resizing
|
|
167
|
+
this.parentElement = getElement(this.settings.parent);
|
|
168
|
+
if (typeof this.settings.scaleTarget !== "undefined" ) {
|
|
169
|
+
this.settings.scaleTarget = getElement(this.settings.scaleTarget);
|
|
170
|
+
}
|
|
171
|
+
|
|
176
172
|
if (typeof this.settings.renderer === "number") {
|
|
177
173
|
switch (this.settings.renderer) {
|
|
178
174
|
case AUTO:
|
|
@@ -194,7 +190,6 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
194
190
|
on(WINDOW_ONORIENTATION_CHANGE, () => onresize(this), this);
|
|
195
191
|
|
|
196
192
|
// add our canvas (default to document.body if settings.parent is undefined)
|
|
197
|
-
this.parentElement = getElement(this.settings.parent);
|
|
198
193
|
this.parentElement.appendChild(this.renderer.getCanvas());
|
|
199
194
|
|
|
200
195
|
// Mobile browser hacks
|
|
@@ -233,6 +228,16 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
233
228
|
this.isInitialized = true;
|
|
234
229
|
|
|
235
230
|
emit(GAME_INIT, this);
|
|
231
|
+
on(STATE_CHANGE, this.repaint, this);
|
|
232
|
+
on(STATE_RESTART, this.repaint, this);
|
|
233
|
+
on(STATE_RESUME, this.repaint, this);
|
|
234
|
+
on(STAGE_RESET, this.reset, this);
|
|
235
|
+
on(TICK, (time) => {
|
|
236
|
+
// update all game objects
|
|
237
|
+
this.update(time);
|
|
238
|
+
// render all game objects
|
|
239
|
+
this.draw();
|
|
240
|
+
}, this);
|
|
236
241
|
}
|
|
237
242
|
|
|
238
243
|
/**
|
|
@@ -313,9 +318,8 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
313
318
|
/**
|
|
314
319
|
* update all objects related to this game active scene/stage
|
|
315
320
|
* @param {number} time - current timestamp as provided by the RAF callback
|
|
316
|
-
* @param {Stage} stage - the current stage
|
|
317
321
|
*/
|
|
318
|
-
update(time
|
|
322
|
+
update(time) {
|
|
319
323
|
// handle frame skipping if required
|
|
320
324
|
if ((++this.frameCounter % this.frameRate) === 0) {
|
|
321
325
|
// reset the frame counter
|
|
@@ -339,7 +343,8 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
339
343
|
}
|
|
340
344
|
|
|
341
345
|
// update all objects (and pass the elapsed time since last frame)
|
|
342
|
-
this.isDirty =
|
|
346
|
+
this.isDirty = this.world.update(this.updateDelta);
|
|
347
|
+
this.isDirty = state.current().update(this.updateDelta) || this.isDirty;
|
|
343
348
|
|
|
344
349
|
this.lastUpdate = globalThis.performance.now();
|
|
345
350
|
this.updateAverageDelta = this.lastUpdate - this.lastUpdateStart;
|
|
@@ -358,9 +363,8 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
358
363
|
|
|
359
364
|
/**
|
|
360
365
|
* draw the active scene/stage associated to this game
|
|
361
|
-
* @param {Stage} stage - the current stage
|
|
362
366
|
*/
|
|
363
|
-
draw(
|
|
367
|
+
draw() {
|
|
364
368
|
if (this.renderer.isContextValid === true && (this.isDirty || this.isAlwaysDirty)) {
|
|
365
369
|
// publish notification
|
|
366
370
|
emit(GAME_BEFORE_DRAW, globalThis.performance.now());
|
|
@@ -369,7 +373,7 @@ import { WEBGL, CANVAS, AUTO } from '../const.js';
|
|
|
369
373
|
this.renderer.clear();
|
|
370
374
|
|
|
371
375
|
// render the stage
|
|
372
|
-
|
|
376
|
+
state.current().draw(this.renderer, this.world);
|
|
373
377
|
|
|
374
378
|
// set back to flag
|
|
375
379
|
this.isDirty = false;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.3.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
6
6
|
* @copyright (C) 2011 - 2023 Olivier Biot (AltByte Pte Ltd)
|
|
7
7
|
*/
|
|
8
|
-
import { getParentBounds, devicePixelRatio } from '../system/device.js';
|
|
8
|
+
import { getElementBounds, getParentBounds, devicePixelRatio } from '../system/device.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* scale the "displayed" canvas by the given scalar.
|
|
@@ -50,6 +50,7 @@ function onresize(game) {
|
|
|
50
50
|
let renderer = game.renderer;
|
|
51
51
|
let settings = renderer.settings;
|
|
52
52
|
let scaleX = 1, scaleY = 1;
|
|
53
|
+
let nodeBounds;
|
|
53
54
|
|
|
54
55
|
if (settings.autoScale) {
|
|
55
56
|
|
|
@@ -63,8 +64,13 @@ function onresize(game) {
|
|
|
63
64
|
canvasMaxHeight = parseInt(style.maxHeight, 10) || Infinity;
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
if (typeof game.settings.scaleTarget !== "undefined") {
|
|
68
|
+
// get the bounds of the given scale target
|
|
69
|
+
nodeBounds = getElementBounds(game.settings.scaleTarget);
|
|
70
|
+
} else {
|
|
71
|
+
// get the maximum canvas size within the parent div containing the canvas container
|
|
72
|
+
nodeBounds = getParentBounds(game.getParentElement());
|
|
73
|
+
}
|
|
68
74
|
|
|
69
75
|
let _max_width = Math.min(canvasMaxWidth, nodeBounds.width);
|
|
70
76
|
let _max_height = Math.min(canvasMaxHeight, nodeBounds.height);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.3.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -12,6 +12,7 @@ const defaultSettings = {
|
|
|
12
12
|
autoScale : false,
|
|
13
13
|
scale : 1.0,
|
|
14
14
|
scaleMethod : "manual",
|
|
15
|
+
scaleTarget : undefined,
|
|
15
16
|
transparent : false,
|
|
16
17
|
premultipliedAlpha: true,
|
|
17
18
|
blendMode : "normal",
|
|
@@ -25,4 +26,39 @@ const defaultSettings = {
|
|
|
25
26
|
legacy : false
|
|
26
27
|
};
|
|
27
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Application & Renderer Settings definition.
|
|
31
|
+
* @typedef {Object} Settings
|
|
32
|
+
* @property {string|HTMLElement} [parent=document.body] - the DOM parent element to hold the canvas in the HTML file
|
|
33
|
+
* @property {number|Renderer} [renderer=AUTO] - renderer to use (CANVAS, WEBGL, AUTO), or a custom renderer class
|
|
34
|
+
* @property {number|string} [scale=1.0] - enable scaling of the canvas ('auto' for automatic scaling)
|
|
35
|
+
* @property {string} [scaleMethod="fit"] - screen scaling modes ('fit','fill-min','fill-max','flex','flex-width','flex-height','stretch') : <br>
|
|
36
|
+
* - <i><b>`fit`</b></i> : Letterboxed; content is scaled to design aspect ratio <br>
|
|
37
|
+
* <center><img src="images/scale-fit.png"/></center><br>
|
|
38
|
+
* - <i><b>`fill-min`</b></i> : Canvas is resized to fit minimum design resolution; content is scaled to design aspect ratio <br>
|
|
39
|
+
* <center><img src="images/scale-fill-min.png"/></center><br>
|
|
40
|
+
* - <i><b>`fill-max`</b></i> : Canvas is resized to fit maximum design resolution; content is scaled to design aspect ratio <br>
|
|
41
|
+
* <center><img src="images/scale-fill-max.png"/></center><br>
|
|
42
|
+
* - <i><b>`flex`</b><</i> : Canvas width & height is resized to fit; content is scaled to design aspect ratio <br>
|
|
43
|
+
* <center><img src="images/scale-flex.png"/></center><br>
|
|
44
|
+
* - <i><b>`flex-width`</b></i> : Canvas width is resized to fit; content is scaled to design aspect ratio <br>
|
|
45
|
+
* <center><img src="images/scale-flex-width.png"/></center><br>
|
|
46
|
+
* - <i><b>`flex-height`</b></i> : Canvas height is resized to fit; content is scaled to design aspect ratio <br>
|
|
47
|
+
* <center><img src="images/scale-flex-height.png"/></center><br>
|
|
48
|
+
* - <i><b>`stretch`</b></i> : Canvas is resized to fit; content is scaled to screen aspect ratio <br>
|
|
49
|
+
* <center><img src="images/scale-stretch.png"/></center>
|
|
50
|
+
* @property {string|HTMLElement} [scaleTarget] - the HTML Element to be used as the reference target when using automatic scaling (by default melonJS will use the parent container of the div element containing the canvas)
|
|
51
|
+
* @property {boolean} [preferWebGL1=false] - if true the renderer will only use WebGL 1
|
|
52
|
+
* @property {boolean} [depthTest="sorting"] - ~Experimental~ the default method to sort object on the z axis in WebGL ("sorting", "z-buffer")
|
|
53
|
+
* @property {string} [powerPreference="default"] - a hint to the user agent indicating what configuration of GPU is suitable for the WebGL context ("default", "high-performance", "low-power"). To be noted that Safari and Chrome (since version 80) both default to "low-power" to save battery life and improve the user experience on these dual-GPU machines.
|
|
54
|
+
* @property {boolean} [transparent=false] - whether to allow transparent pixels in the front buffer (screen).
|
|
55
|
+
* @property {boolean} [antiAlias=false] - whether to enable or not video scaling interpolation
|
|
56
|
+
* @property {boolean} [consoleHeader=true] - whether to display melonJS version and basic device information in the console
|
|
57
|
+
* @param {number} [options.zoomX=width] - The actual width of the canvas with scaling applied
|
|
58
|
+
* @param {number} [options.zoomY=height] - The actual height of the canvas with scaling applied
|
|
59
|
+
* @param {Compositor} [options.compositor] - a custom compositor class (WebGL only)
|
|
60
|
+
* @see Application
|
|
61
|
+
* @memberof Application
|
|
62
|
+
*/
|
|
63
|
+
|
|
28
64
|
export { defaultSettings };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.3.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -112,7 +112,7 @@ import { initKeyboardEvent } from './input/keyboard.js';
|
|
|
112
112
|
* @name version
|
|
113
113
|
* @type {string}
|
|
114
114
|
*/
|
|
115
|
-
const version = "15.
|
|
115
|
+
const version = "15.3.0";
|
|
116
116
|
|
|
117
117
|
/**
|
|
118
118
|
* a flag indicating that melonJS is fully initialized
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v15.
|
|
2
|
+
* melonJS Game Engine - v15.3.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -7,12 +7,6 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { isBoolean, isNumeric } from '../../utils/string.js';
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
* a collection of utility functions for parsing TMX maps
|
|
12
|
-
* @namespace TMXUtils
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
10
|
/**
|
|
17
11
|
* the function used to decompress zlib/gzip data
|
|
18
12
|
* @ignore
|
|
@@ -246,11 +240,14 @@ function normalize(obj, item) {
|
|
|
246
240
|
}
|
|
247
241
|
}
|
|
248
242
|
|
|
243
|
+
/**
|
|
244
|
+
* a collection of utility functions for parsing TMX maps
|
|
245
|
+
* @namespace TMXUtils
|
|
246
|
+
*/
|
|
249
247
|
|
|
250
248
|
/**
|
|
251
249
|
* decompress and decode zlib/gzip data
|
|
252
|
-
* @
|
|
253
|
-
* @memberOf TMXUtils
|
|
250
|
+
* @memberof TMXUtils
|
|
254
251
|
* @param {string} input - Base64 encoded and compressed data
|
|
255
252
|
* @param {string} format - compressed data format ("gzip","zlib", "zstd")
|
|
256
253
|
* @returns {Uint32Array} Decoded and decompress data
|
|
@@ -265,8 +262,7 @@ function decompress(data, format) {
|
|
|
265
262
|
|
|
266
263
|
/**
|
|
267
264
|
* Decode a CSV encoded array into a binary array
|
|
268
|
-
* @
|
|
269
|
-
* @memberOf TMXUtils
|
|
265
|
+
* @memberof TMXUtils
|
|
270
266
|
* @param {string} input- - CSV formatted data (only numbers, everything else will be converted to NaN)
|
|
271
267
|
* @returns {number[]} Decoded data
|
|
272
268
|
*/
|
|
@@ -282,8 +278,7 @@ function decodeCSV(input) {
|
|
|
282
278
|
|
|
283
279
|
/**
|
|
284
280
|
* Decode a base64 encoded string into a byte array
|
|
285
|
-
* @
|
|
286
|
-
* @memberOf TMXUtils
|
|
281
|
+
* @memberof TMXUtils
|
|
287
282
|
* @param {string} input - Base64 encoded data
|
|
288
283
|
* @param {number} [bytes] - number of bytes per array entry
|
|
289
284
|
* @returns {Uint32Array} Decoded data
|
|
@@ -306,6 +301,7 @@ function decodeBase64AsArray(input, bytes) {
|
|
|
306
301
|
|
|
307
302
|
/**
|
|
308
303
|
* set the function used to inflate gzip/zlib data
|
|
304
|
+
* @memberof TMXUtils
|
|
309
305
|
* @param {Func} fn - inflate function
|
|
310
306
|
*/
|
|
311
307
|
function setInflateFunction(fn) {
|
|
@@ -314,8 +310,7 @@ function setInflateFunction(fn) {
|
|
|
314
310
|
|
|
315
311
|
/**
|
|
316
312
|
* Decode a encoded array into a binary array
|
|
317
|
-
* @
|
|
318
|
-
* @memberOf TMXUtils
|
|
313
|
+
* @memberof TMXUtils
|
|
319
314
|
* @param {string} data - data to be decoded
|
|
320
315
|
* @param {string} [encoding="none"] - data encoding ("csv", "base64", "xml")
|
|
321
316
|
* @returns {number[]} Decoded data
|
|
@@ -349,8 +344,7 @@ function decode(data, encoding, compression) {
|
|
|
349
344
|
|
|
350
345
|
/**
|
|
351
346
|
* Parse a XML TMX object and returns the corresponding javascript object
|
|
352
|
-
* @
|
|
353
|
-
* @memberOf TMXUtils
|
|
347
|
+
* @memberof TMXUtils
|
|
354
348
|
* @param {Document} xml - XML TMX object
|
|
355
349
|
* @returns {object} Javascript object
|
|
356
350
|
*/
|
|
@@ -390,8 +384,7 @@ function parse(xml) {
|
|
|
390
384
|
|
|
391
385
|
/**
|
|
392
386
|
* Apply TMX Properties to the given object
|
|
393
|
-
* @
|
|
394
|
-
* @memberOf TMXUtils
|
|
387
|
+
* @memberof TMXUtils
|
|
395
388
|
* @param {object} obj - object to apply the properties to
|
|
396
389
|
* @param {object} data - TMX data object
|
|
397
390
|
* @returns {object} obj
|