God.prototype = Object.create(Phaser.Sprite.prototype); God.constructor = God; function God() { Phaser.Sprite.call(this, game, GAME_SCREEN_SIZE.x / 2, GAME_SCREEN_SIZE.y - 50, 'god_smile'); this.anchor.setTo(0.5, 1); this.scale.set(0.5); game.add.existing(this); game.physics.startSystem(Phaser.Physics.ARCADE); // this.emitter.x = GAME_SCREEN_SIZE.x / 2; this.emitter = game.add.emitter(GAME_SCREEN_SIZE.x / 2, 0); this.emitter.makeParticles("tile_choco"); this.emitter.gravity = 1000; } God.prototype.setScale = function(size) { this.scale.set(size); this.backupScale = size; } God.prototype.animateBigHappy = function(type) { this.loadTexture('god_happy'); 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:1, y:1}, 1500, 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(); this.particleBurst("BigHappy"); } God.prototype.animateBigSmile = function(type) { this.loadTexture('god_happy'); 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.8, y:0.8}, 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(); this.particleBurst("BigSmile"); } God.prototype.animateLittleSmile = function(type) { this.loadTexture('god_happy'); 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.6, y:0.6}, 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(); this.particleBurst("LittleSmile"); } God.prototype.animateBigAngry = function(type) { this.loadTexture('god_angry'); 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:1.5, y:1.5}, 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.animateLittleAngry = function(type) { this.loadTexture('god_angry'); 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.6, y:0.6}, 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'); } God.prototype.particleBurst = function(grade) { switch(grade) { case "BigHappy": this.emitter.y = GAME_SCREEN_SIZE.y - 350; this.emitter.setYSpeed(-700); this.emitter.minParticleScale = 1.3; this.emitter.minParticleScale = 1.5; this.emitter.start(true, 5000, null, 50); break; case "BigSmile": this.emitter.y = GAME_SCREEN_SIZE.y - 250; this.emitter.setYSpeed(-600); this.emitter.minParticleScale = 1.1; this.emitter.minParticleScale = 1.3; this.emitter.start(true, 5000, null, 20); break; case "LittleSmile": this.emitter.y = GAME_SCREEN_SIZE.y - 200; this.emitter.setYSpeed(-500); this.emitter.minParticleScale = 1; this.emitter.minParticleScale = 1.1; this.emitter.start(true, 5000, null, 10); break; } }