Skip to content
Snippets Groups Projects
Commit 5140beef authored by Paolo.Brasolin's avatar Paolo.Brasolin
Browse files

feat: #fe music ramp up

parent ef1ad52f
No related branches found
No related tags found
No related merge requests found
...@@ -110,7 +110,7 @@ export default class FightScene extends Phaser.Scene { ...@@ -110,7 +110,7 @@ export default class FightScene extends Phaser.Scene {
init() { init() {
this.score = 0; this.score = 0;
this.health = 100; this.health = 1;
this.uiDimensions = this.initUiDimensions(); this.uiDimensions = this.initUiDimensions();
this.hud = new HUD(this, { this.hud = new HUD(this, {
...@@ -179,12 +179,8 @@ export default class FightScene extends Phaser.Scene { ...@@ -179,12 +179,8 @@ export default class FightScene extends Phaser.Scene {
}; };
} }
musicSoftReplace( musicSoftReplace(nextMusic: Phaser.Sound.BaseSound) {
nextMusic: Phaser.Sound.BaseSound, this.music.on("looped", () => {
prevMusic: Phaser.Sound.BaseSound,
) {
this.music = prevMusic;
this.music.on("complete", () => {
this.music.stop(); this.music.stop();
this.music.destroy(); this.music.destroy();
this.music = nextMusic; this.music = nextMusic;
...@@ -192,12 +188,23 @@ export default class FightScene extends Phaser.Scene { ...@@ -192,12 +188,23 @@ export default class FightScene extends Phaser.Scene {
}); });
} }
planMusicChanges() {
this.time.delayedCall(0 * 60 * 1000, () =>
this.musicSoftReplace(this.sound.add("bkg_main_1", { loop: true })),
);
this.time.delayedCall(5 * 60 * 1000, () =>
this.musicSoftReplace(this.sound.add("bkg_main_2", { loop: true })),
);
this.time.delayedCall(10 * 60 * 1000, () =>
this.musicSoftReplace(this.sound.add("bkg_main_3", { loop: true })),
);
}
async create(data: { music: Phaser.Sound.BaseSound }) { async create(data: { music: Phaser.Sound.BaseSound }) {
(this.scene.get("background") as BackgroundScene).atmosphere.play(); (this.scene.get("background") as BackgroundScene).atmosphere.play();
this.musicSoftReplace(
this.sound.add("bkg_main_1", { loop: true }), this.music = data.music;
data.music, this.planMusicChanges();
);
this.bindPauseShortcut(); this.bindPauseShortcut();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment