Add: GameOverText
This commit is contained in:
@@ -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;
|
||||
@@ -101,11 +101,12 @@ class Game {
|
||||
startGame() {
|
||||
// activate first alien
|
||||
this.alienTimer.start();
|
||||
// this.activateNextAlien();
|
||||
}
|
||||
|
||||
gameOver() {
|
||||
this.alienTimer.stop();
|
||||
|
||||
let gameOverText = new GameOverText();
|
||||
}
|
||||
|
||||
activateNextAlien() {
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
<script src="../../game/lib/back_button.js"></script>
|
||||
<script src="../../game/lib/fullscreen_button.js"></script>
|
||||
<script src="../../game/lib/screen_bottom.js"></script>
|
||||
<script src="../../game/lib/game_over_text.js"></script>
|
||||
|
||||
<!-- Space Invaders : source files -->
|
||||
<script src="../../game/mouse/space_invaders/define_variables.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user