When I have to move some sprite on my scene (for example, on 100px down), I’m using this code:
Timer timer = new Timer();
for (int i=0; i<10; i++) {
delay+=frameDelay;
timer.schedule(new TimerTask() {
@Override
public void run() {
sprite.setPosition(sprite.getX(), sprite.getY()+10);
}
},delay);
}
It works, but I wonder if there is much correct and/or more fast possibilities to do this.
or look at the various Modifiers available – to move up/down, use a MoveYModifier – something like
The EaseBounceOut.getInstance() is just an example – it causes the Sprite to bounce at the end – there are lots of other EaseFunctions available.