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 ...
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.