Fix biome selection causing bgm-related crash
parent
d3323aadce
commit
00f7bc595b
|
@ -453,13 +453,13 @@ export class SelectBiomePhase extends BattlePhase {
|
|||
start() {
|
||||
super.start();
|
||||
|
||||
this.scene.fadeOutBgm(2000, true);
|
||||
|
||||
const currentBiome = this.scene.arena.biomeType;
|
||||
|
||||
const setNextBiome = (nextBiome: Biome) => {
|
||||
if (this.scene.gameMode === GameMode.CLASSIC)
|
||||
this.scene.unshiftPhase(new PartyHealPhase(this.scene, false));
|
||||
else
|
||||
this.scene.fadeOutBgm(2000, true);
|
||||
this.scene.unshiftPhase(new SwitchBiomePhase(this.scene, nextBiome));
|
||||
this.end();
|
||||
};
|
||||
|
|
|
@ -867,11 +867,11 @@ export default class BattleScene extends Phaser.Scene {
|
|||
playNewBgm();
|
||||
});
|
||||
if (fadeOut) {
|
||||
this.fadeOutBgm(500, true);
|
||||
this.time.delayedCall(750, () => {
|
||||
const onBgmFaded = () => {
|
||||
if (loaded && (!this.bgm.isPlaying || this.bgm.pendingRemove))
|
||||
playNewBgm();
|
||||
});
|
||||
};
|
||||
this.time.delayedCall(this.fadeOutBgm(500, true) ? 750 : 250, onBgmFaded);
|
||||
}
|
||||
if (!this.load.isLoading())
|
||||
this.load.start();
|
||||
|
@ -887,7 +887,7 @@ export default class BattleScene extends Phaser.Scene {
|
|||
this.bgm.resume();
|
||||
}
|
||||
|
||||
fadeOutBgm(duration?: integer, destroy?: boolean): void {
|
||||
fadeOutBgm(duration?: integer, destroy?: boolean): boolean {
|
||||
if (!this.bgm)
|
||||
return;
|
||||
if (!duration)
|
||||
|
@ -895,7 +895,12 @@ export default class BattleScene extends Phaser.Scene {
|
|||
if (destroy === undefined)
|
||||
destroy = true;
|
||||
const bgm = this.sound.get(this.bgm.key);
|
||||
SoundFade.fadeOut(this, bgm, duration, destroy);
|
||||
if (bgm) {
|
||||
SoundFade.fadeOut(this, bgm, duration, destroy);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
playSound(soundName: string, config?: object) {
|
||||
|
|
Loading…
Reference in New Issue