Tuesday, November 17, 2015

java - Sprites not being rendered on screen change - Android Libgdx


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;
}


}




No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...