overrun/js/scenes/GameOverScene.js

34 lines
885 B
JavaScript

export class GameOverScene extends Phaser.Scene {
constructor() {
super({ key: 'GameOverScene' });
}
create() {
const W = this.scale.width;
const H = this.scale.height;
this.add.rectangle(W / 2, H / 2, W, H, 0x000000, 0.75);
this.add.text(W / 2, H / 2 - 60, 'GAME OVER', {
fontFamily: 'FutureImperfect',
fontSize: '64px',
fill: '#ff3333',
stroke: '#660000',
strokeThickness: 6,
}).setOrigin(0.5);
const prompt = this.add.text(W / 2, H / 2 + 30, 'Press R to return to menu', {
fontSize: '24px',
fill: '#ffffff',
}).setOrigin(0.5);
this.tweens.add({ targets: prompt, alpha: 0, duration: 700, yoyo: true, repeat: -1 });
this.input.keyboard.once('keydown-R', () => {
this.scene.stop('GameScene');
this.scene.stop('GameOverScene');
this.scene.start('IntroScene');
});
}
}