0
\$\begingroup\$

I have a screen class in libGDX. In this screen, I want to change a sprite's texture a certain number of times before the screen changes to a different screen class. I tried having a for loop in the render method, but that obviously didn't work as render is constantly called.

Can anyone help?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Try this

private long time;

public void show(){
//...
        time = System.currentTimeMillis();

}
public void draw(){
//...
       if(System.currentTimeMillis()>time+3000){
            time = System.currentTimeMillis();
            System.out.println("called after 3 seconds");
            //change texture
        }
}

So you can change your Sprite's Texture every 3 seconds.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .