O'Reilly logo

LibGDX Cross-Platform Development Blueprints by Indraneel Potnis

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

Adding more effects

We will see how to add a stun effect to the mole in this section.

Stunning the mole

Let's add an effect where the mole is stunned for some time when we tap on it. We will need some more variables for this in the Mole class:

public enum State {GOINGUP,GOINGDOWN,UNDERGROUND,STUNNED}; // define mole's states
public float stunTime =0.1f; // The amount of time the mole would be stunned
public float stunCounter=0.0f; // The amount of time the mole is currently stunned

We add the STUNNED state to denote whether the mole is stunned or not. The stunTime variable denotes the amount of time the mole is to be kept in the STUNNED state, and the stunCounter variable is used to keep track of that time. As we are not sending the mole underground ...

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