Waiter.prototype = Object.create(Phaser.Sprite.prototype); Waiter.prototype.constructor = Waiter; function Waiter() { this.isActivated = true; Phaser.Sprite.call(this, game, Waiter.POSITION_X, Waiter.POSITION_Y, 'waiter'); this.anchor.setTo(0.5, 1); this.scale.set(0.5); this.x = Waiter.POSITION_X; this.inputEnabled = false; game.add.existing(this); this.speechBubble = new SpeechBubble(); this.speechBubble.flipHorizontal(); this.speechBubble.hide(); } Waiter.prototype.animateServing = function() { this.speechBubble.animateRoundSpeech(Waiter.SPEECH_X, Waiter.SPEECH_Y, "맛있게 드세요!"); this.x = Waiter.POSITION_X; this.show(); var tween = game.add.tween(this); tween.to({x:200}, Waiter.SERVING_WAIT_TIME_MS, Phaser.Easing.Linear.In, true, 0); tween.start(); game.time.events.add(Phaser.Timer.SECOND * 1, this.hide, this); } Waiter.prototype.hide = function() { this.alpha = 0; this.speechBubble.hide(); } Waiter.prototype.show = function() { this.alpha = 1; this.speechBubble.show(); } Waiter.POSITION_X = -150; Waiter.POSITION_Y = 340; Waiter.SERVING_WAIT_TIME_MS = 300; Waiter.SPEECH_X = Waiter.POSITION_X + 550; Waiter.SPEECH_Y = Waiter.POSITION_Y - 190;