Jump to content

Particles fading out


personalnadir
 Share

Recommended Posts

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 loop

emitter.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

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...