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

function CenterMessageText() {
	Phaser.Text.call(
		this, game,
		game.world.width / 2,
		game.world.height / 2 - CenterMessageText.MOVE_AMOUNT_PX,
		"",
		CenterMessageText.DEFAULT_TEXT_FONT
	);

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

	// var grd = this.context.createLinearGradient(0, 0, 0, this.height);
	// grd.addColorStop(0, CenterMessageText.COLOR_GRADATION_START); //'#FFD68E');
	// grd.addColorStop(1, CenterMessageText.COLOR_GRADATION_END); //'#B34C00');
	// this.fill = grd;
	// this.fill = CenterMessageText.COLOR_TEXT;
	// this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
	this.stroke = CenterMessageText.COLOR_STROKE;
	this.strokeThickness = 9;

	this.tweenAlpha = game.add.tween(this);
	this.tweenAlpha.to( { alpha: 0 }, CenterMessageText.TWEEN_ALPHA_TIME, Phaser.Easing.Elastic.In, false);
	// this.tweenAlpha.onComplete.addOnce(this.hide, this);

	this.timerEventTween = null;

	this.alpha = 0;
	game.add.existing(this);
};

CenterMessageText.prototype.showText = function(wordLevel, wordLevelText) {
	if(this.timerEventTween)
		game.time.events.remove(this.timerEventTween);

	if(this.tweenAlpha != null)
		this.tweenAlpha.stop();

	this.text = "[ " + wordLevelText + " ] 단계 활성화";
	this.fill = GameLevelManager.CENTER_MESSAGE_TEXT_COLOR_LIST[wordLevel];
	this.stroke = GameLevelManager.CENTER_MESSAGE_STROKE_COLOR_LIST[wordLevel];
	// console.log(this.fill);
	// console.log(this.stroke);

	this.alpha = 1;
	this.tweenAlpha.start();

	this.timerEventTween = game.time.events.add(CenterMessageText.TWEEN_ALPHA_TIME, this.hide, this);
}

CenterMessageText.prototype.hide = function() {
	this.alpha = 0;
}

CenterMessageText.DEFAULT_TEXT_FONT = {
	font: "bold 40px Arial",
	boundsAlignH: "center",		// left, center. right
	boundsAlignV: "middle", 	// top, middle, bottom
	fill: "#ffffff"
};

CenterMessageText.MOVE_AMOUNT_PX		= 100;
CenterMessageText.TWEEN_ALPHA_TIME		= 1500;

CenterMessageText.COLOR_TEXT			= "#ffcc00";
CenterMessageText.COLOR_GRADATION_START	= "#B34C00";
CenterMessageText.COLOR_GRADATION_END	= "#333333";
CenterMessageText.COLOR_STROKE			= "#663300";