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 like this:
@Override public void onUpdate(long elapsedMillis, GameEngine gameEngine) { if (!mIsEmiting){ return; } mTotalMillis += elapsedMillis; // We have to make sure that we have to keep emiting while ( !mParticlePool.isEmpty() &...