Game Development Reference
In-Depth Information
This is the variable where we are going to hold a reference to our loaded and ready-
to-fire dust particle effect. Next, make the following modifications to the same class:
public void init () {
...
// Power-ups
hasFeatherPowerup = false;
timeLeftFeatherPowerup = 0;
// Particles
dustParticles.load(Gdx.files.internal("particles/dust.pfx"),
Gdx.files.internal("particles"));
}
@Override
public void update (float deltaTime) {
super.update(deltaTime);
...
dustParticles.update(deltaTime);
}
@Override
public void render (SpriteBatch batch) {
TextureRegionreg = null;
// Draw Particles
dustParticles.draw(batch);
// Apply Skin Color
...
}
As you can see, only a few changes were required to implement the dust particle
effect in the game. The particle effect is loaded in init() and is continuously
updated and rendered in update() and render() , respectively. However, calling
draw() on a particle effect does not mean that it is always going to be rendered.
The particle effect needs to be triggered first to start playing. Furthermore, if it is
a continuous particle effect, it also needs to be stopped explicitly to become
invisible again.
 
Search WWH ::




Custom Search