68 lines
1.8 KiB
JavaScript
68 lines
1.8 KiB
JavaScript
God = function(x, y, mainGame) {
|
|
this.mainGame = mainGame;
|
|
this.isActivated = true;
|
|
|
|
Phaser.Sprite.call(this, game, x, y, 'god_angry');
|
|
this.anchor.setTo(0.5, 1);
|
|
this.scale.set(0.5);
|
|
|
|
this.inputEnabled = false;
|
|
// this.input.enableDrag(false);
|
|
// this.events.onInputDown.add(this.onDown, this);
|
|
|
|
game.add.existing(this);
|
|
}
|
|
|
|
God.prototype = Object.create(Phaser.Sprite.prototype);
|
|
God.prototype.constructor = God;
|
|
God.prototype.update = function() {
|
|
}
|
|
|
|
|
|
God.prototype.onDown = function(sprite, pointer) {
|
|
console.log("onDown : " + pointer.x + ", " + pointer.y);
|
|
this.animateAngry();
|
|
}
|
|
|
|
God.prototype.isInRect = function(x, y) {
|
|
return true;
|
|
}
|
|
|
|
God.prototype.onDragStop = function(sprite, pointer) {
|
|
console.log("onDragStop : " + pointer.x + ", " + pointer.y);
|
|
}
|
|
|
|
God.prototype.setScale = function(size) {
|
|
this.scale.set(size);
|
|
this.backupScale = size;
|
|
}
|
|
|
|
|
|
God.prototype.animateHappy = function(type) {
|
|
this.loadTexture('god_happy');
|
|
this.mainGame.speechBubble.showSpeechBubble(type);
|
|
|
|
var tween = game.add.tween(this.scale);
|
|
tween.to({x:0.7, y:0.7}, 500, Phaser.Easing.Quadratic.Out, true, 0);
|
|
// tween.to({x:0.7, y:0.7}, 1000, Phaser.Easing.Elastic.InOut, true, 0, 2, true);
|
|
// tween.to({x:0.7, y:0.7}, 1000, Phaser.Easing.Linear.None, true, 0);
|
|
tween.onComplete.add(this.smileAgain, this);
|
|
tween.start();
|
|
}
|
|
|
|
God.prototype.animateAngry = function(type) {
|
|
this.loadTexture('god_angry');
|
|
this.mainGame.speechBubble.showSpeechBubble(type);
|
|
|
|
var tween = game.add.tween(this.scale);
|
|
tween.to({x:0.7, y:0.7}, 1000, Phaser.Easing.Bounce.Out, true, 0);
|
|
// tween.to({x:0.7, y:0.7}, 1000, Phaser.Easing.Elastic.InOut, true, 0, 2, true);
|
|
// tween.to({x:0.7, y:0.7}, 1000, Phaser.Easing.Linear.None, true, 0);
|
|
tween.onComplete.add(this.smileAgain, this);
|
|
tween.start();
|
|
}
|
|
|
|
God.prototype.smileAgain = function() {
|
|
this.scale.set(0.5);
|
|
this.loadTexture('god_smile');
|
|
} |