ComboText.prototype = Object.create(Phaser.Text.prototype); ComboText.constructor = ComboText; function ComboText() { Phaser.Text.call( this, game, game.world.centerX, ComboText.TEXT_POS_Y, "", ComboText.DEFAULT_TEXT_FONT ); this.anchor.set(0.5); this.inputEnabled = false; var grd = this.context.createLinearGradient(0, 0, 0, this.height); grd.addColorStop(0, '#004CB3'); grd.addColorStop(1, '#8ED6FF'); // 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; game.add.existing(this); this.hide(); }; ComboText.prototype.show = function(comboCount, comboBonus) { this.hide(); var message = comboCount + "콤보 : +" + NumberUtil.numberWithCommas(comboBonus) + " 점"; this.text = message; this.alpha = 1; this.scale.set(1); this.tweenScale = game.add.tween(this.scale); this.tweenScale.to({x:0.7, y:0.7}, ComboText.TWEEN_SCALE_TIME, Phaser.Easing.Bounce.Out, true, 0); this.tweenScale.onComplete.add(this.fadeOut, this); this.tweenScale.start(); } ComboText.prototype.fadeOut = function(comboCount) { this.tweenFade = game.add.tween(this); this.tweenFade.to({alpha:0}, ComboText.TWEEN_FADE_OUT_TIME, Phaser.Easing.Quadratic.In, true, 0); this.tweenFade.onComplete.add(this.hide, this); this.tweenFade.start(); } ComboText.prototype.hide = function() { if(this.tweenFade != null) { this.tweenFade.stop(); this.tweenFade = null } if(this.tweenScale != null) { this.tweenScale.stop(); this.tweenScale = null; } this.alpha = 0; this.scale.set(1); } ComboText.DEFAULT_TEXT_FONT = { font: "bold 100px Arial", fontStyle: "italic", boundsAlignH: "center", // left, center. right boundsAlignV: "middle", // top, middle, bottom fill: "#fff" }; ComboText.TEXT_POS_Y = 120; ComboText.TWEEN_SCALE_TIME = 700; ComboText.TWEEN_FADE_OUT_TIME = 1000;