diff --git a/src/game/lib/game_over_text.js b/src/game/lib/game_over_text.js new file mode 100644 index 0000000..f9118d3 --- /dev/null +++ b/src/game/lib/game_over_text.js @@ -0,0 +1,46 @@ +class GameOverText extends Phaser.Text { + + constructor() { + super( + game, + game.world.width / 2, + game.world.height / 2 - GameOverText.MOVE_AMOUNT_PX, + "게임 오버", + GameOverText.DEFAULT_TEXT_FONT + ); + // super(game, 600, 300, "게임 오버", GameOverText.DEFAULT_TEXT_FONT); + + this.anchor.set(0.5); + this.inputEnabled = false; + + var grd = this.context.createLinearGradient(0, 0, 0, this.height); + grd.addColorStop(0, '#FFD68E'); + grd.addColorStop(1, '#B34C00'); + this.fill = grd; + // this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); + this.stroke = '#000'; + this.strokeThickness = 10; + + + this.alpha = 0; + let tweenAlpha = game.add.tween(this); + tweenAlpha.to( { alpha: 1 }, GameOverText.TWEEN_ALPHA_TIME, Phaser.Easing.Linear.None, true); + + let tweenMove = game.add.tween(this); + tweenMove.to( { y: game.world.height / 2 }, GameOverText.TWEEN_MOVE_TIME, Phaser.Easing.Bounce.Out, true); + + game.add.existing(this); + }; + +} + +GameOverText.DEFAULT_TEXT_FONT = { + font: "bold 100px Arial", + boundsAlignH: "center", // left, center. right + boundsAlignV: "middle", // top, middle, bottom + fill: "#fff" +}; + +GameOverText.MOVE_AMOUNT_PX = 200; +GameOverText.TWEEN_ALPHA_TIME = 1000; +GameOverText.TWEEN_MOVE_TIME = 1500; \ No newline at end of file diff --git a/src/game/mouse/space_invaders/game.js b/src/game/mouse/space_invaders/game.js index 0814144..116f32d 100644 --- a/src/game/mouse/space_invaders/game.js +++ b/src/game/mouse/space_invaders/game.js @@ -101,11 +101,12 @@ class Game { startGame() { // activate first alien this.alienTimer.start(); - // this.activateNextAlien(); } gameOver() { this.alienTimer.stop(); + + let gameOverText = new GameOverText(); } activateNextAlien() { diff --git a/src/web/client/space_invaders.html b/src/web/client/space_invaders.html index 887b5cd..707a4cb 100644 --- a/src/web/client/space_invaders.html +++ b/src/web/client/space_invaders.html @@ -27,6 +27,7 @@ +