Cool Transition Effects for Indicators

Thought I would throw out another cool tip for… well… Desktop/Android dev… either one, me guesses.

Instead of calling Indicator.setCurrentValue directly, you can use a GameTimer with Interpolation to update the value and it does some reaaaaalllllly cool stuff!

The general idea is to set up a GameTimer like so:

[java]
float tempScore, incScore, currentScore, finalScore;

// indScore is an Indicator… duh
scoreTimer = new GameTimer(timerTime) {
@Override
public void onComplete(float time) {
indScore.setCurrentValue(finalScore);
}
@Override
public void timerUpdateHook(float tpf) {
incScore = tempScore*getPercentComplete();
indScore.setCurrentValue(currentScore+incScore);
}
};
scoreTimer.setInterpolation(Interpolation.bounceOut);
[/java]

So, instead of calling the Indicator directly, you set up a method that will fire off the GameTimer after setting a couple a variables to use during the update:

[java]
public void incScoreIndicator(float tempScore, float currentScore) {
this.tempScore = tempScore;
this.currentScore = currentScore;
this.finalScore = this.currentScore+this.tempScore;

scoreTimer.reset(false);
screen.getAnimManager().addGameTimer(scoreTimer);

}
[/java]

And the results look like this:

[video]http://youtu.be/vhaEc7T7xBE[/video]

2 Likes

Hey, wow that is awesome.
I love it.
Good job.