Author Topic: Current state of particles and emitters  (Read 2376 times)

tackle

  • Member
  • **
  • Posts: 18
  • Karma: +0/-0
    • View Profile
    • karlmacklin.com - blog/portfolio
Current state of particles and emitters
« on: Tue, May 10, 2011 »
I'm still in the very early learning stages of this game framework, and I'm creating this thread to hopefully get some light shed on the current state of particles and emitters.

As I've gathered, particles are basically extended FlxSprites, and FlxEmitters emit these. I recall the documentation (or some line somewhere) stating that the particle system isn't optimized.

My main question is to all the other developers here:
If you need functionality in your particles that can't be achieved through the current features, do you simply extend the FlxParticle class and add what you need?

Secondary question regards performance:
Considering the particle system being non-optimized (if you can call FlxSprites that), do feel the need for a more emitter/particle focused optimization?

I'm used to the FLiNT particle system and I'm missing a lot of features from it. Nothing I couldn't code myself on top of the current setup, but I wonder if it's better to try to implement a new type of object that draws the particles rather than relying on FlxSprite.

Thoughts?

Adam Atomic

  • Founder
  • Key Contributor
  • *****
  • Posts: 852
  • Karma: +0/-0
  • new dad
    • View Profile
    • Adam Atomic
Re: Current state of particles and emitters
« Reply #1 on: Wed, May 11, 2011 »
hey tackle!  you've got the right idea.  I would say you have two options, both of which are fairly easy, but the main differentiator is PERFORMANCE.  If you need like... more than 500 particles, collision is not important, and you are doing a lot of visual processing (rotation, alpha, etc) then I think making your own emitter is probablyt he right idea.  I suspect you could extend FlxEmitter and just ignore the fact that its a group, and repurpose the start/stop functionality, and do your own rendering.

If performance isn't a big deal, and you just want more interesting particle behavior (like wiggling around, changing direction, scaling, etc) then just extend FlxParticle.  You can even set the default particle class of the emitter before calling makeParticles() in order to easily substitute in your custom class.

hope that helps!

tackle

  • Member
  • **
  • Posts: 18
  • Karma: +0/-0
    • View Profile
    • karlmacklin.com - blog/portfolio
Re: Current state of particles and emitters
« Reply #2 on: Wed, May 11, 2011 »
Yup, that helps, thanks!

I'll run with FlxParticle extensions until I need more horsepower, then I know where to start modding.

zliuyanv

  • New Member
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
    • replica tag heuer
Re: Current state of particles and emitters
« Reply #3 on: Wed, Jun 15, 2011 »
You can even set the default particle class of the emitter before calling makeParticles() in order to easily substitute in your custom class.

John Hutchinson (Johntron247)

  • Commodore 256
  • Contributor
  • ****
  • Posts: 392
  • Karma: +1/-0
  • I can has lazerz?
    • View Profile
    • Level X Games
Re: Current state of particles and emitters
« Reply #4 on: Mon, Aug 8, 2011 »
I did this over the weekend and extending the classes works very well.  I was originally planning on writing the entire emitter and particle classes myself, because I needed them to do more and to be as friendly to the garbage collector as possible. However, after reviewing how they were implemented, extending the classes definitely made more sense.  The classes are actually pretty lightweight already, the particles are recycled, and the extendability is very good. I got mine running on my Android Atrix with lots of particles fading out and changing colors and it ran at a steady 40-45fps (which I capped at 30fps just for good measure).

One thing to note, if you happen to be working with mobile devices, is that flixel doesn't play well with the GPU, and worthwhile optimization requires serious restructuring of the flixel libraries. This is especially true when adding lots of sprites like particles.  With it set to use the GPU, even with a handful of optimizations in place, I was only getting 15-20fps, but once I switched back to using the CPU instead it ran really fast and smooth.

Good luck!