I have a splash screen and a menu screen that loads all of my atlases of textures and skins for menus and handles a lot of things. If I placed the constructor for the menu screen in the SplashScreen constructor or in the create () method of my main game class (MyGame class), it will pass a lot of time without a splash screen and render the image on the phone while all the material is loading, so I postponed loading the menu class in the second frame rendering (called in the SplashScreen rendering method in the second frame); I just check if I went through the first frame, then I call the method in the main class of the game, which loads the menu.
Everything works fine, as expected, but only if the SplashScreen download process is not interrupted. If I get a call or I just press the HOME button on my mobile phone, and then I enter the game again by clicking on the icon on the main screen, I get an AndroidGraphics error message: "waiting for a pause to sync for too long: assuming deadlock and kill" ; this is right after I see the screen saver on the screen for about a second,
I tried to dispose of MyGame in the hide () and pause () methods of both the main game class and the splash screen class, so it stops if I press the HOME button, but they are never called.
How can i fix this? It would be unpleasant to receive a call while loading the game, and after you finish the call and try to enter the game again, it will work.
public class MyGame extends Game{ ... public MainMenu menu; ... @Override public void create(){ this.screen_type == SCREEN_TYPE.SPLASH; splashScreen = new SplashScreen(); setScreen(splashScreen); } ... @Override public void pause(){ //never gets called if I press the HOME button in middle of splash screen if(this.screen_type == SCREEN_TYPE.SPLASH) { this.dispose(); } } ... public void LoadMenuTimeConsumingConstructor(){ //load all menus and process data main_menu = new MainMenu(); loaded_menu = true; } } public class SplashScreen implements InputProcessor, Screen{ public MyGame main_game; ... public SplashScreen(MyGame game){ this.main_game = game; } @Override public void pause(){ //never gets called if I press the HOME button in middle of splash screen if(main_game.screen_type == SCREEN_TYPE.SPLASH) { main_game.dispose(); } } @Override public void hide(){ //never gets called if I press the HOME button in middle of splash screen if(main_game.screen_type == SCREEN_TYPE.SPLASH) { main_game.dispose(); } } @Override public void render(delta float){ ... //wait 1.5 sec if(TimeUtils.millis() - startTime > 1500){ { if(main_game.loaded_menu = true){ main_game.setScreen(main_game.main_menu); } } ... if(is_this_second_frame){ // we start loading menus in the second frame so we already have the splash onscreen main_game.LoadMenuTimeConsumingConstructor(); } ... } }
source share