I made a jumping animation but when i stop touching the screen, the animation stops.
Here is the code:
boolean touching = Gdx.input.isTouched();
long elapsed = (System.currentTimeMillis() - startTime)%1000;
if (touching){
float jump = 500 * (float)Math.sin(((Math.PI*2)/1000)*(elapsed/2));
sprite.setPosition(Gdx.graphics.getWidth()/2,jump);
}
How do i make the animation finish after i stop touching the screen?
Here is a gif of the code running: