melonjs 10.12.0 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/melonjs.js +116 -72
- package/dist/melonjs.min.js +3 -3
- package/dist/melonjs.module.d.ts +11 -4
- package/dist/melonjs.module.js +117 -73
- package/package.json +4 -4
- package/src/renderable/light2d.js +40 -11
- package/src/system/device.js +3 -67
- package/src/system/dom.js +69 -0
- package/src/system/event.js +11 -0
package/dist/melonjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine -
|
|
2
|
+
* melonJS Game Engine - v11.0.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
|
|
@@ -315,10 +315,10 @@
|
|
|
315
315
|
(shared$3.exports = function (key, value) {
|
|
316
316
|
return store$2[key] || (store$2[key] = value !== undefined ? value : {});
|
|
317
317
|
})('versions', []).push({
|
|
318
|
-
version: '3.23.
|
|
318
|
+
version: '3.23.2',
|
|
319
319
|
mode: 'global',
|
|
320
320
|
copyright: '© 2014-2022 Denis Pushkarev (zloirock.ru)',
|
|
321
|
-
license: 'https://github.com/zloirock/core-js/blob/v3.23.
|
|
321
|
+
license: 'https://github.com/zloirock/core-js/blob/v3.23.2/LICENSE',
|
|
322
322
|
source: 'https://github.com/zloirock/core-js'
|
|
323
323
|
});
|
|
324
324
|
|
|
@@ -4379,6 +4379,17 @@
|
|
|
4379
4379
|
// internal instance of the event emiter
|
|
4380
4380
|
var eventEmitter = new EventEmitter();
|
|
4381
4381
|
|
|
4382
|
+
/**
|
|
4383
|
+
* event when the DOM is Ready is booting
|
|
4384
|
+
* @public
|
|
4385
|
+
* @constant
|
|
4386
|
+
* @type {string}
|
|
4387
|
+
* @name DOM_READY
|
|
4388
|
+
* @memberof event
|
|
4389
|
+
* @see event.on
|
|
4390
|
+
*/
|
|
4391
|
+
var DOM_READY = "dom_ready";
|
|
4392
|
+
|
|
4382
4393
|
/**
|
|
4383
4394
|
* event when the system is booting
|
|
4384
4395
|
* @public
|
|
@@ -4888,6 +4899,7 @@
|
|
|
4888
4899
|
|
|
4889
4900
|
var event = /*#__PURE__*/Object.freeze({
|
|
4890
4901
|
__proto__: null,
|
|
4902
|
+
DOM_READY: DOM_READY,
|
|
4891
4903
|
BOOT: BOOT,
|
|
4892
4904
|
STATE_PAUSE: STATE_PAUSE,
|
|
4893
4905
|
STATE_RESUME: STATE_RESUME,
|
|
@@ -28450,33 +28462,17 @@
|
|
|
28450
28462
|
}
|
|
28451
28463
|
};
|
|
28452
28464
|
|
|
28453
|
-
//
|
|
28454
|
-
var
|
|
28455
|
-
var deviceOrientationInitialized = false;
|
|
28465
|
+
// track if DOMContentLoaded was called already
|
|
28466
|
+
var readyBound = false;
|
|
28456
28467
|
|
|
28457
|
-
//
|
|
28458
|
-
var
|
|
28468
|
+
// is the DOM ready ?
|
|
28469
|
+
var isDOMReady = false;
|
|
28459
28470
|
|
|
28460
|
-
|
|
28461
|
-
* @ignore
|
|
28462
|
-
*/
|
|
28463
|
-
function _disableSwipeFn(e) {
|
|
28464
|
-
e.preventDefault();
|
|
28465
|
-
if (typeof globalThis.scroll === "function") {
|
|
28466
|
-
globalThis.scroll(0, 0);
|
|
28467
|
-
}
|
|
28468
|
-
return false;
|
|
28469
|
-
}
|
|
28470
|
-
// DOM loading stuff
|
|
28471
|
-
var readyBound = false, isReady = false, readyList = [];
|
|
28472
|
-
|
|
28473
|
-
/**
|
|
28474
|
-
* // called to check if the device is ready
|
|
28475
|
-
* @ignore
|
|
28476
|
-
*/
|
|
28471
|
+
// check if the dom is ready
|
|
28477
28472
|
function _domReady() {
|
|
28473
|
+
|
|
28478
28474
|
// Make sure that the DOM is not already loaded
|
|
28479
|
-
if (!
|
|
28475
|
+
if (!isDOMReady) {
|
|
28480
28476
|
// be sure document.body is there
|
|
28481
28477
|
if (typeof globalThis.document !== "undefined" && !globalThis.document.body) {
|
|
28482
28478
|
return setTimeout(_domReady, 13);
|
|
@@ -28486,7 +28482,7 @@
|
|
|
28486
28482
|
if (typeof globalThis.document !== "undefined" && typeof globalThis.document.removeEventListener === "function") {
|
|
28487
28483
|
globalThis.document.removeEventListener(
|
|
28488
28484
|
"DOMContentLoaded",
|
|
28489
|
-
|
|
28485
|
+
_domReady,
|
|
28490
28486
|
false
|
|
28491
28487
|
);
|
|
28492
28488
|
}
|
|
@@ -28497,13 +28493,58 @@
|
|
|
28497
28493
|
}
|
|
28498
28494
|
|
|
28499
28495
|
// execute all callbacks
|
|
28500
|
-
|
|
28501
|
-
readyList.shift().call(globalThis, []);
|
|
28502
|
-
}
|
|
28496
|
+
emit(DOM_READY);
|
|
28503
28497
|
|
|
28504
28498
|
// Remember that the DOM is ready
|
|
28505
|
-
|
|
28499
|
+
isDOMReady = true;
|
|
28500
|
+
}
|
|
28501
|
+
}
|
|
28502
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Window/DOMContentLoaded_event
|
|
28503
|
+
function DOMContentLoaded(fn) {
|
|
28504
|
+
// If the DOM is already ready
|
|
28505
|
+
if (isDOMReady) {
|
|
28506
|
+
// Execute the function immediately
|
|
28507
|
+
fn.call(globalThis, []);
|
|
28508
|
+
}
|
|
28509
|
+
else {
|
|
28510
|
+
// else add the function to the DOM_READY event
|
|
28511
|
+
once(DOM_READY, fn, globalThis);
|
|
28512
|
+
// bind dom load event if not done yet
|
|
28513
|
+
if (!readyBound) {
|
|
28514
|
+
// directly call domReady if document is already "ready"
|
|
28515
|
+
if (((typeof process !== "undefined") && (process.release.name === "node")) || (typeof globalThis.document !== "undefined" && globalThis.document.readyState === "complete")) {
|
|
28516
|
+
// defer the fn call to ensure our script is fully loaded
|
|
28517
|
+
globalThis.setTimeout(_domReady, 0);
|
|
28518
|
+
}
|
|
28519
|
+
else {
|
|
28520
|
+
if (typeof globalThis.document !== "undefined" && typeof globalThis.document.addEventListener === "function") {
|
|
28521
|
+
// Use the handy event callback
|
|
28522
|
+
globalThis.document.addEventListener("DOMContentLoaded", _domReady, false);
|
|
28523
|
+
}
|
|
28524
|
+
// A fallback to globalThis.onload, that will always work
|
|
28525
|
+
globalThis.addEventListener("load", _domReady, false);
|
|
28526
|
+
}
|
|
28527
|
+
readyBound = true;
|
|
28528
|
+
}
|
|
28529
|
+
}
|
|
28530
|
+
}
|
|
28531
|
+
|
|
28532
|
+
// private properties
|
|
28533
|
+
var accelInitialized = false;
|
|
28534
|
+
var deviceOrientationInitialized = false;
|
|
28535
|
+
|
|
28536
|
+
// swipe utility fn & flag
|
|
28537
|
+
var swipeEnabled = true;
|
|
28538
|
+
|
|
28539
|
+
/**
|
|
28540
|
+
* @ignore
|
|
28541
|
+
*/
|
|
28542
|
+
function _disableSwipeFn(e) {
|
|
28543
|
+
e.preventDefault();
|
|
28544
|
+
if (typeof globalThis.scroll === "function") {
|
|
28545
|
+
globalThis.scroll(0, 0);
|
|
28506
28546
|
}
|
|
28547
|
+
return false;
|
|
28507
28548
|
}
|
|
28508
28549
|
// a cache DOMRect object
|
|
28509
28550
|
var _domRect = {left: 0, top: 0, x: 0, y: 0, width: 0, height: 0, right: 0, bottom: 0};
|
|
@@ -28859,7 +28900,7 @@
|
|
|
28859
28900
|
* @readonly
|
|
28860
28901
|
* @name nodeJS
|
|
28861
28902
|
*/
|
|
28862
|
-
nodeJS : (typeof process !== "undefined") && (process.release.name === "node"),
|
|
28903
|
+
nodeJS : (typeof globalThis.process !== "undefined") && (typeof globalThis.process.release !== "undefined") && (globalThis.process.release.name === "node"),
|
|
28863
28904
|
|
|
28864
28905
|
/**
|
|
28865
28906
|
* equals to true if the device is running on ChromeOS.
|
|
@@ -29047,33 +29088,7 @@
|
|
|
29047
29088
|
* });
|
|
29048
29089
|
*/
|
|
29049
29090
|
onReady: function onReady(fn) {
|
|
29050
|
-
|
|
29051
|
-
if (isReady) {
|
|
29052
|
-
// Execute the function immediately
|
|
29053
|
-
fn.call(globalThis, []);
|
|
29054
|
-
}
|
|
29055
|
-
else {
|
|
29056
|
-
// Add the function to the wait list
|
|
29057
|
-
readyList.push(fn);
|
|
29058
|
-
|
|
29059
|
-
// attach listeners if not yet done
|
|
29060
|
-
if (!readyBound) {
|
|
29061
|
-
// directly call domReady if document is already "ready"
|
|
29062
|
-
if (device.nodeJS === true || (typeof globalThis.document !== "undefined" && globalThis.document.readyState === "complete")) {
|
|
29063
|
-
// defer the fn call to ensure our script is fully loaded
|
|
29064
|
-
globalThis.setTimeout(_domReady, 0);
|
|
29065
|
-
}
|
|
29066
|
-
else {
|
|
29067
|
-
if (typeof globalThis.document !== "undefined" && typeof globalThis.document.addEventListener === "function") {
|
|
29068
|
-
// Use the handy event callback
|
|
29069
|
-
globalThis.document.addEventListener("DOMContentLoaded", _domReady, false);
|
|
29070
|
-
}
|
|
29071
|
-
// A fallback to globalThis.onload, that will always work
|
|
29072
|
-
globalThis.addEventListener("load", _domReady, false);
|
|
29073
|
-
}
|
|
29074
|
-
readyBound = true;
|
|
29075
|
-
}
|
|
29076
|
-
}
|
|
29091
|
+
DOMContentLoaded(fn);
|
|
29077
29092
|
},
|
|
29078
29093
|
|
|
29079
29094
|
/**
|
|
@@ -32901,10 +32916,10 @@
|
|
|
32901
32916
|
* this can be overridden by the plugin
|
|
32902
32917
|
* @public
|
|
32903
32918
|
* @type {string}
|
|
32904
|
-
* @default "
|
|
32919
|
+
* @default "11.0.0"
|
|
32905
32920
|
* @name plugin.Base#version
|
|
32906
32921
|
*/
|
|
32907
|
-
this.version = "
|
|
32922
|
+
this.version = "11.0.0";
|
|
32908
32923
|
};
|
|
32909
32924
|
|
|
32910
32925
|
/**
|
|
@@ -36098,19 +36113,41 @@
|
|
|
36098
36113
|
/** @ignore */
|
|
36099
36114
|
function createGradient(light) {
|
|
36100
36115
|
var context = light.texture.context;
|
|
36101
|
-
|
|
36102
|
-
var
|
|
36103
|
-
|
|
36116
|
+
|
|
36117
|
+
var x1 = light.texture.width / 2,
|
|
36118
|
+
y1 = light.texture.height / 2;
|
|
36119
|
+
|
|
36120
|
+
var radiusX = light.radiusX,
|
|
36121
|
+
radiusY = light.radiusY;
|
|
36122
|
+
|
|
36123
|
+
var scaleX, scaleY, invScaleX, invScaleY;
|
|
36124
|
+
var gradient;
|
|
36125
|
+
|
|
36104
36126
|
|
|
36105
36127
|
light.texture.clear();
|
|
36106
36128
|
|
|
36129
|
+
if (radiusX >= radiusY) {
|
|
36130
|
+
scaleX = 1;
|
|
36131
|
+
invScaleX = 1;
|
|
36132
|
+
scaleY = radiusY/radiusX;
|
|
36133
|
+
invScaleY = radiusX/radiusY;
|
|
36134
|
+
gradient = context.createRadialGradient(x1, y1 * invScaleY, 0, x1, radiusY * invScaleY, radiusX);
|
|
36135
|
+
}
|
|
36136
|
+
else {
|
|
36137
|
+
scaleY = 1;
|
|
36138
|
+
invScaleY = 1;
|
|
36139
|
+
scaleX = radiusX/radiusY;
|
|
36140
|
+
invScaleX = radiusY/radiusX;
|
|
36141
|
+
gradient = context.createRadialGradient(x1 * invScaleX, y1, 0, x1 * invScaleX, y1, radiusY);
|
|
36142
|
+
}
|
|
36143
|
+
|
|
36107
36144
|
gradient.addColorStop( 0, light.color.toRGBA(light.intensity));
|
|
36108
36145
|
gradient.addColorStop( 1, light.color.toRGBA(0.0));
|
|
36109
36146
|
|
|
36110
|
-
context.beginPath();
|
|
36111
36147
|
context.fillStyle = gradient;
|
|
36112
|
-
|
|
36113
|
-
context.
|
|
36148
|
+
|
|
36149
|
+
context.setTransform(scaleX, 0, 0, scaleY, 0, 0);
|
|
36150
|
+
context.fillRect(0, 0, light.texture.width * invScaleX, light.texture.height * invScaleY);
|
|
36114
36151
|
}
|
|
36115
36152
|
|
|
36116
36153
|
/**
|
|
@@ -36122,12 +36159,13 @@
|
|
|
36122
36159
|
* @see stage.lights
|
|
36123
36160
|
*/
|
|
36124
36161
|
var Light2d = /*@__PURE__*/(function (Renderable) {
|
|
36125
|
-
function Light2d(x, y,
|
|
36162
|
+
function Light2d(x, y, radiusX, radiusY, color, intensity) {
|
|
36163
|
+
if ( radiusY === void 0 ) radiusY = radiusX;
|
|
36126
36164
|
if ( color === void 0 ) color = "#FFF";
|
|
36127
36165
|
if ( intensity === void 0 ) intensity = 0.7;
|
|
36128
36166
|
|
|
36129
36167
|
// call the parent constructor
|
|
36130
|
-
Renderable.call(this, x, y,
|
|
36168
|
+
Renderable.call(this, x, y, radiusX * 2, radiusY * 2);
|
|
36131
36169
|
|
|
36132
36170
|
/**
|
|
36133
36171
|
* the color of the light
|
|
@@ -36137,10 +36175,16 @@
|
|
|
36137
36175
|
this.color = pool.pull("Color").parseCSS(color);
|
|
36138
36176
|
|
|
36139
36177
|
/**
|
|
36140
|
-
* The radius of the light
|
|
36178
|
+
* The horizontal radius of the light
|
|
36141
36179
|
* @type {number}
|
|
36142
36180
|
*/
|
|
36143
|
-
this.
|
|
36181
|
+
this.radiusX = radiusX;
|
|
36182
|
+
|
|
36183
|
+
/**
|
|
36184
|
+
* The vertical radius of the light
|
|
36185
|
+
* @type {number}
|
|
36186
|
+
*/
|
|
36187
|
+
this.radiusY = radiusY;
|
|
36144
36188
|
|
|
36145
36189
|
/**
|
|
36146
36190
|
* The intensity of the light
|
|
@@ -37508,7 +37552,7 @@
|
|
|
37508
37552
|
* @name version
|
|
37509
37553
|
* @type {string}
|
|
37510
37554
|
*/
|
|
37511
|
-
var version = "
|
|
37555
|
+
var version = "11.0.0";
|
|
37512
37556
|
|
|
37513
37557
|
|
|
37514
37558
|
/**
|