Jump to content

Count emitted particles


Lektorelli
 Share

Recommended Posts

I'm obviously missing the obvious here. But how do you count the number of emitted particles at any given time? Imagine a particle emitter that sits in the top of the game canvas, and dropping particles that falls to the bottom. At the bottom there is some "dude" catching the particles and gets a point for each catched particle. There scoreboard may read something like "Points: 4 of 7" and a little while later it may read "Points: 8 of 13". How do you get the 7 and the 13?

Link to comment
Share on other sites

I can think of a couple of different ways of doing this. If you make a custom particle class, there's an "onEmit" method you can override to increment the count. You could call "countLiving" on the emitter itself, but that's pretty dependent on what happens to those particles later (i.e. if you kill them or destroy them or re-use them otherwise later). You could also collide the particle with something just off the bottom of the screen and add those to the count as misses, or collide them with something just below the emitter and add them as total.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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