One shot

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++) {

We set the x and y coordinates from ...

Get Android: Game Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.