diff --git a/src/game/lib/score_text.js b/src/game/lib/score_text.js
new file mode 100644
index 0000000..4e76c55
--- /dev/null
+++ b/src/game/lib/score_text.js
@@ -0,0 +1,41 @@
+class ScoreText extends Phaser.Text {
+
+ constructor(x, y, score) {
+ super(game, x, y, "+" + score, ScoreText.DEFAULT_TEXT_FONT);
+
+ this.anchor.set(0.5);
+ this.inputEnabled = false;
+
+ var grd = this.context.createLinearGradient(0, 0, 0, this.height);
+ grd.addColorStop(0, '#8ED6FF');
+ grd.addColorStop(1, '#004CB3');
+ this.fill = grd;
+ // this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
+ this.stroke = '#fff';
+ this.strokeThickness = 5;
+
+
+ let tweenAlpha = game.add.tween(this);
+ tweenAlpha.to( { alpha: 0 }, 1000, Phaser.Easing.Linear.None, true);
+
+ let tweenMoveUp = game.add.tween(this);
+ tweenMoveUp.to( { y: this.y - ScoreText.MOVE_UP_AMOUNT_PX }, 1000, Phaser.Easing.Linear.None, true);
+ tweenMoveUp.onComplete.addOnce(this.destroySelf, this);
+
+ game.add.existing(this);
+ };
+
+ destroySelf() {
+ this.destroy();
+ }
+
+}
+
+ScoreText.DEFAULT_TEXT_FONT = {
+ font: "30px Arial",
+ boundsAlignH: "center", // left, center. right
+ boundsAlignV: "middle", // top, middle, bottom
+ fill: "#fff"
+};
+
+ScoreText.MOVE_UP_AMOUNT_PX = 50;
\ No newline at end of file
diff --git a/src/game/mouse/space_invaders/alien.js b/src/game/mouse/space_invaders/alien.js
index d449030..3dbc0bd 100644
--- a/src/game/mouse/space_invaders/alien.js
+++ b/src/game/mouse/space_invaders/alien.js
@@ -94,10 +94,10 @@ class Alien extends Phaser.Sprite {
}
onFired() {
- this.goRandomPosition();
-
if(typeof this.onFiredFunction !== "undefined")
- this.onFiredFunction();
+ this.onFiredFunction(this);
+
+ this.goRandomPosition();
}
goRandomPosition() {
diff --git a/src/game/mouse/space_invaders/game.js b/src/game/mouse/space_invaders/game.js
index 178d5d6..6123875 100644
--- a/src/game/mouse/space_invaders/game.js
+++ b/src/game/mouse/space_invaders/game.js
@@ -89,8 +89,10 @@ class Game {
this.activatedAlienIndex++;
}
- onAlienFired() {
+ onAlienFired(sprite) {
console.log("onAlienFired");
+ console.log("x : " + sprite.x + ", y : " + sprite.y);
+ let scoreText = new ScoreText(sprite.x, sprite.y, 30);
}
onAlienEscaped() {
diff --git a/src/web/client/space_invaders.html b/src/web/client/space_invaders.html
index e3ddedf..cfaa73b 100644
--- a/src/web/client/space_invaders.html
+++ b/src/web/client/space_invaders.html
@@ -18,6 +18,7 @@
+