O'Reilly logo

Mastering Android Game Development by Raul Portales

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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++) {
    activateParticle(gameEngine);
  }
}

We set the x and y coordinates from ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required