@vpmedia/phaser 1.117.0 → 1.119.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/index.js +163 -158
- package/dist/index.js.map +1 -1
- package/dist/phaser/core/animation_manager.d.ts +1 -1
- package/dist/phaser/core/animation_manager.d.ts.map +1 -1
- package/dist/phaser/core/cache.d.ts +70 -42
- package/dist/phaser/core/cache.d.ts.map +1 -1
- package/dist/phaser/core/game.d.ts +34 -8
- package/dist/phaser/core/game.d.ts.map +1 -1
- package/dist/phaser/core/input.d.ts +1 -1
- package/dist/phaser/core/input.d.ts.map +1 -1
- package/dist/phaser/core/input_mspointer.d.ts +8 -7
- package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
- package/dist/phaser/core/loader.d.ts +30 -1
- package/dist/phaser/core/loader.d.ts.map +1 -1
- package/dist/phaser/core/loader_parser.d.ts +24 -4
- package/dist/phaser/core/loader_parser.d.ts.map +1 -1
- package/dist/phaser/core/scene.d.ts +3 -2
- package/dist/phaser/core/scene.d.ts.map +1 -1
- package/dist/phaser/core/scene_manager.d.ts +28 -17
- package/dist/phaser/core/scene_manager.d.ts.map +1 -1
- package/dist/phaser/core/sound.d.ts +13 -3
- package/dist/phaser/core/sound.d.ts.map +1 -1
- package/dist/phaser/core/tween.d.ts +3 -3
- package/dist/phaser/core/tween.d.ts.map +1 -1
- package/dist/phaser/core/tween_manager.d.ts +8 -6
- package/dist/phaser/core/tween_manager.d.ts.map +1 -1
- package/dist/phaser/display/bitmap_text.d.ts +13 -8
- package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/phaser/core/animation_manager.ts +1 -1
- package/src/phaser/core/cache.test.ts +201 -0
- package/src/phaser/core/cache.ts +126 -86
- package/src/phaser/core/game.ts +45 -22
- package/src/phaser/core/input.ts +1 -1
- package/src/phaser/core/input_mspointer.ts +10 -13
- package/src/phaser/core/loader.ts +82 -42
- package/src/phaser/core/loader_parser.test.ts +115 -0
- package/src/phaser/core/loader_parser.ts +64 -36
- package/src/phaser/core/scene.ts +4 -2
- package/src/phaser/core/scene_manager.test.ts +193 -0
- package/src/phaser/core/scene_manager.ts +51 -36
- package/src/phaser/core/sound.ts +29 -17
- package/src/phaser/core/sound_manager.ts +1 -1
- package/src/phaser/core/tween.ts +6 -6
- package/src/phaser/core/tween_manager.ts +42 -35
- package/src/phaser/display/bitmap_text.test.ts +212 -0
- package/src/phaser/display/bitmap_text.ts +39 -24
- package/src/phaser/display/webgl/renderer.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -4370,12 +4370,13 @@ var BitmapText = class extends DisplayObject {
|
|
|
4370
4370
|
charCode = 32;
|
|
4371
4371
|
charData = data.chars[charCode];
|
|
4372
4372
|
}
|
|
4373
|
-
|
|
4373
|
+
if (charData === void 0) continue;
|
|
4374
|
+
const kerning = (prevCharCode === null ? 0 : charData.kerning[prevCharCode]) ?? 0;
|
|
4374
4375
|
if (/(\s)/.test(text.charAt(i))) {
|
|
4375
4376
|
lastSpace = i;
|
|
4376
4377
|
wrappedWidth = w;
|
|
4377
4378
|
}
|
|
4378
|
-
c = (kerning + charData.texture
|
|
4379
|
+
c = (kerning + (charData.texture?.width ?? 0) + charData.xOffset) * scale;
|
|
4379
4380
|
if (maxWidth && w + c >= maxWidth && lastSpace > -1) return {
|
|
4380
4381
|
width: wrappedWidth || w,
|
|
4381
4382
|
text: text.substr(0, i - (i - lastSpace)),
|
|
@@ -4401,7 +4402,7 @@ var BitmapText = class extends DisplayObject {
|
|
|
4401
4402
|
* @returns {string} The cleaned text.
|
|
4402
4403
|
*/
|
|
4403
4404
|
cleanText(text, replace = "") {
|
|
4404
|
-
const data = this._data
|
|
4405
|
+
const data = this._data?.font;
|
|
4405
4406
|
if (!data) return "";
|
|
4406
4407
|
const lines = text.replace(/\r\n|\n\r|\n|\r/g, "\n").split("\n");
|
|
4407
4408
|
for (let i = 0; i < lines.length; i += 1) {
|
|
@@ -4417,22 +4418,25 @@ var BitmapText = class extends DisplayObject {
|
|
|
4417
4418
|
* Updates the internal text rendering based on current properties and content.
|
|
4418
4419
|
*/
|
|
4419
4420
|
updateText() {
|
|
4420
|
-
const data = this._data
|
|
4421
|
+
const data = this._data?.font;
|
|
4421
4422
|
if (!data) return;
|
|
4422
4423
|
let text = this.text;
|
|
4423
4424
|
const scale = this._fontSize / data.size;
|
|
4424
4425
|
const lines = [];
|
|
4425
4426
|
let y = 0;
|
|
4426
4427
|
this.textWidth = 0;
|
|
4427
|
-
let
|
|
4428
|
+
let end = false;
|
|
4428
4429
|
do {
|
|
4429
|
-
line =
|
|
4430
|
-
|
|
4430
|
+
const line = {
|
|
4431
|
+
...this.scanLine(data, scale, text),
|
|
4432
|
+
y
|
|
4433
|
+
};
|
|
4431
4434
|
lines.push(line);
|
|
4432
4435
|
if (line.width > this.textWidth) this.textWidth = line.width;
|
|
4433
4436
|
y += data.lineHeight * scale;
|
|
4434
4437
|
text = text.slice(line.text.length + 1);
|
|
4435
|
-
|
|
4438
|
+
end = line.end;
|
|
4439
|
+
} while (!end);
|
|
4436
4440
|
this.textHeight = y;
|
|
4437
4441
|
let t = 0;
|
|
4438
4442
|
let align = 0;
|
|
@@ -4448,14 +4452,15 @@ var BitmapText = class extends DisplayObject {
|
|
|
4448
4452
|
charCode = 32;
|
|
4449
4453
|
charData = data.chars[charCode];
|
|
4450
4454
|
}
|
|
4455
|
+
if (charData?.texture === void 0) continue;
|
|
4451
4456
|
let g = this._glyphs[t];
|
|
4452
4457
|
if (g) g.texture = charData.texture;
|
|
4453
4458
|
else {
|
|
4454
4459
|
g = new Image$1(this.game, 0, 0, charData.texture);
|
|
4455
|
-
g.name = currentLine.text[c];
|
|
4460
|
+
g.name = currentLine.text[c] ?? "";
|
|
4456
4461
|
this._glyphs.push(g);
|
|
4457
4462
|
}
|
|
4458
|
-
g.position.x = currentLine.chars[c] + align - ax;
|
|
4463
|
+
g.position.x = (currentLine.chars[c] ?? 0) + align - ax;
|
|
4459
4464
|
g.position.y = currentLine.y + charData.yOffset * scale - ay;
|
|
4460
4465
|
g.scale.setTo(scale, scale);
|
|
4461
4466
|
g.tint = this.tint;
|
|
@@ -4590,9 +4595,9 @@ var BitmapText = class extends DisplayObject {
|
|
|
4590
4595
|
* @param {number} value - The new font size to use.
|
|
4591
4596
|
*/
|
|
4592
4597
|
set fontSize(value) {
|
|
4593
|
-
|
|
4594
|
-
if (
|
|
4595
|
-
this._fontSize =
|
|
4598
|
+
const size = Math.trunc(Number(value));
|
|
4599
|
+
if (size !== this._fontSize && size > 0) {
|
|
4600
|
+
this._fontSize = size;
|
|
4596
4601
|
this.updateText();
|
|
4597
4602
|
}
|
|
4598
4603
|
}
|
|
@@ -4636,15 +4641,14 @@ var BitmapText = class extends DisplayObject {
|
|
|
4636
4641
|
* @returns {boolean} True if smoothing is enabled, false otherwise.
|
|
4637
4642
|
*/
|
|
4638
4643
|
get smoothed() {
|
|
4639
|
-
return !this._data
|
|
4644
|
+
return !this._data?.base.scaleMode;
|
|
4640
4645
|
}
|
|
4641
4646
|
/**
|
|
4642
4647
|
* Sets whether smoothing is enabled for this bitmap text's font.
|
|
4643
4648
|
* @param {boolean} value - Whether to enable smoothing (true) or not (false).
|
|
4644
4649
|
*/
|
|
4645
4650
|
set smoothed(value) {
|
|
4646
|
-
if (
|
|
4647
|
-
else this._data.base.scaleMode = 1;
|
|
4651
|
+
if (this._data) this._data.base.scaleMode = value ? 0 : 1;
|
|
4648
4652
|
}
|
|
4649
4653
|
};
|
|
4650
4654
|
//#endregion
|
|
@@ -11688,7 +11692,7 @@ var WebGLRenderer = class {
|
|
|
11688
11692
|
this.height = game.height;
|
|
11689
11693
|
this.view = game.canvas;
|
|
11690
11694
|
this._contextOptions = {
|
|
11691
|
-
alpha: game.config.transparent,
|
|
11695
|
+
alpha: Boolean(game.config.transparent),
|
|
11692
11696
|
depth: false,
|
|
11693
11697
|
antialias: game.config.antialias,
|
|
11694
11698
|
premultipliedAlpha: game.config.transparent && game.config.transparent !== "notMultiplied",
|
|
@@ -12105,10 +12109,7 @@ const JSONDataHash = (game, json, _key) => {
|
|
|
12105
12109
|
* @returns {object} The finalized bitmap font data.
|
|
12106
12110
|
*/
|
|
12107
12111
|
const finalizeBitmapFont = (baseTexture, bitmapFontData) => {
|
|
12108
|
-
Object.
|
|
12109
|
-
const letter = bitmapFontData.chars[charCode];
|
|
12110
|
-
letter.texture = new Texture(baseTexture, new Rectangle(letter.x, letter.y, letter.width, letter.height));
|
|
12111
|
-
});
|
|
12112
|
+
for (const letter of Object.values(bitmapFontData.chars)) letter.texture = new Texture(baseTexture, new Rectangle(letter.x, letter.y, letter.width, letter.height));
|
|
12112
12113
|
return bitmapFontData;
|
|
12113
12114
|
};
|
|
12114
12115
|
/**
|
|
@@ -12120,33 +12121,28 @@ const finalizeBitmapFont = (baseTexture, bitmapFontData) => {
|
|
|
12120
12121
|
* @returns {object} The parsed bitmap font data.
|
|
12121
12122
|
*/
|
|
12122
12123
|
const xmlBitmapFont = (xml, baseTexture, xSpacing, ySpacing) => {
|
|
12123
|
-
const data = {};
|
|
12124
12124
|
const info = xml.querySelectorAll("info")[0];
|
|
12125
12125
|
const common = xml.querySelectorAll("common")[0];
|
|
12126
|
-
|
|
12127
|
-
data
|
|
12128
|
-
|
|
12129
|
-
|
|
12130
|
-
|
|
12131
|
-
|
|
12132
|
-
|
|
12133
|
-
|
|
12134
|
-
|
|
12135
|
-
|
|
12136
|
-
|
|
12137
|
-
|
|
12138
|
-
|
|
12139
|
-
|
|
12140
|
-
|
|
12141
|
-
|
|
12142
|
-
|
|
12143
|
-
|
|
12144
|
-
|
|
12145
|
-
|
|
12146
|
-
const first = Math.trunc(Number(kernings[i].getAttribute("first")));
|
|
12147
|
-
const second = Math.trunc(Number(kernings[i].getAttribute("second")));
|
|
12148
|
-
const amount = Math.trunc(Number(kernings[i].getAttribute("amount")));
|
|
12149
|
-
data.chars[second].kerning[first] = amount;
|
|
12126
|
+
const attr = (element, name) => Math.trunc(Number(element?.getAttribute(name)));
|
|
12127
|
+
const data = {
|
|
12128
|
+
font: info?.getAttribute("face") ?? "",
|
|
12129
|
+
size: attr(info, "size"),
|
|
12130
|
+
lineHeight: attr(common, "lineHeight") + ySpacing,
|
|
12131
|
+
chars: {}
|
|
12132
|
+
};
|
|
12133
|
+
for (const letter of xml.querySelectorAll("char")) data.chars[attr(letter, "id")] = {
|
|
12134
|
+
x: attr(letter, "x"),
|
|
12135
|
+
y: attr(letter, "y"),
|
|
12136
|
+
width: attr(letter, "width"),
|
|
12137
|
+
height: attr(letter, "height"),
|
|
12138
|
+
xOffset: attr(letter, "xoffset"),
|
|
12139
|
+
yOffset: attr(letter, "yoffset"),
|
|
12140
|
+
xAdvance: attr(letter, "xadvance") + xSpacing,
|
|
12141
|
+
kerning: {}
|
|
12142
|
+
};
|
|
12143
|
+
for (const kerning of xml.querySelectorAll("kerning")) {
|
|
12144
|
+
const char = data.chars[attr(kerning, "second")];
|
|
12145
|
+
if (char) char.kerning[attr(kerning, "first")] = attr(kerning, "amount");
|
|
12150
12146
|
}
|
|
12151
12147
|
return finalizeBitmapFont(baseTexture, data);
|
|
12152
12148
|
};
|
|
@@ -12306,9 +12302,9 @@ var Cache = class {
|
|
|
12306
12302
|
key,
|
|
12307
12303
|
url,
|
|
12308
12304
|
data,
|
|
12309
|
-
base: new BaseTexture(data)
|
|
12305
|
+
base: new BaseTexture(data),
|
|
12306
|
+
frameData: JSONDataHash(this.game, atlasData, key)
|
|
12310
12307
|
};
|
|
12311
|
-
obj.frameData = JSONDataHash(this.game, atlasData, key);
|
|
12312
12308
|
this._cache.image[key] = obj;
|
|
12313
12309
|
this._resolveURL(url, obj);
|
|
12314
12310
|
}
|
|
@@ -12319,13 +12315,14 @@ var Cache = class {
|
|
|
12319
12315
|
* @param {object} data - The sound data to cache.
|
|
12320
12316
|
*/
|
|
12321
12317
|
addSound(key, url, data) {
|
|
12322
|
-
|
|
12318
|
+
const obj = {
|
|
12323
12319
|
url,
|
|
12324
12320
|
data,
|
|
12325
12321
|
isDecoding: false,
|
|
12326
12322
|
decoded: false
|
|
12327
12323
|
};
|
|
12328
|
-
this.
|
|
12324
|
+
this._cache.sound[key] = obj;
|
|
12325
|
+
this._resolveURL(url, obj);
|
|
12329
12326
|
}
|
|
12330
12327
|
/**
|
|
12331
12328
|
* Adds text data to the cache.
|
|
@@ -12334,11 +12331,12 @@ var Cache = class {
|
|
|
12334
12331
|
* @param {string} data - The text data to cache.
|
|
12335
12332
|
*/
|
|
12336
12333
|
addText(key, url, data) {
|
|
12337
|
-
|
|
12334
|
+
const obj = {
|
|
12338
12335
|
url,
|
|
12339
12336
|
data
|
|
12340
12337
|
};
|
|
12341
|
-
this.
|
|
12338
|
+
this._cache.text[key] = obj;
|
|
12339
|
+
this._resolveURL(url, obj);
|
|
12342
12340
|
}
|
|
12343
12341
|
/**
|
|
12344
12342
|
* Adds a bitmap font to the cache.
|
|
@@ -12351,14 +12349,13 @@ var Cache = class {
|
|
|
12351
12349
|
* @param {number} ySpacing - Vertical spacing between characters.
|
|
12352
12350
|
*/
|
|
12353
12351
|
addBitmapFont(key, url, data, atlasData, atlasType, xSpacing = 0, ySpacing = 0) {
|
|
12352
|
+
const base = new BaseTexture(data);
|
|
12354
12353
|
const obj = {
|
|
12355
12354
|
url,
|
|
12356
12355
|
data,
|
|
12357
|
-
font:
|
|
12358
|
-
base
|
|
12356
|
+
font: atlasType === "json" ? jsonBitmapFont(atlasData, base, xSpacing, ySpacing) : xmlBitmapFont(atlasData, base, xSpacing, ySpacing),
|
|
12357
|
+
base
|
|
12359
12358
|
};
|
|
12360
|
-
if (atlasType === "json") obj.font = jsonBitmapFont(atlasData, obj.base, xSpacing, ySpacing);
|
|
12361
|
-
else obj.font = xmlBitmapFont(atlasData, obj.base, xSpacing, ySpacing);
|
|
12362
12359
|
this._cache.bitmapFont[key] = obj;
|
|
12363
12360
|
this._resolveURL(url, obj);
|
|
12364
12361
|
}
|
|
@@ -12369,11 +12366,12 @@ var Cache = class {
|
|
|
12369
12366
|
* @param {object} data - The JSON data to cache.
|
|
12370
12367
|
*/
|
|
12371
12368
|
addJSON(key, url, data) {
|
|
12372
|
-
|
|
12369
|
+
const obj = {
|
|
12373
12370
|
url,
|
|
12374
12371
|
data
|
|
12375
12372
|
};
|
|
12376
|
-
this.
|
|
12373
|
+
this._cache.json[key] = obj;
|
|
12374
|
+
this._resolveURL(url, obj);
|
|
12377
12375
|
}
|
|
12378
12376
|
/**
|
|
12379
12377
|
* Adds XML data to the cache.
|
|
@@ -12382,11 +12380,12 @@ var Cache = class {
|
|
|
12382
12380
|
* @param {XMLDocument} data - The XML data to cache.
|
|
12383
12381
|
*/
|
|
12384
12382
|
addXML(key, url, data) {
|
|
12385
|
-
|
|
12383
|
+
const obj = {
|
|
12386
12384
|
url,
|
|
12387
12385
|
data
|
|
12388
12386
|
};
|
|
12389
|
-
this.
|
|
12387
|
+
this._cache.xml[key] = obj;
|
|
12388
|
+
this._resolveURL(url, obj);
|
|
12390
12389
|
}
|
|
12391
12390
|
/**
|
|
12392
12391
|
* Updates a sound property in the cache.
|
|
@@ -12405,6 +12404,7 @@ var Cache = class {
|
|
|
12405
12404
|
*/
|
|
12406
12405
|
decodedSound(key, data) {
|
|
12407
12406
|
const sound = this.getSound(key);
|
|
12407
|
+
if (!sound) return;
|
|
12408
12408
|
sound.data = data;
|
|
12409
12409
|
sound.decoded = true;
|
|
12410
12410
|
sound.isDecoding = false;
|
|
@@ -12415,7 +12415,7 @@ var Cache = class {
|
|
|
12415
12415
|
* @returns {boolean} True if the sound is decoded, false otherwise.
|
|
12416
12416
|
*/
|
|
12417
12417
|
isSoundDecoded(key) {
|
|
12418
|
-
const sound = this.
|
|
12418
|
+
const sound = this.getSound(key);
|
|
12419
12419
|
if (sound) return sound.decoded;
|
|
12420
12420
|
return null;
|
|
12421
12421
|
}
|
|
@@ -12425,7 +12425,7 @@ var Cache = class {
|
|
|
12425
12425
|
* @returns {boolean} True if the sound is ready, false otherwise.
|
|
12426
12426
|
*/
|
|
12427
12427
|
isSoundReady(key) {
|
|
12428
|
-
const sound = this.
|
|
12428
|
+
const sound = this.getSound(key);
|
|
12429
12429
|
if (sound) return sound.decoded && !this.game.sound.isLocked;
|
|
12430
12430
|
return false;
|
|
12431
12431
|
}
|
|
@@ -12545,15 +12545,8 @@ var Cache = class {
|
|
|
12545
12545
|
getCanvas(key) {
|
|
12546
12546
|
return this.getItem(key, 0, "getCanvas", "canvas");
|
|
12547
12547
|
}
|
|
12548
|
-
/**
|
|
12549
|
-
* TBD.
|
|
12550
|
-
* @param {string} key - TBD.
|
|
12551
|
-
* @param {boolean} full - TBD.
|
|
12552
|
-
* @returns {HTMLImageElement} TBD.
|
|
12553
|
-
*/
|
|
12554
12548
|
getImage(key = "__default", full = false) {
|
|
12555
|
-
|
|
12556
|
-
if (img === null) img = this.getItem("__missing", 1, "getImage");
|
|
12549
|
+
const img = this.getItem(String(key), 1, "getImage") ?? this.getItem("__missing", 1, "getImage");
|
|
12557
12550
|
if (full) return img;
|
|
12558
12551
|
return img.data;
|
|
12559
12552
|
}
|
|
@@ -12731,8 +12724,9 @@ var Cache = class {
|
|
|
12731
12724
|
*/
|
|
12732
12725
|
getKeys(cache = 1) {
|
|
12733
12726
|
const result = [];
|
|
12734
|
-
|
|
12735
|
-
|
|
12727
|
+
const bucket = this._cacheMap[cache];
|
|
12728
|
+
if (bucket) {
|
|
12729
|
+
const keys = Object.keys(bucket);
|
|
12736
12730
|
for (const key of keys) if (key !== "__default" && key !== "__missing") result.push(key);
|
|
12737
12731
|
}
|
|
12738
12732
|
return result;
|
|
@@ -12751,7 +12745,7 @@ var Cache = class {
|
|
|
12751
12745
|
*/
|
|
12752
12746
|
removeImage(key, destroyBaseTexture = true) {
|
|
12753
12747
|
const img = this.getImage(key, true);
|
|
12754
|
-
if (destroyBaseTexture
|
|
12748
|
+
if (destroyBaseTexture) img.base.destroy();
|
|
12755
12749
|
delete this._cache.image[key];
|
|
12756
12750
|
}
|
|
12757
12751
|
/**
|
|
@@ -12821,8 +12815,7 @@ var Cache = class {
|
|
|
12821
12815
|
* Clears all GL textures from the cache.
|
|
12822
12816
|
*/
|
|
12823
12817
|
clearGLTextures() {
|
|
12824
|
-
const
|
|
12825
|
-
for (const key of keys) this._cache.image[key].base._glTextures = [];
|
|
12818
|
+
for (const entry of Object.values(this._cache.image)) entry.base._glTextures = [];
|
|
12826
12819
|
}
|
|
12827
12820
|
/**
|
|
12828
12821
|
* Resolves a URL and stores it in the cache.
|
|
@@ -12846,7 +12839,7 @@ var Cache = class {
|
|
|
12846
12839
|
for (const cache of this._cacheMap) {
|
|
12847
12840
|
const keys = cache ? Object.keys(cache) : [];
|
|
12848
12841
|
for (const key of keys) if (key !== "__default" && key !== "__missing") {
|
|
12849
|
-
|
|
12842
|
+
cache[key].destroy?.();
|
|
12850
12843
|
delete cache[key];
|
|
12851
12844
|
}
|
|
12852
12845
|
}
|
|
@@ -13560,14 +13553,10 @@ var MSPointer = class {
|
|
|
13560
13553
|
if (this._onMSPointerDown) canvas.removeEventListener("pointerdown", this._onMSPointerDown, false);
|
|
13561
13554
|
if (this._onMSPointerMove) canvas.removeEventListener("pointermove", this._onMSPointerMove, false);
|
|
13562
13555
|
if (this._onMSPointerUp) canvas.removeEventListener("pointerup", this._onMSPointerUp, false);
|
|
13563
|
-
if (this._onMSPointerUpGlobal)
|
|
13564
|
-
if (this._onMSPointerUpGlobal) globalThis.removeEventListener("MSPointerUp", this._onMSPointerUpGlobal, true);
|
|
13565
|
-
}
|
|
13556
|
+
if (this._onMSPointerUpGlobal) globalThis.removeEventListener("MSPointerUp", this._onMSPointerUpGlobal, true);
|
|
13566
13557
|
if (this._onMSPointerOver) canvas.removeEventListener("MSPointerOver", this._onMSPointerOver, true);
|
|
13567
13558
|
if (this._onMSPointerOut) canvas.removeEventListener("MSPointerOut", this._onMSPointerOut, true);
|
|
13568
|
-
if (this._onMSPointerUpGlobal)
|
|
13569
|
-
if (this._onMSPointerUpGlobal) globalThis.removeEventListener("pointerup", this._onMSPointerUpGlobal, true);
|
|
13570
|
-
}
|
|
13559
|
+
if (this._onMSPointerUpGlobal) globalThis.removeEventListener("pointerup", this._onMSPointerUpGlobal, true);
|
|
13571
13560
|
if (this._onMSPointerOver) canvas.removeEventListener("pointerover", this._onMSPointerOver, true);
|
|
13572
13561
|
if (this._onMSPointerOut) canvas.removeEventListener("pointerout", this._onMSPointerOut, true);
|
|
13573
13562
|
}
|
|
@@ -15281,41 +15270,41 @@ var Loader = class {
|
|
|
15281
15270
|
* @param {object} pack - The pack file object to process.
|
|
15282
15271
|
*/
|
|
15283
15272
|
processPack(pack) {
|
|
15284
|
-
const packData = pack.data[pack.key];
|
|
15273
|
+
const packData = (pack.data ?? {})[pack.key];
|
|
15285
15274
|
if (!packData) {
|
|
15286
15275
|
this.game.logger.warn("Missing loader pack key", { key: pack.key });
|
|
15287
15276
|
return;
|
|
15288
15277
|
}
|
|
15289
|
-
const packDataCompat = Array.isArray(packData) ? packData : packData.files;
|
|
15278
|
+
const packDataCompat = Array.isArray(packData) ? packData : packData.files ?? [];
|
|
15290
15279
|
for (const file of packDataCompat) switch (file.type) {
|
|
15291
15280
|
case "image":
|
|
15292
|
-
this.image(file.key, file.url, file.overwrite);
|
|
15281
|
+
this.image(file.key, file.url ?? file.key, file.overwrite);
|
|
15293
15282
|
break;
|
|
15294
15283
|
case "text":
|
|
15295
|
-
this.text(file.key, file.url, file.overwrite);
|
|
15284
|
+
this.text(file.key, file.url ?? file.key, file.overwrite);
|
|
15296
15285
|
break;
|
|
15297
15286
|
case "json":
|
|
15298
|
-
this.json(file.key, file.url, file.overwrite);
|
|
15287
|
+
this.json(file.key, file.url ?? file.key, file.overwrite);
|
|
15299
15288
|
break;
|
|
15300
15289
|
case "xml":
|
|
15301
|
-
this.xml(file.key, file.url, file.overwrite);
|
|
15290
|
+
this.xml(file.key, file.url ?? file.key, file.overwrite);
|
|
15302
15291
|
break;
|
|
15303
15292
|
case "spritesheet":
|
|
15304
|
-
this.spritesheet(file.key, file.url, file.frameWidth, file.frameHeight, file.frameMax, file.margin, file.spacing);
|
|
15293
|
+
this.spritesheet(file.key, file.url ?? file.key, file.frameWidth ?? 0, file.frameHeight ?? 0, file.frameMax ?? -1, file.margin, file.spacing);
|
|
15305
15294
|
break;
|
|
15306
15295
|
case "audio":
|
|
15307
|
-
this.audio(file.key, file.urls ?? file.url);
|
|
15296
|
+
this.audio(file.key, file.urls ?? file.url ?? file.key);
|
|
15308
15297
|
break;
|
|
15309
15298
|
case "audiosprite":
|
|
15310
|
-
this.audioSprite(file.key, file.urls ?? file.url, file.jsonURL, file.jsonData);
|
|
15299
|
+
this.audioSprite(file.key, String(file.urls ?? file.url ?? file.key), file.jsonURL ?? "", file.jsonData);
|
|
15311
15300
|
break;
|
|
15312
15301
|
case "audioSprite":
|
|
15313
|
-
this.audioSprite(file.key, file.audioURL, file.jsonURL, file.jsonData);
|
|
15302
|
+
this.audioSprite(file.key, file.audioURL ?? file.key, file.jsonURL ?? "", file.jsonData);
|
|
15314
15303
|
break;
|
|
15315
15304
|
case "bitmapFont":
|
|
15316
15305
|
this.bitmapFont(file.key, file.textureURL, file.fontDataURL ?? file.atlasURL, file.atlasData, file.xSpacing, file.ySpacing);
|
|
15317
15306
|
break;
|
|
15318
|
-
case "atlas": this.atlas(file.key, file.textureURL, file.atlasURL, file.atlasData, TEXTURE_ATLAS_JSON_HASH);
|
|
15307
|
+
case "atlas": this.atlas(file.key, file.textureURL ?? file.key, file.atlasURL, file.atlasData, TEXTURE_ATLAS_JSON_HASH);
|
|
15319
15308
|
}
|
|
15320
15309
|
}
|
|
15321
15310
|
/**
|
|
@@ -15371,28 +15360,34 @@ var Loader = class {
|
|
|
15371
15360
|
loadImageTag(file) {
|
|
15372
15361
|
this.log("loadImageTag", file);
|
|
15373
15362
|
const scope = this;
|
|
15374
|
-
|
|
15375
|
-
file.data
|
|
15376
|
-
|
|
15377
|
-
|
|
15378
|
-
|
|
15379
|
-
|
|
15380
|
-
|
|
15363
|
+
const image = new globalThis.Image();
|
|
15364
|
+
file.data = image;
|
|
15365
|
+
image.name = file.key;
|
|
15366
|
+
if (typeof this.crossOrigin === "string" && this.crossOrigin) image.crossOrigin = this.crossOrigin;
|
|
15367
|
+
image.onload = () => {
|
|
15368
|
+
if (image.onload) {
|
|
15369
|
+
image.onload = null;
|
|
15370
|
+
image.onerror = null;
|
|
15381
15371
|
scope.fileComplete(file);
|
|
15382
15372
|
}
|
|
15383
15373
|
};
|
|
15384
|
-
|
|
15374
|
+
image.onerror = () => {
|
|
15385
15375
|
if (scope.isUseRetry && (!file.numRetry || file.numRetry < scope.maxRetry)) setTimeout(() => {
|
|
15386
15376
|
file.numRetry = !file.numRetry ? 1 : file.numRetry += 1;
|
|
15387
15377
|
scope.loadImageTag(file);
|
|
15388
15378
|
}, 1e3);
|
|
15389
|
-
else if (
|
|
15390
|
-
|
|
15391
|
-
|
|
15379
|
+
else if (image.onload) {
|
|
15380
|
+
image.onload = null;
|
|
15381
|
+
image.onerror = null;
|
|
15392
15382
|
scope.fileError(file);
|
|
15393
15383
|
}
|
|
15394
15384
|
};
|
|
15395
|
-
|
|
15385
|
+
const src = this.transformUrl(file.url, file);
|
|
15386
|
+
if (src === false) {
|
|
15387
|
+
this.fileError(file, null, "Could not resolve the file URL");
|
|
15388
|
+
return;
|
|
15389
|
+
}
|
|
15390
|
+
image.src = src;
|
|
15396
15391
|
}
|
|
15397
15392
|
/**
|
|
15398
15393
|
* Loads a file using XMLHttpRequest with the specified parameters.
|
|
@@ -15550,14 +15545,19 @@ var Loader = class {
|
|
|
15550
15545
|
});
|
|
15551
15546
|
}
|
|
15552
15547
|
break;
|
|
15553
|
-
case "audio":
|
|
15554
|
-
|
|
15555
|
-
|
|
15548
|
+
case "audio": {
|
|
15549
|
+
const audio = response.response;
|
|
15550
|
+
file.data = audio;
|
|
15551
|
+
this.cache.addSound(file.key, url, audio);
|
|
15556
15552
|
if (file.autoDecode) this.game.sound.decode(file.key);
|
|
15557
15553
|
break;
|
|
15558
|
-
|
|
15559
|
-
|
|
15560
|
-
|
|
15554
|
+
}
|
|
15555
|
+
case "text": {
|
|
15556
|
+
const { responseText } = response;
|
|
15557
|
+
file.data = responseText;
|
|
15558
|
+
this.cache.addText(file.key, url, responseText);
|
|
15559
|
+
break;
|
|
15560
|
+
}
|
|
15561
15561
|
}
|
|
15562
15562
|
if (loadNext) this.asyncComplete(file);
|
|
15563
15563
|
}
|
|
@@ -16958,12 +16958,12 @@ var SceneManager = class {
|
|
|
16958
16958
|
* @returns {Scene|object} The created scene or state object.
|
|
16959
16959
|
*/
|
|
16960
16960
|
add(key, state, autoStart = false) {
|
|
16961
|
-
let newState
|
|
16962
|
-
if (state
|
|
16963
|
-
else
|
|
16961
|
+
let newState;
|
|
16962
|
+
if (typeof state === "function") newState = new state(this.game);
|
|
16963
|
+
else {
|
|
16964
16964
|
newState = state;
|
|
16965
|
-
newState.game = this.game;
|
|
16966
|
-
}
|
|
16965
|
+
if (!(state instanceof Scene)) newState.game = this.game;
|
|
16966
|
+
}
|
|
16967
16967
|
this.states[key] = newState;
|
|
16968
16968
|
if (autoStart) {
|
|
16969
16969
|
if (this.game.isBooted) this.start(key);
|
|
@@ -17019,7 +17019,7 @@ var SceneManager = class {
|
|
|
17019
17019
|
* This method is called before the game loop updates.
|
|
17020
17020
|
*/
|
|
17021
17021
|
preUpdate() {
|
|
17022
|
-
if (this._pendingState && this.game.isBooted) {
|
|
17022
|
+
if (typeof this._pendingState === "string" && this._pendingState && this.game.isBooted) {
|
|
17023
17023
|
this.clearCurrentState();
|
|
17024
17024
|
this.setCurrentState(this._pendingState);
|
|
17025
17025
|
this.game.world.x = 0;
|
|
@@ -17057,10 +17057,8 @@ var SceneManager = class {
|
|
|
17057
17057
|
* @returns {boolean} True if the scene exists, false otherwise.
|
|
17058
17058
|
*/
|
|
17059
17059
|
checkState(key) {
|
|
17060
|
-
|
|
17061
|
-
|
|
17062
|
-
return false;
|
|
17063
|
-
}
|
|
17060
|
+
const state = this.states[key];
|
|
17061
|
+
if (state) return Boolean(state.preload ?? state.create ?? state.update ?? state.render);
|
|
17064
17062
|
return false;
|
|
17065
17063
|
}
|
|
17066
17064
|
/**
|
|
@@ -17068,15 +17066,19 @@ var SceneManager = class {
|
|
|
17068
17066
|
* @param {string} key - The unique key for the state to link.
|
|
17069
17067
|
*/
|
|
17070
17068
|
link(key) {
|
|
17071
|
-
this.states[key]
|
|
17072
|
-
|
|
17069
|
+
const state = this.states[key];
|
|
17070
|
+
if (state) {
|
|
17071
|
+
state.game = this.game;
|
|
17072
|
+
state.key = key;
|
|
17073
|
+
}
|
|
17073
17074
|
}
|
|
17074
17075
|
/**
|
|
17075
17076
|
* Unlink a scene state from the manager.
|
|
17076
17077
|
* @param {string} key - The unique key for the state to unlink.
|
|
17077
17078
|
*/
|
|
17078
17079
|
unlink(key) {
|
|
17079
|
-
|
|
17080
|
+
const state = this.states[key];
|
|
17081
|
+
if (state) state.game = null;
|
|
17080
17082
|
}
|
|
17081
17083
|
/**
|
|
17082
17084
|
* Set the current scene state.
|
|
@@ -17111,7 +17113,7 @@ var SceneManager = class {
|
|
|
17111
17113
|
* This method is called when scene loading is complete.
|
|
17112
17114
|
*/
|
|
17113
17115
|
loadComplete() {
|
|
17114
|
-
if (this._created
|
|
17116
|
+
if (!this._created && this.onCreateCallback) {
|
|
17115
17117
|
this._created = true;
|
|
17116
17118
|
this.onCreateCallback.call(this.callbackContext, this.game);
|
|
17117
17119
|
} else this._created = true;
|
|
@@ -17287,8 +17289,9 @@ var Sound = class {
|
|
|
17287
17289
|
*/
|
|
17288
17290
|
soundHasUnlocked(key) {
|
|
17289
17291
|
if (key === this.key) {
|
|
17290
|
-
|
|
17291
|
-
this.
|
|
17292
|
+
const buffer = this.game.cache.getSoundData(this.key);
|
|
17293
|
+
this._sound = buffer;
|
|
17294
|
+
this.totalDuration = buffer.duration;
|
|
17292
17295
|
}
|
|
17293
17296
|
}
|
|
17294
17297
|
/**
|
|
@@ -17402,14 +17405,15 @@ var Sound = class {
|
|
|
17402
17405
|
this.isPlaying = false;
|
|
17403
17406
|
}
|
|
17404
17407
|
if (marker === "" && Object.keys(this.markers).length > 0) return this;
|
|
17408
|
+
const markerData = marker === "" ? void 0 : this.markers[marker];
|
|
17405
17409
|
if (marker !== "") {
|
|
17406
|
-
if (
|
|
17410
|
+
if (markerData) {
|
|
17407
17411
|
this.currentMarker = marker;
|
|
17408
|
-
this.position =
|
|
17409
|
-
this.volume =
|
|
17410
|
-
this.loop =
|
|
17411
|
-
this.duration =
|
|
17412
|
-
this.durationMS =
|
|
17412
|
+
this.position = markerData.start;
|
|
17413
|
+
this.volume = markerData.volume;
|
|
17414
|
+
this.loop = markerData.loop;
|
|
17415
|
+
this.duration = markerData.duration;
|
|
17416
|
+
this.durationMS = markerData.durationMS;
|
|
17413
17417
|
if (volume !== void 0) this.volume = volume;
|
|
17414
17418
|
if (loop !== void 0) this.loop = loop;
|
|
17415
17419
|
this._tempMarker = marker;
|
|
@@ -17421,8 +17425,8 @@ var Sound = class {
|
|
|
17421
17425
|
return this;
|
|
17422
17426
|
}
|
|
17423
17427
|
} else {
|
|
17424
|
-
position
|
|
17425
|
-
|
|
17428
|
+
position ??= 0;
|
|
17429
|
+
volume ??= this._volume;
|
|
17426
17430
|
if (loop === void 0) ({loop} = this);
|
|
17427
17431
|
this.position = Math.max(0, position);
|
|
17428
17432
|
this.volume = volume;
|
|
@@ -17457,7 +17461,7 @@ var Sound = class {
|
|
|
17457
17461
|
this.onPlay.dispatch(this);
|
|
17458
17462
|
} else {
|
|
17459
17463
|
this.pendingPlayback = true;
|
|
17460
|
-
if (this.game.cache.getSound(this.key)
|
|
17464
|
+
if (this.game.cache.getSound(this.key)?.isDecoding === false) this.game.sound.decode(this.key);
|
|
17461
17465
|
}
|
|
17462
17466
|
return this;
|
|
17463
17467
|
}
|
|
@@ -17909,7 +17913,7 @@ var SoundManager = class {
|
|
|
17909
17913
|
*/
|
|
17910
17914
|
decode(key) {
|
|
17911
17915
|
const soundData = this.game.cache.getSoundData(key);
|
|
17912
|
-
if (!soundData) return;
|
|
17916
|
+
if (!(soundData instanceof ArrayBuffer)) return;
|
|
17913
17917
|
if (this.game.cache.isSoundDecoded(key) === true) return;
|
|
17914
17918
|
this.game.cache.updateSound(key, "isDecoding", true);
|
|
17915
17919
|
this.context.decodeAudioData(soundData).then((buffer) => {
|
|
@@ -19825,7 +19829,7 @@ var TweenManager = class {
|
|
|
19825
19829
|
* This method removes all active and pending tweens.
|
|
19826
19830
|
*/
|
|
19827
19831
|
removeAll() {
|
|
19828
|
-
for (
|
|
19832
|
+
for (const tween of this._tweens) tween.pendingDelete = true;
|
|
19829
19833
|
this._add = [];
|
|
19830
19834
|
}
|
|
19831
19835
|
/**
|
|
@@ -19834,14 +19838,17 @@ var TweenManager = class {
|
|
|
19834
19838
|
* @param {object[]} children - Optional array of child objects to remove tweens from.
|
|
19835
19839
|
*/
|
|
19836
19840
|
removeFrom(obj, children = null) {
|
|
19837
|
-
|
|
19838
|
-
|
|
19839
|
-
|
|
19840
|
-
|
|
19841
|
-
|
|
19842
|
-
|
|
19843
|
-
for (
|
|
19841
|
+
if (Array.isArray(obj)) {
|
|
19842
|
+
for (const entry of obj) this.removeFrom(entry);
|
|
19843
|
+
return;
|
|
19844
|
+
}
|
|
19845
|
+
const group = obj;
|
|
19846
|
+
if (group.type === 7 && children && group.children) {
|
|
19847
|
+
for (const child of group.children) this.removeFrom(child);
|
|
19848
|
+
return;
|
|
19844
19849
|
}
|
|
19850
|
+
for (const tween of this._tweens.slice()) if (obj === tween.target) this.remove(tween);
|
|
19851
|
+
for (const tween of this._add.slice()) if (obj === tween.target) this.remove(tween);
|
|
19845
19852
|
}
|
|
19846
19853
|
/**
|
|
19847
19854
|
* Add a tween to the manager.
|
|
@@ -19864,6 +19871,7 @@ var TweenManager = class {
|
|
|
19864
19871
|
* @param {Tween | null | undefined} tween - The tween to remove.
|
|
19865
19872
|
*/
|
|
19866
19873
|
remove(tween) {
|
|
19874
|
+
if (!tween) return;
|
|
19867
19875
|
let i = this._tweens.indexOf(tween);
|
|
19868
19876
|
if (i !== -1) this._tweens[i].pendingDelete = true;
|
|
19869
19877
|
else {
|
|
@@ -19904,28 +19912,28 @@ var TweenManager = class {
|
|
|
19904
19912
|
* This method pauses all active tweens.
|
|
19905
19913
|
*/
|
|
19906
19914
|
_pauseAll() {
|
|
19907
|
-
for (
|
|
19915
|
+
for (const tween of this._tweens) tween._pause();
|
|
19908
19916
|
}
|
|
19909
19917
|
/**
|
|
19910
19918
|
* Resume all tweens managed by this manager.
|
|
19911
19919
|
* This method resumes all paused tweens.
|
|
19912
19920
|
*/
|
|
19913
19921
|
_resumeAll() {
|
|
19914
|
-
for (
|
|
19922
|
+
for (const tween of this._tweens) tween._resume();
|
|
19915
19923
|
}
|
|
19916
19924
|
/**
|
|
19917
19925
|
* Pause all tweens managed by this manager.
|
|
19918
19926
|
* This method pauses all active tweens.
|
|
19919
19927
|
*/
|
|
19920
19928
|
pauseAll() {
|
|
19921
|
-
for (
|
|
19929
|
+
for (const tween of this._tweens) tween.pause();
|
|
19922
19930
|
}
|
|
19923
19931
|
/**
|
|
19924
19932
|
* Resume all tweens managed by this manager.
|
|
19925
19933
|
* This method resumes all paused tweens.
|
|
19926
19934
|
*/
|
|
19927
19935
|
resumeAll() {
|
|
19928
|
-
for (
|
|
19936
|
+
for (const tween of this._tweens) tween.resume();
|
|
19929
19937
|
}
|
|
19930
19938
|
};
|
|
19931
19939
|
//#endregion
|
|
@@ -20003,7 +20011,6 @@ var Game = class {
|
|
|
20003
20011
|
*/
|
|
20004
20012
|
constructor(gameConfig = {}) {
|
|
20005
20013
|
getRegistry();
|
|
20006
|
-
this.config = {};
|
|
20007
20014
|
this.id = 0;
|
|
20008
20015
|
this.parent = "";
|
|
20009
20016
|
this.width = 800;
|
|
@@ -20066,7 +20073,7 @@ var Game = class {
|
|
|
20066
20073
|
if (this.config.canvas) this.canvas = this.config.canvas;
|
|
20067
20074
|
else this.canvas = create(this, this.width, this.height, this.config.canvasID, true);
|
|
20068
20075
|
if (this.config.canvasStyle) {
|
|
20069
|
-
const canvasStyle = this.config
|
|
20076
|
+
const { canvasStyle } = this.config;
|
|
20070
20077
|
for (const property of Object.keys(canvasStyle)) this.canvas.style.setProperty(property, canvasStyle[property] ?? null);
|
|
20071
20078
|
} else this.canvas.style.setProperty("-webkit-full-screen", "width: 100%; height: 100%");
|
|
20072
20079
|
}
|
|
@@ -20112,8 +20119,7 @@ var Game = class {
|
|
|
20112
20119
|
* @param {*} defaultValue - The default value if the key is not found in config.
|
|
20113
20120
|
*/
|
|
20114
20121
|
parseConfigElement(config, key, defaultValue) {
|
|
20115
|
-
|
|
20116
|
-
else this.config[key] = defaultValue;
|
|
20122
|
+
this.config[key] = config[key] ?? defaultValue;
|
|
20117
20123
|
}
|
|
20118
20124
|
/**
|
|
20119
20125
|
* Parses the configuration object and sets up game properties.
|
|
@@ -20122,6 +20128,7 @@ var Game = class {
|
|
|
20122
20128
|
parseConfig(config) {
|
|
20123
20129
|
this.logger = config.logger ?? getLogger(["phaser"]);
|
|
20124
20130
|
this.logger.info("parseConfig");
|
|
20131
|
+
this.config = {};
|
|
20125
20132
|
this.parseConfigElement(config, "width", 800);
|
|
20126
20133
|
this.parseConfigElement(config, "height", 600);
|
|
20127
20134
|
this.parseConfigElement(config, "backgroundColor", 0);
|
|
@@ -20137,16 +20144,14 @@ var Game = class {
|
|
|
20137
20144
|
this.parseConfigElement(config, "isForceDisabledAudio", false);
|
|
20138
20145
|
this.parseConfigElement(config, "maxParallelDownloads", 16);
|
|
20139
20146
|
if (config.parent) this.parent = config.parent;
|
|
20140
|
-
|
|
20141
|
-
if (config.state) ({state} = config);
|
|
20142
|
-
this.state = new SceneManager(this, state);
|
|
20147
|
+
this.state = new SceneManager(this, config.state ?? null);
|
|
20143
20148
|
}
|
|
20144
20149
|
/**
|
|
20145
20150
|
* Called when the WebGL context is lost.
|
|
20146
20151
|
* @param {WebGLContextEvent | Event} event - The WebGL context loss event.
|
|
20147
20152
|
*/
|
|
20148
20153
|
contextLost(event) {
|
|
20149
|
-
this.logger.info("contextLost", event);
|
|
20154
|
+
this.logger.info("contextLost", { type: event.type });
|
|
20150
20155
|
event.preventDefault();
|
|
20151
20156
|
if (this.renderer) this.renderer.contextLost = true;
|
|
20152
20157
|
}
|
|
@@ -20155,7 +20160,7 @@ var Game = class {
|
|
|
20155
20160
|
* @param {WebGLContextEvent | Event} event - The WebGL context restore event.
|
|
20156
20161
|
*/
|
|
20157
20162
|
contextRestored(event) {
|
|
20158
|
-
this.logger.info("contextRestored", event);
|
|
20163
|
+
this.logger.info("contextRestored", { type: event.type });
|
|
20159
20164
|
if (this.renderer) {
|
|
20160
20165
|
this.renderer.initContext(this);
|
|
20161
20166
|
this.renderer.contextLost = false;
|