@umicat/phaser-sdk 1.0.14 → 1.0.15
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/scene/SceneLoader.js +21 -2
- package/package.json +1 -1
|
@@ -109,6 +109,20 @@ export function preloadSceneAssets(scene, sceneFile, manifest) {
|
|
|
109
109
|
queueAssetLoad(scene, asset);
|
|
110
110
|
state.requestedAssetIds.add(id);
|
|
111
111
|
}
|
|
112
|
+
// Audio assets are GLOBAL — BGM / SFX are played from code (`sound.play(key)`),
|
|
113
|
+
// not attached to a scene entity — so the entity walk above never collects
|
|
114
|
+
// them and they'd never load. Eagerly load every audio asset in the manifest
|
|
115
|
+
// so `cache.audio.has(key)` is true and the game can play it with no manual
|
|
116
|
+
// BootScene preload. (Without this, registering BGM in the manifest silently
|
|
117
|
+
// produced no sound — the asset existed but was never queued.)
|
|
118
|
+
for (const asset of manifest.assets ?? []) {
|
|
119
|
+
if (asset.kind !== 'audio')
|
|
120
|
+
continue;
|
|
121
|
+
if (state.requestedAssetIds.has(asset.id))
|
|
122
|
+
continue;
|
|
123
|
+
queueAssetLoad(scene, asset);
|
|
124
|
+
state.requestedAssetIds.add(asset.id);
|
|
125
|
+
}
|
|
112
126
|
}
|
|
113
127
|
function collectAssetIds(entities, manifest, resolveTilemapFile) {
|
|
114
128
|
const ids = new Set();
|
|
@@ -345,10 +359,15 @@ function queueAssetLoad(scene, asset) {
|
|
|
345
359
|
}
|
|
346
360
|
return;
|
|
347
361
|
case 'audio':
|
|
348
|
-
|
|
362
|
+
// Fall back to `id` when `textureKey` is absent. Audio (and json) entries
|
|
363
|
+
// are naturally written as `{ id, path, kind:'audio' }` — "textureKey" is
|
|
364
|
+
// a misnomer for a sound — so an agent/human routinely omits it. Without
|
|
365
|
+
// the fallback the clip loads under key `undefined` and `sound.play(id)`
|
|
366
|
+
// silently no-ops (the "generated BGM never plays" bug).
|
|
367
|
+
scene.load.audio(asset.textureKey || asset.id, asset.path);
|
|
349
368
|
return;
|
|
350
369
|
case 'json':
|
|
351
|
-
scene.load.json(asset.textureKey, asset.path);
|
|
370
|
+
scene.load.json(asset.textureKey || asset.id, asset.path);
|
|
352
371
|
return;
|
|
353
372
|
default: {
|
|
354
373
|
const exhaustive = asset.kind;
|