Search in sources :

Example 1 with BaseScreen

use of de.gg.screen.BaseScreen in project ProjektGG by eskalon.

the class ProjektGG method pushScreen.

/**
 * Pushes a screen to be the active screen. The screen has to be added to
 * the game beforehand via {@link #addScreen(String, BaseScreen)}.
 * <p>
 * {@link Screen#hide()} is called on the previously {@linkplain Game#screen
 * active screen} and {@link Screen#show()} is called on the new active
 * screen.
 *
 * @param name
 *            The name of the pushed screen.
 */
public void pushScreen(String name) {
    BaseScreen pushedScreen = this.screens.get(name);
    if (pushedScreen == null) {
        throw new ScreenNotFoundException("Could not find a screen named '" + name + "'. Add the screen via #addScreen(String, BaseScreen) first.");
    }
    if (screen != null) {
        screen.hide();
    }
    if (!pushedScreen.isLoaded()) {
        assetManager.load(pushedScreen);
        assetManager.finishLoading();
        pushedScreen.finishLoading();
    }
    pushedScreen.show();
    this.screen = pushedScreen;
}
Also used : ScreenNotFoundException(de.gg.exception.ScreenNotFoundException) BaseScreen(de.gg.screen.BaseScreen)

Aggregations

ScreenNotFoundException (de.gg.exception.ScreenNotFoundException)1 BaseScreen (de.gg.screen.BaseScreen)1