Mariusz Posted February 28, 2014 Share Posted February 28, 2014 Hello guys. I'm trying to create an explosion effect in my game and the following is my approach to the problem. The explosion consists of one explosion particle, several smoke particles and some sparkle particles. Thus I'm thinking of having three emitters. So good so far. However, I'd like the particles to animate in some ways, e.g. diminish and fade out smoothly rather than having them disappear after a certain interval. I've looked into Phaser and tried to set my custom sprite class to the particleClass property in the Emitter function, to no avail. Iterating over the group and setting a tween to each child doesn't seem like an option, since that would interfere with other particles emitted in another place in the game. What's the 'proper' approach to the problem? Thanks in advance.Mariusz kstamatov85 1 Link to comment Share on other sites More sharing options...
lessmilk Posted February 28, 2014 Share Posted February 28, 2014 You can iterate over the particles of a single emitter like this:emitter_smoke.forEachAlive(function(p) { p.alpha -= 1; }So it shouldn't interfere with other emitters. Heppell08 1 Link to comment Share on other sites More sharing options...
Heppell08 Posted February 28, 2014 Share Posted February 28, 2014 Try fading the particles with a timer inside a function. That way you can have a wait period then update into a fade without tweens. I use alpha += 0.01 for fading inside my update but you can play with that if needed. If you have other particles that don't require the fade then set the alpha back to normal after the fade is complete. A quick if statement on the particles in update to set that back up and it should work fine. Its what I would do anyway. Hope this helps Link to comment Share on other sites More sharing options...
Recommended Posts