Skip to content Skip to sidebar Skip to footer

How Do I Pause The SpriteAnimation In LibGDX With A Button To Be Able To View The Current Frame When Pause Button Is Pressed?

I was trying to pause the animation with a pause/resume button, by doing this : public static int gameStatus = 1; public int gamePaused = 0; public int gameRunning = 0; public void

Solution 1:

I did the pause implementation without any flickering issues like I had by simply removing the spriteBatch.draw() from the pause method, and by using a boolean variable to know when to render and when not to render inorder to pause the animation. This is how I did it (in case anyone had the same issues):

private boolean isPlaying = true;

    @Override
    public void pause() { 
    Gdx.app.log("pause():", "pausing the app");
        if( isPlaying )
        {
            isPlaying = false;
        }
        else
        {
            isPlaying = true;
        }


    }

    @Override
    public void render() {      

    Gdx.app.log("123123", (!seekBar.isDragging())+"");
    if( isPlaying )
              // .. do the animation.. 
    }

Post a Comment for "How Do I Pause The SpriteAnimation In LibGDX With A Button To Be Able To View The Current Frame When Pause Button Is Pressed?"