0
\$\begingroup\$

In my game over screen for my Libgdx Android game I've the following code which starts a new game upon a screen touch.

       if(Gdx.input.isTouched()) {
        ScreenManager.setScreen(new GameScreen());
    }

A new game starts but none of the sprites are displayed on screen.

I've confirmed that a new game has started through logging and through use of the debugger. Also the game over screen eventually reappears after some time due to the player dying.

What's interesting is that if I hit the home button or bring up the running apps menu in Android and re-enter the app, the sprites display fine.

Both my GameOver screen and Game screen are classes which implement a Screen interface

Anyone have an idea of what could be causing the sprites not to display?

Here is my ScreenManager class which can either set or get the screen.

public class ScreenManager {

private static Screen currentScreen;

public static void setScreen(Screen screen) {
    if (currentScreen != null) {
        currentScreen.dispose();
    }
        currentScreen = screen;
        currentScreen.create();

}

public static Screen getCurrentScreen() {
    return currentScreen;
}

}

\$\endgroup\$
  • \$\begingroup\$ What does your ScreenManager class do? \$\endgroup\$ – bornander Mar 30 '15 at 14:24
  • \$\begingroup\$ @bornander My ScreenManager class can either get or set the screen. I've added to the code to my original question. \$\endgroup\$ – ConorB Mar 30 '15 at 16:03
  • \$\begingroup\$ You're not loading the assets for the Screen in the Screen's create method are you? Swapping to a screen should be fast, so you'll want most of that work done long before you initiate the screen change. \$\endgroup\$ – bornander Mar 31 '15 at 7:24
  • \$\begingroup\$ @bornander I am actually, I don't think that is what's causing the issue though. I only have 2 textures to load! It's a very simple game. \$\endgroup\$ – ConorB Mar 31 '15 at 16:04
  • \$\begingroup\$ Possible duplicate of Screen not rendering after restarting game \$\endgroup\$ – Anko Dec 7 '15 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.