Emitters

The other way to use particle systems is to configure them as emitters. This means that there is a ratio of particles per second that your system emits while it is active.

Calculating the right pool size is quite easy. It is just a formula based on the particle's time to live and the number of particles per second you want. For example, using 20 particles per second with 500 milliseconds time to live, you only need a pool of 10 particles, since they are returned to the pool as they die.

It is important to remember that a ParticleSystem working as an emitter needs to be added and removed from the GameEngine, since the onUpdate method is required to check for the spawning of more particles. The onUpdate method of the ParticleSystem looks ...

Get Android Game Programming: A Developer’s Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.