personalnadir Posted October 28, 2013 Share Posted October 28, 2013 I'm trying to use the Emitter class to create a particle system where the particles slowly fade out as they age. Initially I tried the following in the update loopemitter.forEachAlive(function(p){ p.alpha-=alphaStep;}); However when I ran that, all the particles behaved as if they shared a common alpha value. I'm using the following initialisation line:emitter = game.add.emitter(game.world.centerX, game.world.centerY, 250);emitter.makeParticles('sparks', ["spark1.png"], 200, false, false);Where 'sparks' is a texture atlas. Any clues on where to look or what to approach to ensure that I can fade out particles individually? I'd also love to be able to render the particles using additive blending is that supported? Thanks, Link to comment Share on other sites More sharing options...
Aizat Posted October 28, 2013 Share Posted October 28, 2013 If you are using lifespanemitter.start(false, 1500, 20);function update() { emitter.forEachAlive(function(p){ p.alpha= p.lifespan / emitter.lifespan; });} Manifest, Titus, clark and 1 other 4 Link to comment Share on other sites More sharing options...
personalnadir Posted October 29, 2013 Author Share Posted October 29, 2013 Thanks for that - that works wonderfully. But out of interest, why was my approach not working? I can see that in your you're setting the alpha to the ratio of the particles life, which is the nicer approach, but I would have thought that mine would just reduce the alpha evenly on each particle individually while actually it work of behaved as if it were globally. Are particles pooled? Link to comment Share on other sites More sharing options...
Aizat Posted October 29, 2013 Share Posted October 29, 2013 maybeA new particle == old killed particle.and alpha remains the same Link to comment Share on other sites More sharing options...
Recommended Posts