Skip to content
Snippets Groups Projects
Commit 63ba9df6 authored by Paolo Brasolin's avatar Paolo Brasolin
Browse files

fix: game over cleanup procedure

parent acd5ef1c
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Delegate word API requests to scene in order to avoid scrambled events after game over.
- Spawner scene activity gates.
- Game over cleanup procedure.
## [1.10.5] - 2022-09-28
......
......@@ -49,19 +49,12 @@ export default class FightScene extends MainScene {
})
).data;
this.spawner.remove();
this.music.stop();
this.music.destroy();
this.game.records.updateLast({
level: this.getDifficulty(this.beGame.ended_at_gmtm ?? 0),
words: this.acceptedWords,
score: this.beGame.score ?? 0,
timer: this.beGame.ended_at_gmtm ?? 0,
});
this.scene.start("game_over");
}
//=[ Ambient transitions ]====================================================
......
......@@ -83,6 +83,12 @@ export default class MainScene extends Phaser.Scene {
async endGame() {
this.tweens.killAll();
this.time.removeAllEvents();
// TODO: this sucks, but it will be a FightScene
(this as any).spawner.remove();
this.music.stop();
this.music.destroy();
// TODO: are we being thorough? will the next frame always arrive in time to guarantee cleanup?
this.setGameTimePaused(true);
this.foes.forEach((foe) => foe.destroy());
......@@ -91,6 +97,8 @@ export default class MainScene extends Phaser.Scene {
this.typewriter.resetInputStatus();
await this.afterGameEnd();
this.scene.start("game_over");
}
async afterGameEnd() {
......
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