Files
chocomae/src/game/lib/score_text.js
T
2018-05-15 16:10:21 +09:00

41 lines
1.0 KiB
JavaScript

class ScoreText extends Phaser.Text {
constructor(x, y, score) {
super(game, x, y, "+" + NumberUtil.numberWithCommas(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;