melonjs 15.2.0 → 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 +5 -5
- 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 +4 -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 +117 -90
- 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 +4 -54
- 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 +262 -250
- package/dist/types/application/application.d.ts +4 -27
- package/dist/types/application/settings.d.ts +64 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/level/tiled/TMXUtils.d.ts +18 -37
- 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 +3 -57
- package/dist/types/video/webgl/webgl_renderer.d.ts +1 -34
- package/package.json +7 -7
- package/src/application/application.js +22 -18
- package/src/application/resize.js +8 -2
- package/src/application/settings.js +36 -0
- package/src/index.js +2 -0
- package/src/level/tiled/TMXUtils.js +116 -92
- 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 +7 -30
- package/src/video/webgl/webgl_renderer.js +12 -15
package/dist/melonjs.module.js
CHANGED
|
@@ -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
|
|
@@ -2409,12 +2409,12 @@ let cssToRGB = new Map();
|
|
|
2409
2409
|
* @returns {Color} Reference to this object for method chaining
|
|
2410
2410
|
*/
|
|
2411
2411
|
copy(color) {
|
|
2412
|
-
if (color
|
|
2412
|
+
if (typeof color === "string") {
|
|
2413
|
+
return this.parseCSS(color);
|
|
2414
|
+
} else {
|
|
2413
2415
|
this.glArray.set(color.glArray);
|
|
2414
2416
|
return this;
|
|
2415
2417
|
}
|
|
2416
|
-
|
|
2417
|
-
return this.parseCSS(color);
|
|
2418
2418
|
}
|
|
2419
2419
|
|
|
2420
2420
|
/**
|
|
@@ -9446,6 +9446,17 @@ const DOM_READY = "dom_ready";
|
|
|
9446
9446
|
*/
|
|
9447
9447
|
const BOOT = "me.boot";
|
|
9448
9448
|
|
|
9449
|
+
/**
|
|
9450
|
+
* event generated when the system update the engine and the renderer by one step
|
|
9451
|
+
* @public
|
|
9452
|
+
* @constant
|
|
9453
|
+
* @type {string}
|
|
9454
|
+
* @name TICK
|
|
9455
|
+
* @memberof event
|
|
9456
|
+
* @see event.on
|
|
9457
|
+
*/
|
|
9458
|
+
const TICK = "me.tick";
|
|
9459
|
+
|
|
9449
9460
|
/**
|
|
9450
9461
|
* event when the game is paused <br>
|
|
9451
9462
|
* Data passed : none <br>
|
|
@@ -9505,6 +9516,17 @@ const STATE_RESTART = "me.state.onRestart";
|
|
|
9505
9516
|
*/
|
|
9506
9517
|
const STATE_CHANGE = "me.state.onChange";
|
|
9507
9518
|
|
|
9519
|
+
/**
|
|
9520
|
+
* event for when a stage is resetted
|
|
9521
|
+
* @public
|
|
9522
|
+
* @constant
|
|
9523
|
+
* @type {string}
|
|
9524
|
+
* @name STAGE_RESET
|
|
9525
|
+
* @memberof event
|
|
9526
|
+
* @see event.on
|
|
9527
|
+
*/
|
|
9528
|
+
const STAGE_RESET = "me.stage.onReset";
|
|
9529
|
+
|
|
9508
9530
|
/**
|
|
9509
9531
|
* event for when the video is initialized<br>
|
|
9510
9532
|
* Data passed : none <br>
|
|
@@ -9969,11 +9991,13 @@ var event = {
|
|
|
9969
9991
|
ONCONTEXT_RESTORED: ONCONTEXT_RESTORED,
|
|
9970
9992
|
POINTERLOCKCHANGE: POINTERLOCKCHANGE,
|
|
9971
9993
|
POINTERMOVE: POINTERMOVE,
|
|
9994
|
+
STAGE_RESET: STAGE_RESET,
|
|
9972
9995
|
STATE_CHANGE: STATE_CHANGE,
|
|
9973
9996
|
STATE_PAUSE: STATE_PAUSE,
|
|
9974
9997
|
STATE_RESTART: STATE_RESTART,
|
|
9975
9998
|
STATE_RESUME: STATE_RESUME,
|
|
9976
9999
|
STATE_STOP: STATE_STOP,
|
|
10000
|
+
TICK: TICK,
|
|
9977
10001
|
VIDEO_INIT: VIDEO_INIT,
|
|
9978
10002
|
VIEWPORT_ONCHANGE: VIEWPORT_ONCHANGE,
|
|
9979
10003
|
VIEWPORT_ONRESIZE: VIEWPORT_ONRESIZE,
|
|
@@ -13969,7 +13993,7 @@ var audio = {
|
|
|
13969
13993
|
* @static
|
|
13970
13994
|
* @see Application
|
|
13971
13995
|
*/
|
|
13972
|
-
const CANVAS
|
|
13996
|
+
const CANVAS = 0;
|
|
13973
13997
|
|
|
13974
13998
|
/**
|
|
13975
13999
|
* constant to select select the WebGL renderer
|
|
@@ -13977,7 +14001,7 @@ const CANVAS$1 = 0;
|
|
|
13977
14001
|
* @static
|
|
13978
14002
|
* @see Application
|
|
13979
14003
|
*/
|
|
13980
|
-
const WEBGL
|
|
14004
|
+
const WEBGL = 1;
|
|
13981
14005
|
|
|
13982
14006
|
/**
|
|
13983
14007
|
* constant to auto-select the renderer (Attempt WebGL first, with fallback to Canvas)
|
|
@@ -13985,33 +14009,7 @@ const WEBGL$1 = 1;
|
|
|
13985
14009
|
* @type {number}
|
|
13986
14010
|
* @see Application
|
|
13987
14011
|
*/
|
|
13988
|
-
const AUTO
|
|
13989
|
-
|
|
13990
|
-
/**
|
|
13991
|
-
* @namespace video
|
|
13992
|
-
*/
|
|
13993
|
-
|
|
13994
|
-
|
|
13995
|
-
/**
|
|
13996
|
-
* Select the HTML5 Canvas renderer
|
|
13997
|
-
* @memberof video
|
|
13998
|
-
* @static
|
|
13999
|
-
*/
|
|
14000
|
-
const CANVAS = CANVAS$1;
|
|
14001
|
-
|
|
14002
|
-
/**
|
|
14003
|
-
* Select the WebGL renderer
|
|
14004
|
-
* @memberof video
|
|
14005
|
-
* @static
|
|
14006
|
-
*/
|
|
14007
|
-
const WEBGL = WEBGL$1;
|
|
14008
|
-
|
|
14009
|
-
/**
|
|
14010
|
-
* Auto-select the renderer (Attempt WebGL first, with fallback to Canvas)
|
|
14011
|
-
* @memberof video
|
|
14012
|
-
* @static
|
|
14013
|
-
*/
|
|
14014
|
-
const AUTO = AUTO$1;
|
|
14012
|
+
const AUTO = 2;
|
|
14015
14013
|
|
|
14016
14014
|
/**
|
|
14017
14015
|
* A reference to the active Canvas or WebGL active renderer renderer
|
|
@@ -14022,34 +14020,10 @@ let renderer = null;
|
|
|
14022
14020
|
|
|
14023
14021
|
/**
|
|
14024
14022
|
* Initialize the "video" system (create a canvas based on the given arguments, and the related renderer). <br>
|
|
14025
|
-
* melonJS support various scaling mode, that can be enabled <u>once the scale option is set to <b>`auto`</b></u> : <br>
|
|
14026
|
-
* - <i><b>`fit`</b></i> : Letterboxed; content is scaled to design aspect ratio <br>
|
|
14027
|
-
* <center><img src="images/scale-fit.png"/></center><br>
|
|
14028
|
-
* - <i><b>`fill-min`</b></i> : Canvas is resized to fit minimum design resolution; content is scaled to design aspect ratio <br>
|
|
14029
|
-
* <center><img src="images/scale-fill-min.png"/></center><br>
|
|
14030
|
-
* - <i><b>`fill-max`</b></i> : Canvas is resized to fit maximum design resolution; content is scaled to design aspect ratio <br>
|
|
14031
|
-
* <center><img src="images/scale-fill-max.png"/></center><br>
|
|
14032
|
-
* - <i><b>`flex`</b><</i> : Canvas width & height is resized to fit; content is scaled to design aspect ratio <br>
|
|
14033
|
-
* <center><img src="images/scale-flex.png"/></center><br>
|
|
14034
|
-
* - <i><b>`flex-width`</b></i> : Canvas width is resized to fit; content is scaled to design aspect ratio <br>
|
|
14035
|
-
* <center><img src="images/scale-flex-width.png"/></center><br>
|
|
14036
|
-
* - <i><b>`flex-height`</b></i> : Canvas height is resized to fit; content is scaled to design aspect ratio <br>
|
|
14037
|
-
* <center><img src="images/scale-flex-height.png"/></center><br>
|
|
14038
|
-
* - <i><b>`stretch`</b></i> : Canvas is resized to fit; content is scaled to screen aspect ratio
|
|
14039
|
-
* <center><img src="images/scale-stretch.png"/></center><br>
|
|
14040
14023
|
* @memberof video
|
|
14041
14024
|
* @param {number} width - The width of the canvas viewport
|
|
14042
14025
|
* @param {number} height - The height of the canvas viewport
|
|
14043
|
-
* @param {
|
|
14044
|
-
* @param {string|HTMLElement} [options.parent=document.body] - the DOM parent element to hold the canvas in the HTML file
|
|
14045
|
-
* @param {number|Renderer} [options.renderer=video.AUTO] - renderer to use (me.video.CANVAS, me.video.WEBGL, me.video.AUTO), or a custom renderer class
|
|
14046
|
-
* @param {number|string} [options.scale=1.0] - enable scaling of the canvas ('auto' for automatic scaling)
|
|
14047
|
-
* @param {string} [options.scaleMethod="fit"] - screen scaling modes ('fit','fill-min','fill-max','flex','flex-width','flex-height','stretch')
|
|
14048
|
-
* @param {boolean} [options.preferWebGL1=false] - if true the renderer will only use WebGL 1
|
|
14049
|
-
* @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.
|
|
14050
|
-
* @param {boolean} [options.transparent=false] - whether to allow transparent pixels in the front buffer (screen).
|
|
14051
|
-
* @param {boolean} [options.antiAlias=false] - whether to enable or not video scaling interpolation
|
|
14052
|
-
* @param {boolean} [options.consoleHeader=true] - whether to display melonJS version and basic device information in the console
|
|
14026
|
+
* @param {Application.Settings} [options] - optional parameters for the renderer
|
|
14053
14027
|
* @returns {boolean} false if initialization failed (canvas not supported)
|
|
14054
14028
|
* @example
|
|
14055
14029
|
* // init the video with a 640x480 canvas
|
|
@@ -14551,6 +14525,7 @@ function hasOffscreenCanvas() {
|
|
|
14551
14525
|
|
|
14552
14526
|
/**
|
|
14553
14527
|
* used by [un]watchAccelerometer()
|
|
14528
|
+
* @ignore
|
|
14554
14529
|
*/
|
|
14555
14530
|
function onDeviceMotion(e) {
|
|
14556
14531
|
// Accelerometer information
|
|
@@ -14561,6 +14536,7 @@ function onDeviceMotion(e) {
|
|
|
14561
14536
|
|
|
14562
14537
|
/**
|
|
14563
14538
|
* used by [un]watchDeviceOrientation()
|
|
14539
|
+
* @ignore
|
|
14564
14540
|
*/
|
|
14565
14541
|
function onDeviceRotate(e) {
|
|
14566
14542
|
gamma = e.gamma;
|
|
@@ -17843,6 +17819,9 @@ var input = {
|
|
|
17843
17819
|
// viewport flag
|
|
17844
17820
|
this._inViewport = false;
|
|
17845
17821
|
|
|
17822
|
+
// renderable cache tint value used by the getter/setter
|
|
17823
|
+
this._tint = pool.pull("Color", 255, 255, 255, 1.0);
|
|
17824
|
+
|
|
17846
17825
|
// ensure it's fully opaque by default
|
|
17847
17826
|
this.setOpacity(1.0);
|
|
17848
17827
|
}
|
|
@@ -17867,21 +17846,11 @@ var input = {
|
|
|
17867
17846
|
* this.tint.setColor(255, 255, 255);
|
|
17868
17847
|
*/
|
|
17869
17848
|
get tint() {
|
|
17870
|
-
if (typeof this._tint === "undefined") {
|
|
17871
|
-
this._tint = pool.pull("Color", 255, 255, 255, 1.0);
|
|
17872
|
-
}
|
|
17873
17849
|
return this._tint;
|
|
17874
17850
|
}
|
|
17875
17851
|
set tint(value) {
|
|
17876
|
-
|
|
17877
|
-
|
|
17878
|
-
}
|
|
17879
|
-
if (value instanceof Color) {
|
|
17880
|
-
this._tint.copy(value);
|
|
17881
|
-
} else {
|
|
17882
|
-
// string (#RGB, #ARGB, #RRGGBB, #AARRGGBB)
|
|
17883
|
-
this._tint.parseCSS(value);
|
|
17884
|
-
}
|
|
17852
|
+
this._tint.copy(value);
|
|
17853
|
+
this.isDirty = true;
|
|
17885
17854
|
}
|
|
17886
17855
|
|
|
17887
17856
|
/**
|
|
@@ -19192,7 +19161,6 @@ let default_settings = {
|
|
|
19192
19161
|
* @ignore
|
|
19193
19162
|
*/
|
|
19194
19163
|
reset() {
|
|
19195
|
-
|
|
19196
19164
|
// add all defined cameras
|
|
19197
19165
|
this.settings.cameras.forEach((camera) => {
|
|
19198
19166
|
this.cameras.set(camera.name, camera);
|
|
@@ -19210,7 +19178,7 @@ let default_settings = {
|
|
|
19210
19178
|
}
|
|
19211
19179
|
|
|
19212
19180
|
// reset the game
|
|
19213
|
-
|
|
19181
|
+
emit(STAGE_RESET, this);
|
|
19214
19182
|
|
|
19215
19183
|
// call the onReset Function
|
|
19216
19184
|
this.onResetEvent.apply(this, arguments);
|
|
@@ -19225,8 +19193,7 @@ let default_settings = {
|
|
|
19225
19193
|
* @returns {boolean}
|
|
19226
19194
|
*/
|
|
19227
19195
|
update(dt) {
|
|
19228
|
-
|
|
19229
|
-
let isDirty = game.world.update(dt);
|
|
19196
|
+
let isDirty = false;
|
|
19230
19197
|
|
|
19231
19198
|
// update the camera/viewport
|
|
19232
19199
|
// iterate through all cameras
|
|
@@ -19251,13 +19218,15 @@ let default_settings = {
|
|
|
19251
19218
|
* @name draw
|
|
19252
19219
|
* @memberof Stage
|
|
19253
19220
|
* @ignore
|
|
19254
|
-
* @param {
|
|
19221
|
+
* @param {Renderer} renderer - the renderer object to draw with
|
|
19222
|
+
* @param {World} world - the world object to draw
|
|
19255
19223
|
*/
|
|
19256
|
-
draw(renderer) {
|
|
19224
|
+
draw(renderer, world) {
|
|
19225
|
+
|
|
19257
19226
|
// iterate through all cameras
|
|
19258
19227
|
this.cameras.forEach((camera) => {
|
|
19259
19228
|
// render the root container
|
|
19260
|
-
camera.draw(renderer,
|
|
19229
|
+
camera.draw(renderer, world);
|
|
19261
19230
|
|
|
19262
19231
|
// render the ambient light
|
|
19263
19232
|
if (this.ambientLight.alpha !== 0) {
|
|
@@ -19277,9 +19246,9 @@ let default_settings = {
|
|
|
19277
19246
|
|
|
19278
19247
|
// render all lights
|
|
19279
19248
|
this.lights.forEach((light) => {
|
|
19280
|
-
light.preDraw(renderer,
|
|
19281
|
-
light.draw(renderer,
|
|
19282
|
-
light.postDraw(renderer,
|
|
19249
|
+
light.preDraw(renderer, world);
|
|
19250
|
+
light.draw(renderer, world);
|
|
19251
|
+
light.postDraw(renderer, world);
|
|
19283
19252
|
});
|
|
19284
19253
|
});
|
|
19285
19254
|
}
|
|
@@ -19314,7 +19283,6 @@ let default_settings = {
|
|
|
19314
19283
|
if (typeof this.settings.onResetEvent === "function") {
|
|
19315
19284
|
this.settings.onResetEvent.apply(this, arguments);
|
|
19316
19285
|
}
|
|
19317
|
-
|
|
19318
19286
|
}
|
|
19319
19287
|
|
|
19320
19288
|
/**
|
|
@@ -19874,6 +19842,12 @@ const COLLISION_GROUP = "collision";
|
|
|
19874
19842
|
}
|
|
19875
19843
|
}
|
|
19876
19844
|
|
|
19845
|
+
/**
|
|
19846
|
+
* the function used to decompress zlib/gzip data
|
|
19847
|
+
* @ignore
|
|
19848
|
+
*/
|
|
19849
|
+
let inflateFunction;
|
|
19850
|
+
|
|
19877
19851
|
/**
|
|
19878
19852
|
* set and interpret a TMX property value
|
|
19879
19853
|
* @ignore
|
|
@@ -19969,94 +19943,6 @@ function parseAttributes(obj, elt) {
|
|
|
19969
19943
|
}
|
|
19970
19944
|
}
|
|
19971
19945
|
|
|
19972
|
-
/**
|
|
19973
|
-
* decompress and decode zlib/gzip data
|
|
19974
|
-
* @ignore
|
|
19975
|
-
* @name decompress
|
|
19976
|
-
* @param {string} input - Base64 encoded and compressed data
|
|
19977
|
-
* @param {string} format - compressed data format ("gzip","zlib", "zstd")
|
|
19978
|
-
* @returns {Uint32Array} Decoded and decompress data
|
|
19979
|
-
*/
|
|
19980
|
-
function decompress(data, format) {
|
|
19981
|
-
if (typeof undefined === "function") {
|
|
19982
|
-
return undefined(data, format);
|
|
19983
|
-
} else {
|
|
19984
|
-
throw new Error("GZIP/ZLIB compressed TMX Tile Map not supported!");
|
|
19985
|
-
}
|
|
19986
|
-
}
|
|
19987
|
-
|
|
19988
|
-
/**
|
|
19989
|
-
* Decode a CSV encoded array into a binary array
|
|
19990
|
-
* @ignore
|
|
19991
|
-
* @name decodeCSV
|
|
19992
|
-
* @param {string} input- - CSV formatted data (only numbers, everything else will be converted to NaN)
|
|
19993
|
-
* @returns {number[]} Decoded data
|
|
19994
|
-
*/
|
|
19995
|
-
function decodeCSV(input) {
|
|
19996
|
-
let entries = input.replace("\n", "").trim().split(",");
|
|
19997
|
-
|
|
19998
|
-
let result = [];
|
|
19999
|
-
for (let i = 0; i < entries.length; i++) {
|
|
20000
|
-
result.push(+entries[i]);
|
|
20001
|
-
}
|
|
20002
|
-
return result;
|
|
20003
|
-
}
|
|
20004
|
-
|
|
20005
|
-
/**
|
|
20006
|
-
* Decode a base64 encoded string into a byte array
|
|
20007
|
-
* @ignore
|
|
20008
|
-
* @name decodeBase64AsArray
|
|
20009
|
-
* @param {string} input - Base64 encoded data
|
|
20010
|
-
* @param {number} [bytes] - number of bytes per array entry
|
|
20011
|
-
* @returns {Uint32Array} Decoded data
|
|
20012
|
-
*/
|
|
20013
|
-
function decodeBase64AsArray(input, bytes) {
|
|
20014
|
-
bytes = bytes || 1;
|
|
20015
|
-
|
|
20016
|
-
let i, j, len;
|
|
20017
|
-
let dec = globalThis.atob(input.replace(/[^A-Za-z0-9\+\/\=]/g, ""));
|
|
20018
|
-
let ar = new Uint32Array(dec.length / bytes);
|
|
20019
|
-
|
|
20020
|
-
for (i = 0, len = dec.length / bytes; i < len; i++) {
|
|
20021
|
-
ar[i] = 0;
|
|
20022
|
-
for (j = bytes - 1; j >= 0; --j) {
|
|
20023
|
-
ar[i] += dec.charCodeAt((i * bytes) + j) << (j << 3);
|
|
20024
|
-
}
|
|
20025
|
-
}
|
|
20026
|
-
return ar;
|
|
20027
|
-
}
|
|
20028
|
-
|
|
20029
|
-
/**
|
|
20030
|
-
* Decode the given data
|
|
20031
|
-
* @ignore
|
|
20032
|
-
*/
|
|
20033
|
-
function decode(data, encoding, compression) {
|
|
20034
|
-
compression = compression || "none";
|
|
20035
|
-
encoding = encoding || "none";
|
|
20036
|
-
|
|
20037
|
-
switch (encoding) {
|
|
20038
|
-
case "csv":
|
|
20039
|
-
return decodeCSV(data);
|
|
20040
|
-
|
|
20041
|
-
case "base64":
|
|
20042
|
-
if (compression !== "none") {
|
|
20043
|
-
data = decompress(data, compression);
|
|
20044
|
-
} else {
|
|
20045
|
-
data = decodeBase64AsArray(data, 4);
|
|
20046
|
-
}
|
|
20047
|
-
return data;
|
|
20048
|
-
|
|
20049
|
-
case "none":
|
|
20050
|
-
return data;
|
|
20051
|
-
|
|
20052
|
-
case "xml":
|
|
20053
|
-
throw new Error("XML encoding is deprecated, use base64 instead");
|
|
20054
|
-
|
|
20055
|
-
default:
|
|
20056
|
-
throw new Error("Unknown layer encoding: " + encoding);
|
|
20057
|
-
}
|
|
20058
|
-
}
|
|
20059
|
-
|
|
20060
19946
|
/**
|
|
20061
19947
|
* Normalize TMX format to Tiled JSON format
|
|
20062
19948
|
* @ignore
|
|
@@ -20189,9 +20075,113 @@ function normalize(obj, item) {
|
|
|
20189
20075
|
}
|
|
20190
20076
|
}
|
|
20191
20077
|
|
|
20078
|
+
/**
|
|
20079
|
+
* a collection of utility functions for parsing TMX maps
|
|
20080
|
+
* @namespace TMXUtils
|
|
20081
|
+
*/
|
|
20082
|
+
|
|
20083
|
+
/**
|
|
20084
|
+
* decompress and decode zlib/gzip data
|
|
20085
|
+
* @memberof TMXUtils
|
|
20086
|
+
* @param {string} input - Base64 encoded and compressed data
|
|
20087
|
+
* @param {string} format - compressed data format ("gzip","zlib", "zstd")
|
|
20088
|
+
* @returns {Uint32Array} Decoded and decompress data
|
|
20089
|
+
*/
|
|
20090
|
+
function decompress(data, format) {
|
|
20091
|
+
if (typeof inflateFunction === "function") {
|
|
20092
|
+
return inflateFunction(data, format);
|
|
20093
|
+
} else {
|
|
20094
|
+
throw new Error("GZIP/ZLIB compressed TMX Tile Map not supported!");
|
|
20095
|
+
}
|
|
20096
|
+
}
|
|
20097
|
+
|
|
20098
|
+
/**
|
|
20099
|
+
* Decode a CSV encoded array into a binary array
|
|
20100
|
+
* @memberof TMXUtils
|
|
20101
|
+
* @param {string} input- - CSV formatted data (only numbers, everything else will be converted to NaN)
|
|
20102
|
+
* @returns {number[]} Decoded data
|
|
20103
|
+
*/
|
|
20104
|
+
function decodeCSV(input) {
|
|
20105
|
+
let entries = input.replace("\n", "").trim().split(",");
|
|
20106
|
+
|
|
20107
|
+
let result = [];
|
|
20108
|
+
for (let i = 0; i < entries.length; i++) {
|
|
20109
|
+
result.push(+entries[i]);
|
|
20110
|
+
}
|
|
20111
|
+
return result;
|
|
20112
|
+
}
|
|
20113
|
+
|
|
20114
|
+
/**
|
|
20115
|
+
* Decode a base64 encoded string into a byte array
|
|
20116
|
+
* @memberof TMXUtils
|
|
20117
|
+
* @param {string} input - Base64 encoded data
|
|
20118
|
+
* @param {number} [bytes] - number of bytes per array entry
|
|
20119
|
+
* @returns {Uint32Array} Decoded data
|
|
20120
|
+
*/
|
|
20121
|
+
function decodeBase64AsArray(input, bytes) {
|
|
20122
|
+
bytes = bytes || 1;
|
|
20123
|
+
|
|
20124
|
+
let i, j, len;
|
|
20125
|
+
let dec = globalThis.atob(input.replace(/[^A-Za-z0-9\+\/\=]/g, ""));
|
|
20126
|
+
let ar = new Uint32Array(dec.length / bytes);
|
|
20127
|
+
|
|
20128
|
+
for (i = 0, len = dec.length / bytes; i < len; i++) {
|
|
20129
|
+
ar[i] = 0;
|
|
20130
|
+
for (j = bytes - 1; j >= 0; --j) {
|
|
20131
|
+
ar[i] += dec.charCodeAt((i * bytes) + j) << (j << 3);
|
|
20132
|
+
}
|
|
20133
|
+
}
|
|
20134
|
+
return ar;
|
|
20135
|
+
}
|
|
20136
|
+
|
|
20137
|
+
/**
|
|
20138
|
+
* set the function used to inflate gzip/zlib data
|
|
20139
|
+
* @memberof TMXUtils
|
|
20140
|
+
* @param {Func} fn - inflate function
|
|
20141
|
+
*/
|
|
20142
|
+
function setInflateFunction(fn) {
|
|
20143
|
+
inflateFunction = fn;
|
|
20144
|
+
}
|
|
20145
|
+
|
|
20146
|
+
/**
|
|
20147
|
+
* Decode a encoded array into a binary array
|
|
20148
|
+
* @memberof TMXUtils
|
|
20149
|
+
* @param {string} data - data to be decoded
|
|
20150
|
+
* @param {string} [encoding="none"] - data encoding ("csv", "base64", "xml")
|
|
20151
|
+
* @returns {number[]} Decoded data
|
|
20152
|
+
*/
|
|
20153
|
+
function decode(data, encoding, compression) {
|
|
20154
|
+
compression = compression || "none";
|
|
20155
|
+
encoding = encoding || "none";
|
|
20156
|
+
|
|
20157
|
+
switch (encoding) {
|
|
20158
|
+
case "csv":
|
|
20159
|
+
return decodeCSV(data);
|
|
20160
|
+
|
|
20161
|
+
case "base64":
|
|
20162
|
+
if (compression !== "none") {
|
|
20163
|
+
data = decompress(data, compression);
|
|
20164
|
+
} else {
|
|
20165
|
+
data = decodeBase64AsArray(data, 4);
|
|
20166
|
+
}
|
|
20167
|
+
return data;
|
|
20168
|
+
|
|
20169
|
+
case "none":
|
|
20170
|
+
return data;
|
|
20171
|
+
|
|
20172
|
+
case "xml":
|
|
20173
|
+
throw new Error("XML encoding is deprecated, use base64 instead");
|
|
20174
|
+
|
|
20175
|
+
default:
|
|
20176
|
+
throw new Error("Unknown layer encoding: " + encoding);
|
|
20177
|
+
}
|
|
20178
|
+
}
|
|
20179
|
+
|
|
20192
20180
|
/**
|
|
20193
20181
|
* Parse a XML TMX object and returns the corresponding javascript object
|
|
20194
|
-
* @
|
|
20182
|
+
* @memberof TMXUtils
|
|
20183
|
+
* @param {Document} xml - XML TMX object
|
|
20184
|
+
* @returns {object} Javascript object
|
|
20195
20185
|
*/
|
|
20196
20186
|
function parse(xml) {
|
|
20197
20187
|
// Create the return object
|
|
@@ -20229,7 +20219,10 @@ function parse(xml) {
|
|
|
20229
20219
|
|
|
20230
20220
|
/**
|
|
20231
20221
|
* Apply TMX Properties to the given object
|
|
20232
|
-
* @
|
|
20222
|
+
* @memberof TMXUtils
|
|
20223
|
+
* @param {object} obj - object to apply the properties to
|
|
20224
|
+
* @param {object} data - TMX data object
|
|
20225
|
+
* @returns {object} obj
|
|
20233
20226
|
*/
|
|
20234
20227
|
function applyTMXProperties(obj, data) {
|
|
20235
20228
|
let properties = data.properties;
|
|
@@ -20259,6 +20252,14 @@ function applyTMXProperties(obj, data) {
|
|
|
20259
20252
|
}
|
|
20260
20253
|
}
|
|
20261
20254
|
|
|
20255
|
+
var TMXUtils = {
|
|
20256
|
+
__proto__: null,
|
|
20257
|
+
applyTMXProperties: applyTMXProperties,
|
|
20258
|
+
decode: decode,
|
|
20259
|
+
parse: parse,
|
|
20260
|
+
setInflateFunction: setInflateFunction
|
|
20261
|
+
};
|
|
20262
|
+
|
|
20262
20263
|
/**
|
|
20263
20264
|
* @classdesc
|
|
20264
20265
|
* a basic tile object
|
|
@@ -20990,20 +20991,7 @@ class TMXObject {
|
|
|
20990
20991
|
*/
|
|
20991
20992
|
class Renderer {
|
|
20992
20993
|
/**
|
|
20993
|
-
* @param {
|
|
20994
|
-
* @param {number} options.width - The width of the canvas without scaling
|
|
20995
|
-
* @param {number} options.height - The height of the canvas without scaling
|
|
20996
|
-
* @param {HTMLCanvasElement} [options.canvas] - The html canvas to draw to on screen
|
|
20997
|
-
* @param {boolean} [options.antiAlias=false] - Whether to enable anti-aliasing, use false (default) for a pixelated effect.
|
|
20998
|
-
* @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.
|
|
20999
|
-
* @param {boolean} [options.transparent=false] - Whether to enable transparency on the canvas
|
|
21000
|
-
* @param {boolean} [options.premultipliedAlpha=true] - in WebGL, whether the renderer will assume that colors have premultiplied alpha when canvas transparency is enabled
|
|
21001
|
-
* @param {boolean} [options.blendMode="normal"] - the default blend mode to use ("normal", "multiply")
|
|
21002
|
-
* @param {boolean} [options.depthBuffer="sorting"] - ~Experimental~ the default method to sort object on the z axis in WebGL ("sorting", "z-buffer")
|
|
21003
|
-
* @param {boolean} [options.subPixel=false] - Whether to enable subpixel rendering (performance hit when enabled)
|
|
21004
|
-
* @param {boolean} [options.verbose=false] - Enable the verbose mode that provides additional details as to what the renderer is doing
|
|
21005
|
-
* @param {number} [options.zoomX=width] - The actual width of the canvas with scaling applied
|
|
21006
|
-
* @param {number} [options.zoomY=height] - The actual height of the canvas with scaling applied
|
|
20994
|
+
* @param {Application.Settings} [options] - optional parameters for the renderer
|
|
21007
20995
|
*/
|
|
21008
20996
|
constructor(options) {
|
|
21009
20997
|
/**
|
|
@@ -22267,16 +22255,7 @@ class TextureCache {
|
|
|
22267
22255
|
*/
|
|
22268
22256
|
class CanvasRenderer extends Renderer {
|
|
22269
22257
|
/**
|
|
22270
|
-
* @param {
|
|
22271
|
-
* @param {number} options.width - The width of the canvas without scaling
|
|
22272
|
-
* @param {number} options.height - The height of the canvas without scaling
|
|
22273
|
-
* @param {HTMLCanvasElement} [options.canvas] - The html canvas to draw to on screen
|
|
22274
|
-
* @param {boolean} [options.antiAlias=false] - Whether to enable anti-aliasing
|
|
22275
|
-
* @param {boolean} [options.transparent=false] - Whether to enable transparency on the canvas (performance hit when enabled)
|
|
22276
|
-
* @param {boolean} [options.subPixel=false] - Whether to enable subpixel renderering (performance hit when enabled)
|
|
22277
|
-
* @param {boolean} [options.textureSeamFix=true] - enable the texture seam fix when rendering Tile when antiAlias is off for the canvasRenderer
|
|
22278
|
-
* @param {number} [options.zoomX=width] - The actual width of the canvas with scaling applied
|
|
22279
|
-
* @param {number} [options.zoomY=height] - The actual height of the canvas with scaling applied
|
|
22258
|
+
* @param {Application.Settings} [options] - optional parameters for the renderer
|
|
22280
22259
|
*/
|
|
22281
22260
|
constructor(options) {
|
|
22282
22261
|
// parent constructor
|
|
@@ -27882,11 +27861,7 @@ function _pauseRunLoop() {
|
|
|
27882
27861
|
* @ignore
|
|
27883
27862
|
*/
|
|
27884
27863
|
function _renderFrame(time) {
|
|
27885
|
-
|
|
27886
|
-
// update all game objects
|
|
27887
|
-
game.update(time, stage);
|
|
27888
|
-
// render all game objects
|
|
27889
|
-
game.draw(stage);
|
|
27864
|
+
emit(TICK, time);
|
|
27890
27865
|
// schedule the next frame update
|
|
27891
27866
|
if (_animFrameId !== -1) {
|
|
27892
27867
|
_animFrameId = globalThis.requestAnimationFrame(_renderFrame);
|
|
@@ -27935,9 +27910,6 @@ function _switchState(state) {
|
|
|
27935
27910
|
if (_onSwitchComplete) {
|
|
27936
27911
|
_onSwitchComplete();
|
|
27937
27912
|
}
|
|
27938
|
-
|
|
27939
|
-
// force repaint
|
|
27940
|
-
game.repaint();
|
|
27941
27913
|
}
|
|
27942
27914
|
}
|
|
27943
27915
|
|
|
@@ -28083,7 +28055,7 @@ let state = {
|
|
|
28083
28055
|
* default state ID for the default Stage
|
|
28084
28056
|
* (the default stage is the one running as soon as melonJS is started)
|
|
28085
28057
|
* @constant
|
|
28086
|
-
* @name
|
|
28058
|
+
* @name DEFAULT
|
|
28087
28059
|
* @memberof state
|
|
28088
28060
|
*/
|
|
28089
28061
|
DEFAULT : 9,
|
|
@@ -28171,9 +28143,6 @@ let state = {
|
|
|
28171
28143
|
// calculate the elpased time
|
|
28172
28144
|
_pauseTime = globalThis.performance.now() - _pauseTime;
|
|
28173
28145
|
|
|
28174
|
-
// force repaint
|
|
28175
|
-
game.repaint();
|
|
28176
|
-
|
|
28177
28146
|
// publish the restart notification
|
|
28178
28147
|
emit(STATE_RESTART, _pauseTime);
|
|
28179
28148
|
}
|
|
@@ -31308,21 +31277,7 @@ let V_ARRAY = [
|
|
|
31308
31277
|
*/
|
|
31309
31278
|
class WebGLRenderer extends Renderer {
|
|
31310
31279
|
/**
|
|
31311
|
-
* @param {
|
|
31312
|
-
* @param {number} options.width - The width of the canvas without scaling
|
|
31313
|
-
* @param {number} options.height - The height of the canvas without scaling
|
|
31314
|
-
* @param {HTMLCanvasElement} [options.canvas] - The html canvas to draw to on screen
|
|
31315
|
-
* @param {boolean} [options.antiAlias=false] - Whether to enable anti-aliasing
|
|
31316
|
-
* @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.
|
|
31317
|
-
* @param {boolean} [options.transparent=false] - Whether to enable transparency on the canvas
|
|
31318
|
-
* @param {boolean} [options.premultipliedAlpha=true] - in WebGL, whether the renderer will assume that colors have premultiplied alpha when canvas transparency is enabled
|
|
31319
|
-
* @param {boolean} [options.subPixel=false] - Whether to enable subpixel renderering (performance hit when enabled)
|
|
31320
|
-
* @param {boolean} [options.preferWebGL1=false] - if true the renderer will only use WebGL 1
|
|
31321
|
-
* @param {boolean} [options.depthTest="sorting"] - ~Experimental~ the default method to sort object on the z axis in WebGL ("sorting", "z-buffer")
|
|
31322
|
-
* @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.
|
|
31323
|
-
* @param {number} [options.zoomX=width] - The actual width of the canvas with scaling applied
|
|
31324
|
-
* @param {number} [options.zoomY=height] - The actual height of the canvas with scaling applied
|
|
31325
|
-
* @param {Compositor} [options.compositor] - A class that implements the compositor API for sprite rendering
|
|
31280
|
+
* @param {Application.Settings} [options] - optional parameters for the renderer
|
|
31326
31281
|
*/
|
|
31327
31282
|
constructor(options) {
|
|
31328
31283
|
// parent contructor
|
|
@@ -31493,6 +31448,17 @@ let V_ARRAY = [
|
|
|
31493
31448
|
reset() {
|
|
31494
31449
|
super.reset();
|
|
31495
31450
|
|
|
31451
|
+
// clear all stacks
|
|
31452
|
+
this._colorStack.forEach((color) => {
|
|
31453
|
+
pool.push(color);
|
|
31454
|
+
});
|
|
31455
|
+
this._matrixStack.forEach((matrix) => {
|
|
31456
|
+
pool.push(matrix);
|
|
31457
|
+
});
|
|
31458
|
+
this._colorStack.length = 0;
|
|
31459
|
+
this._matrixStack.length = 0;
|
|
31460
|
+
this._blendStack.length = 0;
|
|
31461
|
+
|
|
31496
31462
|
// clear gl context
|
|
31497
31463
|
this.clear();
|
|
31498
31464
|
|
|
@@ -37520,6 +37486,7 @@ function onresize(game) {
|
|
|
37520
37486
|
let renderer = game.renderer;
|
|
37521
37487
|
let settings = renderer.settings;
|
|
37522
37488
|
let scaleX = 1, scaleY = 1;
|
|
37489
|
+
let nodeBounds;
|
|
37523
37490
|
|
|
37524
37491
|
if (settings.autoScale) {
|
|
37525
37492
|
|
|
@@ -37533,8 +37500,13 @@ function onresize(game) {
|
|
|
37533
37500
|
canvasMaxHeight = parseInt(style.maxHeight, 10) || Infinity;
|
|
37534
37501
|
}
|
|
37535
37502
|
|
|
37536
|
-
|
|
37537
|
-
|
|
37503
|
+
if (typeof game.settings.scaleTarget !== "undefined") {
|
|
37504
|
+
// get the bounds of the given scale target
|
|
37505
|
+
nodeBounds = getElementBounds(game.settings.scaleTarget);
|
|
37506
|
+
} else {
|
|
37507
|
+
// get the maximum canvas size within the parent div containing the canvas container
|
|
37508
|
+
nodeBounds = getParentBounds(game.getParentElement());
|
|
37509
|
+
}
|
|
37538
37510
|
|
|
37539
37511
|
let _max_width = Math.min(canvasMaxWidth, nodeBounds.width);
|
|
37540
37512
|
let _max_height = Math.min(canvasMaxHeight, nodeBounds.height);
|
|
@@ -37595,6 +37567,7 @@ const defaultSettings = {
|
|
|
37595
37567
|
autoScale : false,
|
|
37596
37568
|
scale : 1.0,
|
|
37597
37569
|
scaleMethod : "manual",
|
|
37570
|
+
scaleTarget : undefined,
|
|
37598
37571
|
transparent : false,
|
|
37599
37572
|
premultipliedAlpha: true,
|
|
37600
37573
|
blendMode : "normal",
|
|
@@ -37608,6 +37581,41 @@ const defaultSettings = {
|
|
|
37608
37581
|
legacy : false
|
|
37609
37582
|
};
|
|
37610
37583
|
|
|
37584
|
+
/**
|
|
37585
|
+
* Application & Renderer Settings definition.
|
|
37586
|
+
* @typedef {Object} Settings
|
|
37587
|
+
* @property {string|HTMLElement} [parent=document.body] - the DOM parent element to hold the canvas in the HTML file
|
|
37588
|
+
* @property {number|Renderer} [renderer=AUTO] - renderer to use (CANVAS, WEBGL, AUTO), or a custom renderer class
|
|
37589
|
+
* @property {number|string} [scale=1.0] - enable scaling of the canvas ('auto' for automatic scaling)
|
|
37590
|
+
* @property {string} [scaleMethod="fit"] - screen scaling modes ('fit','fill-min','fill-max','flex','flex-width','flex-height','stretch') : <br>
|
|
37591
|
+
* - <i><b>`fit`</b></i> : Letterboxed; content is scaled to design aspect ratio <br>
|
|
37592
|
+
* <center><img src="images/scale-fit.png"/></center><br>
|
|
37593
|
+
* - <i><b>`fill-min`</b></i> : Canvas is resized to fit minimum design resolution; content is scaled to design aspect ratio <br>
|
|
37594
|
+
* <center><img src="images/scale-fill-min.png"/></center><br>
|
|
37595
|
+
* - <i><b>`fill-max`</b></i> : Canvas is resized to fit maximum design resolution; content is scaled to design aspect ratio <br>
|
|
37596
|
+
* <center><img src="images/scale-fill-max.png"/></center><br>
|
|
37597
|
+
* - <i><b>`flex`</b><</i> : Canvas width & height is resized to fit; content is scaled to design aspect ratio <br>
|
|
37598
|
+
* <center><img src="images/scale-flex.png"/></center><br>
|
|
37599
|
+
* - <i><b>`flex-width`</b></i> : Canvas width is resized to fit; content is scaled to design aspect ratio <br>
|
|
37600
|
+
* <center><img src="images/scale-flex-width.png"/></center><br>
|
|
37601
|
+
* - <i><b>`flex-height`</b></i> : Canvas height is resized to fit; content is scaled to design aspect ratio <br>
|
|
37602
|
+
* <center><img src="images/scale-flex-height.png"/></center><br>
|
|
37603
|
+
* - <i><b>`stretch`</b></i> : Canvas is resized to fit; content is scaled to screen aspect ratio <br>
|
|
37604
|
+
* <center><img src="images/scale-stretch.png"/></center>
|
|
37605
|
+
* @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)
|
|
37606
|
+
* @property {boolean} [preferWebGL1=false] - if true the renderer will only use WebGL 1
|
|
37607
|
+
* @property {boolean} [depthTest="sorting"] - ~Experimental~ the default method to sort object on the z axis in WebGL ("sorting", "z-buffer")
|
|
37608
|
+
* @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.
|
|
37609
|
+
* @property {boolean} [transparent=false] - whether to allow transparent pixels in the front buffer (screen).
|
|
37610
|
+
* @property {boolean} [antiAlias=false] - whether to enable or not video scaling interpolation
|
|
37611
|
+
* @property {boolean} [consoleHeader=true] - whether to display melonJS version and basic device information in the console
|
|
37612
|
+
* @param {number} [options.zoomX=width] - The actual width of the canvas with scaling applied
|
|
37613
|
+
* @param {number} [options.zoomY=height] - The actual height of the canvas with scaling applied
|
|
37614
|
+
* @param {Compositor} [options.compositor] - a custom compositor class (WebGL only)
|
|
37615
|
+
* @see Application
|
|
37616
|
+
* @memberof Application
|
|
37617
|
+
*/
|
|
37618
|
+
|
|
37611
37619
|
/**
|
|
37612
37620
|
* display information
|
|
37613
37621
|
* @param {Application} game - the game application instance calling this function
|
|
@@ -37643,17 +37651,7 @@ function consoleHeader(app) {
|
|
|
37643
37651
|
/**
|
|
37644
37652
|
* @param {number} width - The width of the canvas viewport
|
|
37645
37653
|
* @param {number} height - The height of the canvas viewport
|
|
37646
|
-
* @param {
|
|
37647
|
-
* @param {string|HTMLElement} [options.parent=document.body] - the DOM parent element to hold the canvas in the HTML file
|
|
37648
|
-
* @param {number|Renderer} [options.renderer=AUTO] - renderer to use (CANVAS, WEBGL, AUTO), or a custom renderer class
|
|
37649
|
-
* @param {number|string} [options.scale=1.0] - enable scaling of the canvas ('auto' for automatic scaling)
|
|
37650
|
-
* @param {string} [options.scaleMethod="fit"] - screen scaling modes ('fit','fill-min','fill-max','flex','flex-width','flex-height','stretch')
|
|
37651
|
-
* @param {boolean} [options.preferWebGL1=false] - if true the renderer will only use WebGL 1
|
|
37652
|
-
* @param {boolean} [options.depthTest="sorting"] - ~Experimental~ the default method to sort object on the z axis in WebGL ("sorting", "z-buffer")
|
|
37653
|
-
* @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.
|
|
37654
|
-
* @param {boolean} [options.transparent=false] - whether to allow transparent pixels in the front buffer (screen).
|
|
37655
|
-
* @param {boolean} [options.antiAlias=false] - whether to enable or not video scaling interpolation
|
|
37656
|
-
* @param {boolean} [options.consoleHeader=true] - whether to display melonJS version and basic device information in the console
|
|
37654
|
+
* @param {Application.Settings} [options] - The optional parameters for the application and default renderer
|
|
37657
37655
|
* @throws Will throw an exception if it fails to instantiate a renderer
|
|
37658
37656
|
* @example
|
|
37659
37657
|
* let my game = new Application(640, 480, {renderer: me.video.AUTO}) {
|
|
@@ -37773,12 +37771,12 @@ function consoleHeader(app) {
|
|
|
37773
37771
|
// override renderer settings if &webgl or &canvas is defined in the URL
|
|
37774
37772
|
let uriFragment = getUriFragment();
|
|
37775
37773
|
if (uriFragment.webgl === true || uriFragment.webgl1 === true || uriFragment.webgl2 === true) {
|
|
37776
|
-
this.settings.renderer = WEBGL
|
|
37774
|
+
this.settings.renderer = WEBGL;
|
|
37777
37775
|
if (uriFragment.webgl1 === true) {
|
|
37778
37776
|
this.settings.preferWebGL1 = true;
|
|
37779
37777
|
}
|
|
37780
37778
|
} else if (uriFragment.canvas === true) {
|
|
37781
|
-
this.settings.renderer = CANVAS
|
|
37779
|
+
this.settings.renderer = CANVAS;
|
|
37782
37780
|
}
|
|
37783
37781
|
|
|
37784
37782
|
// normalize scale
|
|
@@ -37788,10 +37786,16 @@ function consoleHeader(app) {
|
|
|
37788
37786
|
this.settings.zoomX = width * this.settings.scale;
|
|
37789
37787
|
this.settings.zoomY = height * this.settings.scale;
|
|
37790
37788
|
|
|
37789
|
+
// identify parent element and/or the html target for resizing
|
|
37790
|
+
this.parentElement = getElement(this.settings.parent);
|
|
37791
|
+
if (typeof this.settings.scaleTarget !== "undefined" ) {
|
|
37792
|
+
this.settings.scaleTarget = getElement(this.settings.scaleTarget);
|
|
37793
|
+
}
|
|
37794
|
+
|
|
37791
37795
|
if (typeof this.settings.renderer === "number") {
|
|
37792
37796
|
switch (this.settings.renderer) {
|
|
37793
|
-
case AUTO
|
|
37794
|
-
case WEBGL
|
|
37797
|
+
case AUTO:
|
|
37798
|
+
case WEBGL:
|
|
37795
37799
|
this.renderer = autoDetectRenderer(this.settings);
|
|
37796
37800
|
break;
|
|
37797
37801
|
default:
|
|
@@ -37809,7 +37813,6 @@ function consoleHeader(app) {
|
|
|
37809
37813
|
on(WINDOW_ONORIENTATION_CHANGE, () => onresize(this), this);
|
|
37810
37814
|
|
|
37811
37815
|
// add our canvas (default to document.body if settings.parent is undefined)
|
|
37812
|
-
this.parentElement = getElement(this.settings.parent);
|
|
37813
37816
|
this.parentElement.appendChild(this.renderer.getCanvas());
|
|
37814
37817
|
|
|
37815
37818
|
// Mobile browser hacks
|
|
@@ -37848,6 +37851,16 @@ function consoleHeader(app) {
|
|
|
37848
37851
|
this.isInitialized = true;
|
|
37849
37852
|
|
|
37850
37853
|
emit(GAME_INIT, this);
|
|
37854
|
+
on(STATE_CHANGE, this.repaint, this);
|
|
37855
|
+
on(STATE_RESTART, this.repaint, this);
|
|
37856
|
+
on(STATE_RESUME, this.repaint, this);
|
|
37857
|
+
on(STAGE_RESET, this.reset, this);
|
|
37858
|
+
on(TICK, (time) => {
|
|
37859
|
+
// update all game objects
|
|
37860
|
+
this.update(time);
|
|
37861
|
+
// render all game objects
|
|
37862
|
+
this.draw();
|
|
37863
|
+
}, this);
|
|
37851
37864
|
}
|
|
37852
37865
|
|
|
37853
37866
|
/**
|
|
@@ -37928,9 +37941,8 @@ function consoleHeader(app) {
|
|
|
37928
37941
|
/**
|
|
37929
37942
|
* update all objects related to this game active scene/stage
|
|
37930
37943
|
* @param {number} time - current timestamp as provided by the RAF callback
|
|
37931
|
-
* @param {Stage} stage - the current stage
|
|
37932
37944
|
*/
|
|
37933
|
-
update(time
|
|
37945
|
+
update(time) {
|
|
37934
37946
|
// handle frame skipping if required
|
|
37935
37947
|
if ((++this.frameCounter % this.frameRate) === 0) {
|
|
37936
37948
|
// reset the frame counter
|
|
@@ -37954,7 +37966,8 @@ function consoleHeader(app) {
|
|
|
37954
37966
|
}
|
|
37955
37967
|
|
|
37956
37968
|
// update all objects (and pass the elapsed time since last frame)
|
|
37957
|
-
this.isDirty =
|
|
37969
|
+
this.isDirty = this.world.update(this.updateDelta);
|
|
37970
|
+
this.isDirty = state$1.current().update(this.updateDelta) || this.isDirty;
|
|
37958
37971
|
|
|
37959
37972
|
this.lastUpdate = globalThis.performance.now();
|
|
37960
37973
|
this.updateAverageDelta = this.lastUpdate - this.lastUpdateStart;
|
|
@@ -37973,9 +37986,8 @@ function consoleHeader(app) {
|
|
|
37973
37986
|
|
|
37974
37987
|
/**
|
|
37975
37988
|
* draw the active scene/stage associated to this game
|
|
37976
|
-
* @param {Stage} stage - the current stage
|
|
37977
37989
|
*/
|
|
37978
|
-
draw(
|
|
37990
|
+
draw() {
|
|
37979
37991
|
if (this.renderer.isContextValid === true && (this.isDirty || this.isAlwaysDirty)) {
|
|
37980
37992
|
// publish notification
|
|
37981
37993
|
emit(GAME_BEFORE_DRAW, globalThis.performance.now());
|
|
@@ -37984,7 +37996,7 @@ function consoleHeader(app) {
|
|
|
37984
37996
|
this.renderer.clear();
|
|
37985
37997
|
|
|
37986
37998
|
// render the stage
|
|
37987
|
-
|
|
37999
|
+
state$1.current().draw(this.renderer, this.world);
|
|
37988
38000
|
|
|
37989
38001
|
// set back to flag
|
|
37990
38002
|
this.isDirty = false;
|
|
@@ -38023,9 +38035,9 @@ class BasePlugin {
|
|
|
38023
38035
|
* define the minimum required version of melonJS<br>
|
|
38024
38036
|
* this can be overridden by the plugin
|
|
38025
38037
|
* @type {string}
|
|
38026
|
-
* @default "15.
|
|
38038
|
+
* @default "15.3.0"
|
|
38027
38039
|
*/
|
|
38028
|
-
this.version = "15.
|
|
38040
|
+
this.version = "15.3.0";
|
|
38029
38041
|
}
|
|
38030
38042
|
}
|
|
38031
38043
|
|
|
@@ -38252,7 +38264,7 @@ Renderer.prototype.getScreenContext = function() {
|
|
|
38252
38264
|
* @name version
|
|
38253
38265
|
* @type {string}
|
|
38254
38266
|
*/
|
|
38255
|
-
const version = "15.
|
|
38267
|
+
const version = "15.3.0";
|
|
38256
38268
|
|
|
38257
38269
|
/**
|
|
38258
38270
|
* a flag indicating that melonJS is fully initialized
|
|
@@ -38381,4 +38393,4 @@ onReady(() => {
|
|
|
38381
38393
|
}
|
|
38382
38394
|
});
|
|
38383
38395
|
|
|
38384
|
-
export { AUTO
|
|
38396
|
+
export { AUTO, Application, BitmapText, BitmapTextData, Body, Bounds, CANVAS, Camera2d, CanvasRenderer, CanvasTexture, Collectable, Color, ColorLayer, Compositor, Container, Draggable, DraggableEntity, DropTarget, DroptargetEntity, Ellipse, Entity, GLShader, GUI_Object, ImageLayer, Light2d, Line, math as Math, Matrix2d, Matrix3d, NineSliceSprite, ObservableVector2d, ObservableVector3d, Particle, ParticleEmitter, ParticleEmitterSettings, Point, Pointer, Polygon, PrimitiveCompositor, QuadCompositor, QuadTree, Rect, Renderable, Renderer, RoundRect, Sprite, Stage, TMXHexagonalRenderer, TMXIsometricRenderer, TMXLayer, TMXOrthogonalRenderer, TMXRenderer, TMXStaggeredRenderer, TMXTileMap, TMXTileset, TMXTilesetGroup, TMXUtils, Text, TextureAtlas, Tile, Trigger, Tween, UIBaseElement, UISpriteElement, UITextButton, Vector2d, Vector3d, WEBGL, WebGLRenderer, World, audio, boot, collision, device, event, game, initialized, input, level, loader, plugin, cache as plugins, pool, save, skipAutoInit, state$1 as state, timer$1 as timer, utils, version, video };
|