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

feat: #fe use button for game over screen

parent 5f9b1cc9
No related branches found
No related tags found
No related merge requests found
...@@ -3,8 +3,24 @@ import { FONTS } from "./assets"; ...@@ -3,8 +3,24 @@ import { FONTS } from "./assets";
import BackgroundScene from "./background_scene"; import BackgroundScene from "./background_scene";
import { formatTime, ICONS, THIN_SPACE } from "./hud"; import { formatTime, ICONS, THIN_SPACE } from "./hud";
const BUTTON_HIGHLIGHT_COLOR = "darkorange";
const TEXT_STYLE: {
[key: string]: Phaser.Types.GameObjects.Text.TextStyle;
} = {
BUTTON: {
fontFamily: FONTS.MONO,
fontStyle: "bold",
color: "white",
stroke: "black",
strokeThickness: 8,
testString: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
},
};
export default class GameOverScene extends Phaser.Scene { export default class GameOverScene extends Phaser.Scene {
music!: Phaser.Sound.BaseSound; music!: Phaser.Sound.BaseSound;
continueButton!: Phaser.GameObjects.Text;
constructor() { constructor() {
super("game_over"); super("game_over");
...@@ -95,26 +111,29 @@ export default class GameOverScene extends Phaser.Scene { ...@@ -95,26 +111,29 @@ export default class GameOverScene extends Phaser.Scene {
} }
drawCTA() { drawCTA() {
const text = "press to continue"; const verb = this.game.device.os.desktop ? "Click" : "Tap";
const cta = this.add.text(0, 0, text, { const text = `${verb} to continue`;
fontSize: "32px", this.continueButton = this.add
fontFamily: FONTS.MONO, .text(this.cameras.main.centerX, this.cameras.main.height * 0.8, text, {
fontStyle: "bold", ...TEXT_STYLE.BUTTON,
color: "#ffffff", fontSize: "32px",
}); })
cta.setOrigin(0.5, 0); .setOrigin(0.5, 0)
cta.setPosition( .setPadding(4)
this.cameras.main.width * 0.5, .setInteractive({ useHandCursor: true })
this.cameras.main.height * 0.8, .on("pointerover", () =>
); this.continueButton.setStyle({ stroke: BUTTON_HIGHLIGHT_COLOR }),
)
.on("pointerout", () =>
this.continueButton.setStyle({ stroke: TEXT_STYLE.BUTTON.stroke }),
);
} }
bindEvents() { bindEvents() {
this.input.keyboard.once("keyup", this.startFight.bind(this)); this.continueButton.on("pointerup", this.backToWelcome.bind(this));
this.input.once("pointerup", this.startFight.bind(this));
} }
startFight() { backToWelcome() {
(this.scene.get("background") as BackgroundScene).liftCurtain(); (this.scene.get("background") as BackgroundScene).liftCurtain();
this.scene.start("welcome", { music: this.music }); this.scene.start("welcome", { music: this.music });
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment