From 8a7079837ef31844ad3714ab09007e5d5d2ad4d7 Mon Sep 17 00:00:00 2001 From: Noofreuuuh Date: Mon, 15 Apr 2024 00:10:25 +0200 Subject: [PATCH] manage HighScore --- Games/TutoPhaser/src/App.vue | 82 +++++++----------------- Games/TutoPhaser/src/game/PhaserGame.vue | 30 ++++----- Games/TutoPhaser/src/game/scenes/Game.ts | 7 ++ 3 files changed, 42 insertions(+), 77 deletions(-) diff --git a/Games/TutoPhaser/src/App.vue b/Games/TutoPhaser/src/App.vue index 1738d1f..697003b 100644 --- a/Games/TutoPhaser/src/App.vue +++ b/Games/TutoPhaser/src/App.vue @@ -1,66 +1,41 @@ diff --git a/Games/TutoPhaser/src/game/PhaserGame.vue b/Games/TutoPhaser/src/game/PhaserGame.vue index 717c930..a3f05a0 100644 --- a/Games/TutoPhaser/src/game/PhaserGame.vue +++ b/Games/TutoPhaser/src/game/PhaserGame.vue @@ -1,43 +1,35 @@ \ No newline at end of file + diff --git a/Games/TutoPhaser/src/game/scenes/Game.ts b/Games/TutoPhaser/src/game/scenes/Game.ts index 33cd8c8..609912f 100644 --- a/Games/TutoPhaser/src/game/scenes/Game.ts +++ b/Games/TutoPhaser/src/game/scenes/Game.ts @@ -191,6 +191,7 @@ export class Game extends Scene { star.disableBody(true, true); this.score += 10; this.scoreText.setText("Score: " + this.score); + EventBus.emit("highscore", this); if (this.stars.countActive(true) === 0) { this.stars.children.iterate((child) => { @@ -227,4 +228,10 @@ export class Game extends Scene { this.scene.start("Boot"); } } + + public updateHighScore(vueCallback: ({ highScore }: { highScore: number }) => void) { + if (vueCallback) { + vueCallback({ highScore: this.score }); + } + } }