ScoreText.prototype = Object.create(Phaser.Text.prototype);
ScoreText.constructor = ScoreText;

function ScoreText(x, y, score) {
	// super(game, x, y, "+" + NumberUtil.numberWithCommas(score), ScoreText.DEFAULT_TEXT_FONT);
	var scoreValue = Number(score);
	if(scoreValue > 0)
		Phaser.Text.call(this, game, x, y, "+" + NumberUtil.numberWithCommas(score), ScoreText.DEFAULT_TEXT_FONT);
	else if(scoreValue < 0)
		Phaser.Text.call(this, game, x, y, NumberUtil.numberWithCommas(score), ScoreText.DEFAULT_TEXT_FONT);

	if(this == undefined) {
		this.destroy();
		return;
	}

	this.anchor.set(0.5);
	this.inputEnabled = false;

	var grd = this.context.createLinearGradient(0, 0, 0, this.height);
	if(scoreValue < 0) {
		grd.addColorStop(0, ScoreText.COLOR_MINUS_SCORE_GRADATION_1);
		grd.addColorStop(1, ScoreText.COLOR_MINUS_SCORE_GRADATION_2);
	} else {
		grd.addColorStop(0, ScoreText.COLOR_PLUS_SCORE_GRADATION_1);
		grd.addColorStop(1, ScoreText.COLOR_PLUS_SCORE_GRADATION_2);
	}
	this.fill = grd;
	// this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
	this.stroke = '#fff';
	this.strokeThickness = 5;


	var tweenAlpha = game.add.tween(this);
	tweenAlpha.to( { alpha: 0 }, 1000, Phaser.Easing.Linear.None, true);

	var 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);
};

ScoreText.prototype.destroySelf = function() {
	this.destroy();
}


ScoreText.prototype.setScale = function(value) {
	this.scale.set(value);
}


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;

ScoreText.COLOR_PLUS_SCORE_GRADATION_1	= "#8ED6FF";
ScoreText.COLOR_PLUS_SCORE_GRADATION_2	= "#004CB3";

ScoreText.COLOR_MINUS_SCORE_GRADATION_1	= "#FFD68E";
ScoreText.COLOR_MINUS_SCORE_GRADATION_2	= "#B34C00";