Fix: change smoke animation sprite to particle effect
This commit is contained in:
@@ -1,37 +1,44 @@
|
||||
var SMOKE_START_OFFSET_Y = 200;
|
||||
var SMOKE_SPEED = 1;
|
||||
Smoke = function(type, x, y) {
|
||||
this.emitter = game.add.emitter(x, y, 50);
|
||||
// this.emitter = game.add.emitter(game.world.centerX, 500, 200);
|
||||
this.emitter.makeParticles("smoke");
|
||||
|
||||
/////////////////////////////
|
||||
// PlusScore Class
|
||||
this.emitter.width = 50;
|
||||
this.emitter.height = 50;
|
||||
this.emitter.setRotation(0, 0);
|
||||
this.emitter.setAlpha(0.3, 0.8);
|
||||
// this.emitter.setScale(0.5, 1);
|
||||
this.emitter.gravity = -300;
|
||||
this.emitter.start(false, 1000, 100);
|
||||
this.stop();
|
||||
|
||||
Smoke = function(game, x, y) {
|
||||
Phaser.Sprite.call(this, game, x, y - SMOKE_START_OFFSET_Y, 'smoke');
|
||||
|
||||
// this.anchor.set(0.5);
|
||||
this.scale.set(0.5);
|
||||
// console.log(this);
|
||||
// this.addColor("#ffffff", 0);
|
||||
// this.setStyle(textStyle);
|
||||
|
||||
this.inputEnabled = false;
|
||||
game.time.events.add(Phaser.Timer.SECOND * 1, this.fadePlusScore, this);
|
||||
game.time.events.add(Phaser.Timer.SECOND * 2, this.destroySelf, this);
|
||||
|
||||
game.add.existing(this);
|
||||
this.changeColor(type);
|
||||
}
|
||||
|
||||
Smoke.prototype = Object.create(Phaser.Sprite.prototype);
|
||||
Smoke.prototype.constructor = Smoke;
|
||||
Smoke.prototype.update = function() {
|
||||
this.y -= SMOKE_SPEED;
|
||||
Smoke.prototype.changeColor = function(type) {
|
||||
var color = 0xf0f0ed;
|
||||
|
||||
if(type == Meat.DONENESS_WELLDONE)
|
||||
color = 0xb06060;
|
||||
else if(type == Meat.DONENESS_BURN_BLACK)
|
||||
color = 0x333333;
|
||||
|
||||
this.emitter.forEach(
|
||||
function(particle) {
|
||||
particle.tint = color;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Smoke.prototype.fadePlusScore = function() {
|
||||
game.add.tween(this).to( { alpha: 0 }, 1000, Phaser.Easing.Linear.None, true);
|
||||
Smoke.prototype.start = function(x, y) {
|
||||
this.emitter.x = x; // + game.rnd.integerInRange(-10, 10);
|
||||
this.emitter.y = y + Smoke.OFFSET_POS_Y;
|
||||
this.emitter.on = true;
|
||||
}
|
||||
|
||||
Smoke.prototype.destroySelf = function() {
|
||||
this.destroy();
|
||||
Smoke.prototype.stop = function() {
|
||||
this.emitter.on = false;
|
||||
}
|
||||
|
||||
|
||||
Smoke.OFFSET_POS_Y = -20;
|
||||
Reference in New Issue
Block a user