While using one shot, we make the ParticleSystem
launch all the particles at once.
In this case, we do not need to add or remove the ParticleSystem
to or from the GameEngine
, because the onUpdate
method of the ParticleSystem
does not need to be called (it is only used to emit new particles).
While using one shot, it is only logical to initialize the particle pool with the same number of particles that we plan to use for the shot.
The oneShot
method of the ParticleSystem
class is as follows:
public void oneShot(GameEngine gameEngine, double x, double y, int numParticles) { mX = x; mY = y; mIsEmiting = false; for (int i=0; !mParticlePool.isEmpty() && i<numParticles; i++) { activateParticle(gameEngine); } }
We set the x and y coordinates from which we will emit and then set isEmitting
to false
. While updating isEmitting
is only necessary when the ParticleSystem
is added to the GameEngine
, we do it just to be safe. In this case, setting isEmitting
to false will...