Files
chocomae/src/game/mouse/grilled_meat/smoke.js
T

51 lines
1.2 KiB
JavaScript

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");
this.emitter.width = 30;
this.emitter.height = 30;
this.emitter.setRotation(-90, 90);
this.emitter.setAlpha(0.3, 0.8);
// this.emitter.setScale(0.2, 0.2);
this.emitter.minParticleScale = 0.5;
this.emitter.maxParticleScale = 1;
this.emitter.gravity = -300;
if(type == Meat.DONENESS_RARE)
this.emitter.start(false, 1000, 400);
else if(type == Meat.DONENESS_WELLDONE)
this.emitter.start(false, 1000, 200);
else if(type == Meat.DONENESS_BURN_BLACK)
this.emitter.start(false, 1000, 100);
this.stop();
this.changeColor(type);
}
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.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.stop = function() {
this.emitter.on = false;
}
Smoke.OFFSET_POS_Y = -20;