Skip to content

Instantly share code, notes, and snippets.

@apostroll
Last active September 9, 2015 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apostroll/b831c14f6d4ca63986a5 to your computer and use it in GitHub Desktop.
Save apostroll/b831c14f6d4ca63986a5 to your computer and use it in GitHub Desktop.
// Demo at http://codepen.io/anon/pen/gbXoXm
var game = new Phaser.Game(800, 600, Phaser.AUTO);
game.state.add('main', {create: create});
game.state.start('main', true, false);
var emitter;
function create() {
var pSize = game.world.width / 12.5;
var bmpd = game.add.bitmapData(pSize, pSize);
// Create a radial gradient, yellow-ish on the inside, orange
// on the outside. Use it to draw a circle that will be used
// by the FireParticle class.
var grd = bmpd.ctx.createRadialGradient(
pSize / 2, pSize /2, 2,
pSize / 2, pSize / 2, pSize * 0.5);
grd.addColorStop(0, 'rgba(193, 170, 30, 0.6)');
grd.addColorStop(1, 'rgba(255, 100, 30, 0.1)');
bmpd.ctx.fillStyle = grd;
bmpd.ctx.arc(pSize / 2, pSize / 2 , pSize / 2, 0, Math.PI * 2);
bmpd.ctx.fill();
game.cache.addBitmapData('flame', bmpd);
// Generate 100 particles
emitter = game.add.emitter(game.world.centerX, game.world.height, 100);
emitter.width = 3 * pSize;
emitter.particleClass = FireParticle;
// Magic happens here, bleding the colors of each particle
// generates the bright light effect
emitter.blendMode = PIXI.blendModes.ADD;
emitter.makeParticles();
emitter.minParticleSpeed.set(-15, -80);
emitter.maxParticleSpeed.set(15, -100);
emitter.setRotation(0, 0);
// Make the flames taller than they are wide to simulate the
// effect of flame tongues
emitter.setScale(3, 1, 4, 3, 12000, Phaser.Easing.Quintic.Out);
emitter.gravity = -5;
emitter.start(false, 3000, 50);
}
function FireParticle(game, x, y) {
Phaser.Particle.call(this, game, x, y, game.cache.getBitmapData('flame'));
}
FireParticle.prototype = Object.create(Phaser.Particle.prototype);
FireParticle.prototype.constructor = FireParticle;
@jvinhit
Copy link

jvinhit commented Sep 9, 2015

slow effect in mobile . tks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment