Yes! I did check but forgot to mention here. I describe it as:
number of times that command can be called in a single frame/update
Yes! I did check but forgot to mention here. I describe it as:
number of times that command can be called in a single frame/update
Hey all, thanks so much for all your help and feedback, I finally got it working more or less the way I want it. It's still a little rough but I wanted to share it with you all to hear your thoughts or feedback.
Meet glitterbomb:
The main class is called ParticleEmitter, which you initialize by passing it an image. There's also a class called AnimatedParticleEmitter that does the same thing but with an image table. You can manually position the emitter, or give it a velocity so it moves each frame.
Right now, the default behavior is to emit particles randomly given certain parameters (discussed below) but could easily be changed to whatever pattern you want.
Right now, the settings are:
You can either set these variables on initialization by passing them as a table, or can set them manually with functions like setEmissionRate, setEmissionForce, etc. I've included a demo app so you can see some of the functionality and examples of how to use it.
Right now, I've found that I can get over 100 particles on device at 30FPS, and closer to 50 particles if they're animated (note: if anyone has thoughts on how to improve it I would love to hear it!)
I've found that animating scale and opacity was too expensive to do, so instead I recommend baking any size or opacity changes into your animation. To that end, I also created a second mini "app" called glitterglue. With glitterglue, you can create a ParticleEmitter, but rather than draw onscreen it draws a particle frame by frame to a sprite sheet so you can import it as an ImageTable to an AnimatedParticleEmitter later (I'm sure there's a more elegant way of going about this but that's what I have so far). Right now, it just animates size and opacity, but I'm sure could be extended to rotation or other animations.
Anyways, would love for you all to take a look, try it out, and let me know what you think!
Hey all, so I've made a few more improvements and feel like it's ready for people to use. There are a few more features I'm trying to get in, but in the meantime I wanted to share some findings I made during the process of optimizing it to run on device (big thanks to Matt for his benchmarking tool):
Curious to hear if you all have any thoughts!
Great! Thanks for the detailed summary.
Does this increase the number of particles you're pushing around?
edit: from 30 particles up to 100! Nice.
Oh sorry yes! Forgot to mention it here, but originally it could support around 30 particles at a time and now itās over 100. I also added the ability to load imagetables for animated particles (as well as a utility to create imagetables that animate a particleās size/opacity) and even there it can support 50+ animated particles.
The one remaining issue is there is a framerate spike every 5-10 seconds which seems to be due to the garbage collector? But other than that Iām very pleased with where itās at.
You can change the frequency of the garbage collector, or trigger it yourself. If you're reusing particles then the question is "what garbage is building up?"
Triggering the GC yourself allows you to see how much has been freed. Let's track it down!
Interesting! Is there a way to see what garbage the GC is collecting?
And I did see that! Itās funny that I built this because there was no particle system solution, then the next day someone else made one
I really like the stylized look of their particles, and I may try adding something like that here.