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/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,
|
|
@@ -13996,34 +14020,10 @@ let renderer = null;
|
|
|
13996
14020
|
|
|
13997
14021
|
/**
|
|
13998
14022
|
* Initialize the "video" system (create a canvas based on the given arguments, and the related renderer). <br>
|
|
13999
|
-
* melonJS support various scaling mode, that can be enabled <u>once the scale option is set to <b>`auto`</b></u> : <br>
|
|
14000
|
-
* - <i><b>`fit`</b></i> : Letterboxed; content is scaled to design aspect ratio <br>
|
|
14001
|
-
* <center><img src="images/scale-fit.png"/></center><br>
|
|
14002
|
-
* - <i><b>`fill-min`</b></i> : Canvas is resized to fit minimum design resolution; content is scaled to design aspect ratio <br>
|
|
14003
|
-
* <center><img src="images/scale-fill-min.png"/></center><br>
|
|
14004
|
-
* - <i><b>`fill-max`</b></i> : Canvas is resized to fit maximum design resolution; content is scaled to design aspect ratio <br>
|
|
14005
|
-
* <center><img src="images/scale-fill-max.png"/></center><br>
|
|
14006
|
-
* - <i><b>`flex`</b><</i> : Canvas width & height is resized to fit; content is scaled to design aspect ratio <br>
|
|
14007
|
-
* <center><img src="images/scale-flex.png"/></center><br>
|
|
14008
|
-
* - <i><b>`flex-width`</b></i> : Canvas width is resized to fit; content is scaled to design aspect ratio <br>
|
|
14009
|
-
* <center><img src="images/scale-flex-width.png"/></center><br>
|
|
14010
|
-
* - <i><b>`flex-height`</b></i> : Canvas height is resized to fit; content is scaled to design aspect ratio <br>
|
|
14011
|
-
* <center><img src="images/scale-flex-height.png"/></center><br>
|
|
14012
|
-
* - <i><b>`stretch`</b></i> : Canvas is resized to fit; content is scaled to screen aspect ratio
|
|
14013
|
-
* <center><img src="images/scale-stretch.png"/></center><br>
|
|
14014
14023
|
* @memberof video
|
|
14015
14024
|
* @param {number} width - The width of the canvas viewport
|
|
14016
14025
|
* @param {number} height - The height of the canvas viewport
|
|
14017
|
-
* @param {
|
|
14018
|
-
* @param {string|HTMLElement} [options.parent=document.body] - the DOM parent element to hold the canvas in the HTML file
|
|
14019
|
-
* @param {number|Renderer} [options.renderer=video.AUTO] - renderer to use (me.video.CANVAS, me.video.WEBGL, me.video.AUTO), or a custom renderer class
|
|
14020
|
-
* @param {number|string} [options.scale=1.0] - enable scaling of the canvas ('auto' for automatic scaling)
|
|
14021
|
-
* @param {string} [options.scaleMethod="fit"] - screen scaling modes ('fit','fill-min','fill-max','flex','flex-width','flex-height','stretch')
|
|
14022
|
-
* @param {boolean} [options.preferWebGL1=false] - if true the renderer will only use WebGL 1
|
|
14023
|
-
* @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.
|
|
14024
|
-
* @param {boolean} [options.transparent=false] - whether to allow transparent pixels in the front buffer (screen).
|
|
14025
|
-
* @param {boolean} [options.antiAlias=false] - whether to enable or not video scaling interpolation
|
|
14026
|
-
* @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
|
|
14027
14027
|
* @returns {boolean} false if initialization failed (canvas not supported)
|
|
14028
14028
|
* @example
|
|
14029
14029
|
* // init the video with a 640x480 canvas
|
|
@@ -14525,6 +14525,7 @@ function hasOffscreenCanvas() {
|
|
|
14525
14525
|
|
|
14526
14526
|
/**
|
|
14527
14527
|
* used by [un]watchAccelerometer()
|
|
14528
|
+
* @ignore
|
|
14528
14529
|
*/
|
|
14529
14530
|
function onDeviceMotion(e) {
|
|
14530
14531
|
// Accelerometer information
|
|
@@ -14535,6 +14536,7 @@ function onDeviceMotion(e) {
|
|
|
14535
14536
|
|
|
14536
14537
|
/**
|
|
14537
14538
|
* used by [un]watchDeviceOrientation()
|
|
14539
|
+
* @ignore
|
|
14538
14540
|
*/
|
|
14539
14541
|
function onDeviceRotate(e) {
|
|
14540
14542
|
gamma = e.gamma;
|
|
@@ -17817,6 +17819,9 @@ var input = {
|
|
|
17817
17819
|
// viewport flag
|
|
17818
17820
|
this._inViewport = false;
|
|
17819
17821
|
|
|
17822
|
+
// renderable cache tint value used by the getter/setter
|
|
17823
|
+
this._tint = pool.pull("Color", 255, 255, 255, 1.0);
|
|
17824
|
+
|
|
17820
17825
|
// ensure it's fully opaque by default
|
|
17821
17826
|
this.setOpacity(1.0);
|
|
17822
17827
|
}
|
|
@@ -17841,21 +17846,11 @@ var input = {
|
|
|
17841
17846
|
* this.tint.setColor(255, 255, 255);
|
|
17842
17847
|
*/
|
|
17843
17848
|
get tint() {
|
|
17844
|
-
if (typeof this._tint === "undefined") {
|
|
17845
|
-
this._tint = pool.pull("Color", 255, 255, 255, 1.0);
|
|
17846
|
-
}
|
|
17847
17849
|
return this._tint;
|
|
17848
17850
|
}
|
|
17849
17851
|
set tint(value) {
|
|
17850
|
-
|
|
17851
|
-
|
|
17852
|
-
}
|
|
17853
|
-
if (value instanceof Color) {
|
|
17854
|
-
this._tint.copy(value);
|
|
17855
|
-
} else {
|
|
17856
|
-
// string (#RGB, #ARGB, #RRGGBB, #AARRGGBB)
|
|
17857
|
-
this._tint.parseCSS(value);
|
|
17858
|
-
}
|
|
17852
|
+
this._tint.copy(value);
|
|
17853
|
+
this.isDirty = true;
|
|
17859
17854
|
}
|
|
17860
17855
|
|
|
17861
17856
|
/**
|
|
@@ -19166,7 +19161,6 @@ let default_settings = {
|
|
|
19166
19161
|
* @ignore
|
|
19167
19162
|
*/
|
|
19168
19163
|
reset() {
|
|
19169
|
-
|
|
19170
19164
|
// add all defined cameras
|
|
19171
19165
|
this.settings.cameras.forEach((camera) => {
|
|
19172
19166
|
this.cameras.set(camera.name, camera);
|
|
@@ -19184,7 +19178,7 @@ let default_settings = {
|
|
|
19184
19178
|
}
|
|
19185
19179
|
|
|
19186
19180
|
// reset the game
|
|
19187
|
-
|
|
19181
|
+
emit(STAGE_RESET, this);
|
|
19188
19182
|
|
|
19189
19183
|
// call the onReset Function
|
|
19190
19184
|
this.onResetEvent.apply(this, arguments);
|
|
@@ -19199,8 +19193,7 @@ let default_settings = {
|
|
|
19199
19193
|
* @returns {boolean}
|
|
19200
19194
|
*/
|
|
19201
19195
|
update(dt) {
|
|
19202
|
-
|
|
19203
|
-
let isDirty = game.world.update(dt);
|
|
19196
|
+
let isDirty = false;
|
|
19204
19197
|
|
|
19205
19198
|
// update the camera/viewport
|
|
19206
19199
|
// iterate through all cameras
|
|
@@ -19225,13 +19218,15 @@ let default_settings = {
|
|
|
19225
19218
|
* @name draw
|
|
19226
19219
|
* @memberof Stage
|
|
19227
19220
|
* @ignore
|
|
19228
|
-
* @param {
|
|
19221
|
+
* @param {Renderer} renderer - the renderer object to draw with
|
|
19222
|
+
* @param {World} world - the world object to draw
|
|
19229
19223
|
*/
|
|
19230
|
-
draw(renderer) {
|
|
19224
|
+
draw(renderer, world) {
|
|
19225
|
+
|
|
19231
19226
|
// iterate through all cameras
|
|
19232
19227
|
this.cameras.forEach((camera) => {
|
|
19233
19228
|
// render the root container
|
|
19234
|
-
camera.draw(renderer,
|
|
19229
|
+
camera.draw(renderer, world);
|
|
19235
19230
|
|
|
19236
19231
|
// render the ambient light
|
|
19237
19232
|
if (this.ambientLight.alpha !== 0) {
|
|
@@ -19251,9 +19246,9 @@ let default_settings = {
|
|
|
19251
19246
|
|
|
19252
19247
|
// render all lights
|
|
19253
19248
|
this.lights.forEach((light) => {
|
|
19254
|
-
light.preDraw(renderer,
|
|
19255
|
-
light.draw(renderer,
|
|
19256
|
-
light.postDraw(renderer,
|
|
19249
|
+
light.preDraw(renderer, world);
|
|
19250
|
+
light.draw(renderer, world);
|
|
19251
|
+
light.postDraw(renderer, world);
|
|
19257
19252
|
});
|
|
19258
19253
|
});
|
|
19259
19254
|
}
|
|
@@ -19288,7 +19283,6 @@ let default_settings = {
|
|
|
19288
19283
|
if (typeof this.settings.onResetEvent === "function") {
|
|
19289
19284
|
this.settings.onResetEvent.apply(this, arguments);
|
|
19290
19285
|
}
|
|
19291
|
-
|
|
19292
19286
|
}
|
|
19293
19287
|
|
|
19294
19288
|
/**
|
|
@@ -19848,12 +19842,6 @@ const COLLISION_GROUP = "collision";
|
|
|
19848
19842
|
}
|
|
19849
19843
|
}
|
|
19850
19844
|
|
|
19851
|
-
/**
|
|
19852
|
-
* a collection of utility functions for parsing TMX maps
|
|
19853
|
-
* @namespace TMXUtils
|
|
19854
|
-
*/
|
|
19855
|
-
|
|
19856
|
-
|
|
19857
19845
|
/**
|
|
19858
19846
|
* the function used to decompress zlib/gzip data
|
|
19859
19847
|
* @ignore
|
|
@@ -20087,11 +20075,14 @@ function normalize(obj, item) {
|
|
|
20087
20075
|
}
|
|
20088
20076
|
}
|
|
20089
20077
|
|
|
20078
|
+
/**
|
|
20079
|
+
* a collection of utility functions for parsing TMX maps
|
|
20080
|
+
* @namespace TMXUtils
|
|
20081
|
+
*/
|
|
20090
20082
|
|
|
20091
20083
|
/**
|
|
20092
20084
|
* decompress and decode zlib/gzip data
|
|
20093
|
-
* @
|
|
20094
|
-
* @memberOf TMXUtils
|
|
20085
|
+
* @memberof TMXUtils
|
|
20095
20086
|
* @param {string} input - Base64 encoded and compressed data
|
|
20096
20087
|
* @param {string} format - compressed data format ("gzip","zlib", "zstd")
|
|
20097
20088
|
* @returns {Uint32Array} Decoded and decompress data
|
|
@@ -20106,8 +20097,7 @@ function decompress(data, format) {
|
|
|
20106
20097
|
|
|
20107
20098
|
/**
|
|
20108
20099
|
* Decode a CSV encoded array into a binary array
|
|
20109
|
-
* @
|
|
20110
|
-
* @memberOf TMXUtils
|
|
20100
|
+
* @memberof TMXUtils
|
|
20111
20101
|
* @param {string} input- - CSV formatted data (only numbers, everything else will be converted to NaN)
|
|
20112
20102
|
* @returns {number[]} Decoded data
|
|
20113
20103
|
*/
|
|
@@ -20123,8 +20113,7 @@ function decodeCSV(input) {
|
|
|
20123
20113
|
|
|
20124
20114
|
/**
|
|
20125
20115
|
* Decode a base64 encoded string into a byte array
|
|
20126
|
-
* @
|
|
20127
|
-
* @memberOf TMXUtils
|
|
20116
|
+
* @memberof TMXUtils
|
|
20128
20117
|
* @param {string} input - Base64 encoded data
|
|
20129
20118
|
* @param {number} [bytes] - number of bytes per array entry
|
|
20130
20119
|
* @returns {Uint32Array} Decoded data
|
|
@@ -20147,6 +20136,7 @@ function decodeBase64AsArray(input, bytes) {
|
|
|
20147
20136
|
|
|
20148
20137
|
/**
|
|
20149
20138
|
* set the function used to inflate gzip/zlib data
|
|
20139
|
+
* @memberof TMXUtils
|
|
20150
20140
|
* @param {Func} fn - inflate function
|
|
20151
20141
|
*/
|
|
20152
20142
|
function setInflateFunction(fn) {
|
|
@@ -20155,8 +20145,7 @@ function setInflateFunction(fn) {
|
|
|
20155
20145
|
|
|
20156
20146
|
/**
|
|
20157
20147
|
* Decode a encoded array into a binary array
|
|
20158
|
-
* @
|
|
20159
|
-
* @memberOf TMXUtils
|
|
20148
|
+
* @memberof TMXUtils
|
|
20160
20149
|
* @param {string} data - data to be decoded
|
|
20161
20150
|
* @param {string} [encoding="none"] - data encoding ("csv", "base64", "xml")
|
|
20162
20151
|
* @returns {number[]} Decoded data
|
|
@@ -20190,8 +20179,7 @@ function decode(data, encoding, compression) {
|
|
|
20190
20179
|
|
|
20191
20180
|
/**
|
|
20192
20181
|
* Parse a XML TMX object and returns the corresponding javascript object
|
|
20193
|
-
* @
|
|
20194
|
-
* @memberOf TMXUtils
|
|
20182
|
+
* @memberof TMXUtils
|
|
20195
20183
|
* @param {Document} xml - XML TMX object
|
|
20196
20184
|
* @returns {object} Javascript object
|
|
20197
20185
|
*/
|
|
@@ -20231,8 +20219,7 @@ function parse(xml) {
|
|
|
20231
20219
|
|
|
20232
20220
|
/**
|
|
20233
20221
|
* Apply TMX Properties to the given object
|
|
20234
|
-
* @
|
|
20235
|
-
* @memberOf TMXUtils
|
|
20222
|
+
* @memberof TMXUtils
|
|
20236
20223
|
* @param {object} obj - object to apply the properties to
|
|
20237
20224
|
* @param {object} data - TMX data object
|
|
20238
20225
|
* @returns {object} obj
|
|
@@ -21004,20 +20991,7 @@ class TMXObject {
|
|
|
21004
20991
|
*/
|
|
21005
20992
|
class Renderer {
|
|
21006
20993
|
/**
|
|
21007
|
-
* @param {
|
|
21008
|
-
* @param {number} options.width - The width of the canvas without scaling
|
|
21009
|
-
* @param {number} options.height - The height of the canvas without scaling
|
|
21010
|
-
* @param {HTMLCanvasElement} [options.canvas] - The html canvas to draw to on screen
|
|
21011
|
-
* @param {boolean} [options.antiAlias=false] - Whether to enable anti-aliasing, use false (default) for a pixelated effect.
|
|
21012
|
-
* @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.
|
|
21013
|
-
* @param {boolean} [options.transparent=false] - Whether to enable transparency on the canvas
|
|
21014
|
-
* @param {boolean} [options.premultipliedAlpha=true] - in WebGL, whether the renderer will assume that colors have premultiplied alpha when canvas transparency is enabled
|
|
21015
|
-
* @param {boolean} [options.blendMode="normal"] - the default blend mode to use ("normal", "multiply")
|
|
21016
|
-
* @param {boolean} [options.depthBuffer="sorting"] - ~Experimental~ the default method to sort object on the z axis in WebGL ("sorting", "z-buffer")
|
|
21017
|
-
* @param {boolean} [options.subPixel=false] - Whether to enable subpixel rendering (performance hit when enabled)
|
|
21018
|
-
* @param {boolean} [options.verbose=false] - Enable the verbose mode that provides additional details as to what the renderer is doing
|
|
21019
|
-
* @param {number} [options.zoomX=width] - The actual width of the canvas with scaling applied
|
|
21020
|
-
* @param {number} [options.zoomY=height] - The actual height of the canvas with scaling applied
|
|
20994
|
+
* @param {Application.Settings} [options] - optional parameters for the renderer
|
|
21021
20995
|
*/
|
|
21022
20996
|
constructor(options) {
|
|
21023
20997
|
/**
|
|
@@ -22281,16 +22255,7 @@ class TextureCache {
|
|
|
22281
22255
|
*/
|
|
22282
22256
|
class CanvasRenderer extends Renderer {
|
|
22283
22257
|
/**
|
|
22284
|
-
* @param {
|
|
22285
|
-
* @param {number} options.width - The width of the canvas without scaling
|
|
22286
|
-
* @param {number} options.height - The height of the canvas without scaling
|
|
22287
|
-
* @param {HTMLCanvasElement} [options.canvas] - The html canvas to draw to on screen
|
|
22288
|
-
* @param {boolean} [options.antiAlias=false] - Whether to enable anti-aliasing
|
|
22289
|
-
* @param {boolean} [options.transparent=false] - Whether to enable transparency on the canvas (performance hit when enabled)
|
|
22290
|
-
* @param {boolean} [options.subPixel=false] - Whether to enable subpixel renderering (performance hit when enabled)
|
|
22291
|
-
* @param {boolean} [options.textureSeamFix=true] - enable the texture seam fix when rendering Tile when antiAlias is off for the canvasRenderer
|
|
22292
|
-
* @param {number} [options.zoomX=width] - The actual width of the canvas with scaling applied
|
|
22293
|
-
* @param {number} [options.zoomY=height] - The actual height of the canvas with scaling applied
|
|
22258
|
+
* @param {Application.Settings} [options] - optional parameters for the renderer
|
|
22294
22259
|
*/
|
|
22295
22260
|
constructor(options) {
|
|
22296
22261
|
// parent constructor
|
|
@@ -27896,11 +27861,7 @@ function _pauseRunLoop() {
|
|
|
27896
27861
|
* @ignore
|
|
27897
27862
|
*/
|
|
27898
27863
|
function _renderFrame(time) {
|
|
27899
|
-
|
|
27900
|
-
// update all game objects
|
|
27901
|
-
game.update(time, stage);
|
|
27902
|
-
// render all game objects
|
|
27903
|
-
game.draw(stage);
|
|
27864
|
+
emit(TICK, time);
|
|
27904
27865
|
// schedule the next frame update
|
|
27905
27866
|
if (_animFrameId !== -1) {
|
|
27906
27867
|
_animFrameId = globalThis.requestAnimationFrame(_renderFrame);
|
|
@@ -27949,9 +27910,6 @@ function _switchState(state) {
|
|
|
27949
27910
|
if (_onSwitchComplete) {
|
|
27950
27911
|
_onSwitchComplete();
|
|
27951
27912
|
}
|
|
27952
|
-
|
|
27953
|
-
// force repaint
|
|
27954
|
-
game.repaint();
|
|
27955
27913
|
}
|
|
27956
27914
|
}
|
|
27957
27915
|
|
|
@@ -28097,7 +28055,7 @@ let state = {
|
|
|
28097
28055
|
* default state ID for the default Stage
|
|
28098
28056
|
* (the default stage is the one running as soon as melonJS is started)
|
|
28099
28057
|
* @constant
|
|
28100
|
-
* @name
|
|
28058
|
+
* @name DEFAULT
|
|
28101
28059
|
* @memberof state
|
|
28102
28060
|
*/
|
|
28103
28061
|
DEFAULT : 9,
|
|
@@ -28185,9 +28143,6 @@ let state = {
|
|
|
28185
28143
|
// calculate the elpased time
|
|
28186
28144
|
_pauseTime = globalThis.performance.now() - _pauseTime;
|
|
28187
28145
|
|
|
28188
|
-
// force repaint
|
|
28189
|
-
game.repaint();
|
|
28190
|
-
|
|
28191
28146
|
// publish the restart notification
|
|
28192
28147
|
emit(STATE_RESTART, _pauseTime);
|
|
28193
28148
|
}
|
|
@@ -31322,21 +31277,7 @@ let V_ARRAY = [
|
|
|
31322
31277
|
*/
|
|
31323
31278
|
class WebGLRenderer extends Renderer {
|
|
31324
31279
|
/**
|
|
31325
|
-
* @param {
|
|
31326
|
-
* @param {number} options.width - The width of the canvas without scaling
|
|
31327
|
-
* @param {number} options.height - The height of the canvas without scaling
|
|
31328
|
-
* @param {HTMLCanvasElement} [options.canvas] - The html canvas to draw to on screen
|
|
31329
|
-
* @param {boolean} [options.antiAlias=false] - Whether to enable anti-aliasing
|
|
31330
|
-
* @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.
|
|
31331
|
-
* @param {boolean} [options.transparent=false] - Whether to enable transparency on the canvas
|
|
31332
|
-
* @param {boolean} [options.premultipliedAlpha=true] - in WebGL, whether the renderer will assume that colors have premultiplied alpha when canvas transparency is enabled
|
|
31333
|
-
* @param {boolean} [options.subPixel=false] - Whether to enable subpixel renderering (performance hit when enabled)
|
|
31334
|
-
* @param {boolean} [options.preferWebGL1=false] - if true the renderer will only use WebGL 1
|
|
31335
|
-
* @param {boolean} [options.depthTest="sorting"] - ~Experimental~ the default method to sort object on the z axis in WebGL ("sorting", "z-buffer")
|
|
31336
|
-
* @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.
|
|
31337
|
-
* @param {number} [options.zoomX=width] - The actual width of the canvas with scaling applied
|
|
31338
|
-
* @param {number} [options.zoomY=height] - The actual height of the canvas with scaling applied
|
|
31339
|
-
* @param {Compositor} [options.compositor] - A class that implements the compositor API for sprite rendering
|
|
31280
|
+
* @param {Application.Settings} [options] - optional parameters for the renderer
|
|
31340
31281
|
*/
|
|
31341
31282
|
constructor(options) {
|
|
31342
31283
|
// parent contructor
|
|
@@ -31507,6 +31448,17 @@ let V_ARRAY = [
|
|
|
31507
31448
|
reset() {
|
|
31508
31449
|
super.reset();
|
|
31509
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
|
+
|
|
31510
31462
|
// clear gl context
|
|
31511
31463
|
this.clear();
|
|
31512
31464
|
|
|
@@ -37534,6 +37486,7 @@ function onresize(game) {
|
|
|
37534
37486
|
let renderer = game.renderer;
|
|
37535
37487
|
let settings = renderer.settings;
|
|
37536
37488
|
let scaleX = 1, scaleY = 1;
|
|
37489
|
+
let nodeBounds;
|
|
37537
37490
|
|
|
37538
37491
|
if (settings.autoScale) {
|
|
37539
37492
|
|
|
@@ -37547,8 +37500,13 @@ function onresize(game) {
|
|
|
37547
37500
|
canvasMaxHeight = parseInt(style.maxHeight, 10) || Infinity;
|
|
37548
37501
|
}
|
|
37549
37502
|
|
|
37550
|
-
|
|
37551
|
-
|
|
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
|
+
}
|
|
37552
37510
|
|
|
37553
37511
|
let _max_width = Math.min(canvasMaxWidth, nodeBounds.width);
|
|
37554
37512
|
let _max_height = Math.min(canvasMaxHeight, nodeBounds.height);
|
|
@@ -37609,6 +37567,7 @@ const defaultSettings = {
|
|
|
37609
37567
|
autoScale : false,
|
|
37610
37568
|
scale : 1.0,
|
|
37611
37569
|
scaleMethod : "manual",
|
|
37570
|
+
scaleTarget : undefined,
|
|
37612
37571
|
transparent : false,
|
|
37613
37572
|
premultipliedAlpha: true,
|
|
37614
37573
|
blendMode : "normal",
|
|
@@ -37622,6 +37581,41 @@ const defaultSettings = {
|
|
|
37622
37581
|
legacy : false
|
|
37623
37582
|
};
|
|
37624
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
|
+
|
|
37625
37619
|
/**
|
|
37626
37620
|
* display information
|
|
37627
37621
|
* @param {Application} game - the game application instance calling this function
|
|
@@ -37657,17 +37651,7 @@ function consoleHeader(app) {
|
|
|
37657
37651
|
/**
|
|
37658
37652
|
* @param {number} width - The width of the canvas viewport
|
|
37659
37653
|
* @param {number} height - The height of the canvas viewport
|
|
37660
|
-
* @param {
|
|
37661
|
-
* @param {string|HTMLElement} [options.parent=document.body] - the DOM parent element to hold the canvas in the HTML file
|
|
37662
|
-
* @param {number|Renderer} [options.renderer=AUTO] - renderer to use (CANVAS, WEBGL, AUTO), or a custom renderer class
|
|
37663
|
-
* @param {number|string} [options.scale=1.0] - enable scaling of the canvas ('auto' for automatic scaling)
|
|
37664
|
-
* @param {string} [options.scaleMethod="fit"] - screen scaling modes ('fit','fill-min','fill-max','flex','flex-width','flex-height','stretch')
|
|
37665
|
-
* @param {boolean} [options.preferWebGL1=false] - if true the renderer will only use WebGL 1
|
|
37666
|
-
* @param {boolean} [options.depthTest="sorting"] - ~Experimental~ the default method to sort object on the z axis in WebGL ("sorting", "z-buffer")
|
|
37667
|
-
* @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.
|
|
37668
|
-
* @param {boolean} [options.transparent=false] - whether to allow transparent pixels in the front buffer (screen).
|
|
37669
|
-
* @param {boolean} [options.antiAlias=false] - whether to enable or not video scaling interpolation
|
|
37670
|
-
* @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
|
|
37671
37655
|
* @throws Will throw an exception if it fails to instantiate a renderer
|
|
37672
37656
|
* @example
|
|
37673
37657
|
* let my game = new Application(640, 480, {renderer: me.video.AUTO}) {
|
|
@@ -37802,6 +37786,12 @@ function consoleHeader(app) {
|
|
|
37802
37786
|
this.settings.zoomX = width * this.settings.scale;
|
|
37803
37787
|
this.settings.zoomY = height * this.settings.scale;
|
|
37804
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
|
+
|
|
37805
37795
|
if (typeof this.settings.renderer === "number") {
|
|
37806
37796
|
switch (this.settings.renderer) {
|
|
37807
37797
|
case AUTO:
|
|
@@ -37823,7 +37813,6 @@ function consoleHeader(app) {
|
|
|
37823
37813
|
on(WINDOW_ONORIENTATION_CHANGE, () => onresize(this), this);
|
|
37824
37814
|
|
|
37825
37815
|
// add our canvas (default to document.body if settings.parent is undefined)
|
|
37826
|
-
this.parentElement = getElement(this.settings.parent);
|
|
37827
37816
|
this.parentElement.appendChild(this.renderer.getCanvas());
|
|
37828
37817
|
|
|
37829
37818
|
// Mobile browser hacks
|
|
@@ -37862,6 +37851,16 @@ function consoleHeader(app) {
|
|
|
37862
37851
|
this.isInitialized = true;
|
|
37863
37852
|
|
|
37864
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);
|
|
37865
37864
|
}
|
|
37866
37865
|
|
|
37867
37866
|
/**
|
|
@@ -37942,9 +37941,8 @@ function consoleHeader(app) {
|
|
|
37942
37941
|
/**
|
|
37943
37942
|
* update all objects related to this game active scene/stage
|
|
37944
37943
|
* @param {number} time - current timestamp as provided by the RAF callback
|
|
37945
|
-
* @param {Stage} stage - the current stage
|
|
37946
37944
|
*/
|
|
37947
|
-
update(time
|
|
37945
|
+
update(time) {
|
|
37948
37946
|
// handle frame skipping if required
|
|
37949
37947
|
if ((++this.frameCounter % this.frameRate) === 0) {
|
|
37950
37948
|
// reset the frame counter
|
|
@@ -37968,7 +37966,8 @@ function consoleHeader(app) {
|
|
|
37968
37966
|
}
|
|
37969
37967
|
|
|
37970
37968
|
// update all objects (and pass the elapsed time since last frame)
|
|
37971
|
-
this.isDirty =
|
|
37969
|
+
this.isDirty = this.world.update(this.updateDelta);
|
|
37970
|
+
this.isDirty = state$1.current().update(this.updateDelta) || this.isDirty;
|
|
37972
37971
|
|
|
37973
37972
|
this.lastUpdate = globalThis.performance.now();
|
|
37974
37973
|
this.updateAverageDelta = this.lastUpdate - this.lastUpdateStart;
|
|
@@ -37987,9 +37986,8 @@ function consoleHeader(app) {
|
|
|
37987
37986
|
|
|
37988
37987
|
/**
|
|
37989
37988
|
* draw the active scene/stage associated to this game
|
|
37990
|
-
* @param {Stage} stage - the current stage
|
|
37991
37989
|
*/
|
|
37992
|
-
draw(
|
|
37990
|
+
draw() {
|
|
37993
37991
|
if (this.renderer.isContextValid === true && (this.isDirty || this.isAlwaysDirty)) {
|
|
37994
37992
|
// publish notification
|
|
37995
37993
|
emit(GAME_BEFORE_DRAW, globalThis.performance.now());
|
|
@@ -37998,7 +37996,7 @@ function consoleHeader(app) {
|
|
|
37998
37996
|
this.renderer.clear();
|
|
37999
37997
|
|
|
38000
37998
|
// render the stage
|
|
38001
|
-
|
|
37999
|
+
state$1.current().draw(this.renderer, this.world);
|
|
38002
38000
|
|
|
38003
38001
|
// set back to flag
|
|
38004
38002
|
this.isDirty = false;
|
|
@@ -38037,9 +38035,9 @@ class BasePlugin {
|
|
|
38037
38035
|
* define the minimum required version of melonJS<br>
|
|
38038
38036
|
* this can be overridden by the plugin
|
|
38039
38037
|
* @type {string}
|
|
38040
|
-
* @default "15.
|
|
38038
|
+
* @default "15.3.0"
|
|
38041
38039
|
*/
|
|
38042
|
-
this.version = "15.
|
|
38040
|
+
this.version = "15.3.0";
|
|
38043
38041
|
}
|
|
38044
38042
|
}
|
|
38045
38043
|
|
|
@@ -38266,7 +38264,7 @@ Renderer.prototype.getScreenContext = function() {
|
|
|
38266
38264
|
* @name version
|
|
38267
38265
|
* @type {string}
|
|
38268
38266
|
*/
|
|
38269
|
-
const version = "15.
|
|
38267
|
+
const version = "15.3.0";
|
|
38270
38268
|
|
|
38271
38269
|
/**
|
|
38272
38270
|
* a flag indicating that melonJS is fully initialized
|
|
@@ -8,35 +8,14 @@ export default class Application {
|
|
|
8
8
|
/**
|
|
9
9
|
* @param {number} width - The width of the canvas viewport
|
|
10
10
|
* @param {number} height - The height of the canvas viewport
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {string|HTMLElement} [options.parent=document.body] - the DOM parent element to hold the canvas in the HTML file
|
|
13
|
-
* @param {number|Renderer} [options.renderer=AUTO] - renderer to use (CANVAS, WEBGL, AUTO), or a custom renderer class
|
|
14
|
-
* @param {number|string} [options.scale=1.0] - enable scaling of the canvas ('auto' for automatic scaling)
|
|
15
|
-
* @param {string} [options.scaleMethod="fit"] - screen scaling modes ('fit','fill-min','fill-max','flex','flex-width','flex-height','stretch')
|
|
16
|
-
* @param {boolean} [options.preferWebGL1=false] - if true the renderer will only use WebGL 1
|
|
17
|
-
* @param {boolean} [options.depthTest="sorting"] - ~Experimental~ the default method to sort object on the z axis in WebGL ("sorting", "z-buffer")
|
|
18
|
-
* @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.
|
|
19
|
-
* @param {boolean} [options.transparent=false] - whether to allow transparent pixels in the front buffer (screen).
|
|
20
|
-
* @param {boolean} [options.antiAlias=false] - whether to enable or not video scaling interpolation
|
|
21
|
-
* @param {boolean} [options.consoleHeader=true] - whether to display melonJS version and basic device information in the console
|
|
11
|
+
* @param {Application.Settings} [options] - The optional parameters for the application and default renderer
|
|
22
12
|
* @throws Will throw an exception if it fails to instantiate a renderer
|
|
23
13
|
* @example
|
|
24
14
|
* let my game = new Application(640, 480, {renderer: me.video.AUTO}) {
|
|
25
15
|
* ....
|
|
26
16
|
* }
|
|
27
17
|
*/
|
|
28
|
-
constructor(width: number, height: number, options?:
|
|
29
|
-
parent?: string | HTMLElement | undefined;
|
|
30
|
-
renderer?: number | Renderer;
|
|
31
|
-
scale?: string | number | undefined;
|
|
32
|
-
scaleMethod?: string | undefined;
|
|
33
|
-
preferWebGL1?: boolean | undefined;
|
|
34
|
-
depthTest?: boolean | undefined;
|
|
35
|
-
powerPreference?: string | undefined;
|
|
36
|
-
transparent?: boolean | undefined;
|
|
37
|
-
antiAlias?: boolean | undefined;
|
|
38
|
-
consoleHeader?: boolean | undefined;
|
|
39
|
-
} | undefined);
|
|
18
|
+
constructor(width: number, height: number, options?: any);
|
|
40
19
|
/**
|
|
41
20
|
* the parent HTML element holding the main canvas of this application
|
|
42
21
|
* @type {HTMLElement}
|
|
@@ -138,14 +117,12 @@ export default class Application {
|
|
|
138
117
|
/**
|
|
139
118
|
* update all objects related to this game active scene/stage
|
|
140
119
|
* @param {number} time - current timestamp as provided by the RAF callback
|
|
141
|
-
* @param {Stage} stage - the current stage
|
|
142
120
|
*/
|
|
143
|
-
update(time: number
|
|
121
|
+
update(time: number): void;
|
|
144
122
|
/**
|
|
145
123
|
* draw the active scene/stage associated to this game
|
|
146
|
-
* @param {Stage} stage - the current stage
|
|
147
124
|
*/
|
|
148
|
-
draw(
|
|
125
|
+
draw(): void;
|
|
149
126
|
}
|
|
150
127
|
import CanvasRenderer from "./../video/canvas/canvas_renderer.js";
|
|
151
128
|
import World from "./../physics/world.js";
|