Class ScreenManager

java.lang.Object
de.gurkenlabs.litiengine.gui.screens.ScreenManager

public final class ScreenManager extends Object
The ScreenManager holds instances of all available screens and handles whenever a different Screen should be shown to the player. It provides the currently active Screen for the Game’s RenderComponent which calls the Screen.render(Graphics2D) method on every tick of the RenderLoop. Overwriting this method provides the ability to define a customized render pipeline that suits the need of a particular Screen implementation. With the GameScreen, the LITIENGINE provides a simple default Screen implementation that renders the current Environment and all its GuiComponents.
See Also:
  • Constructor Details

    • ScreenManager

      public ScreenManager()
      You should never call this manually! Instead use the Game.screens() instance.
      See Also:
  • Method Details

    • addScreenChangedListener

      public void addScreenChangedListener(ScreenChangedListener listener)
      Adds the specified screen changed listener to receive events when the current screen was changed.
      Parameters:
      listener - The listener to add.
    • removeScreenChangedListener

      public void removeScreenChangedListener(ScreenChangedListener listener)
      Removes the specified screen changed listener.
      Parameters:
      listener - The listener to remove.
    • add

      public void add(Screen screen)
      Adds the specified screen instance to the manager.
      Parameters:
      screen - The screen to add.
    • remove

      public void remove(Screen screen)
      Removes the specified screen instance from the manager.
      Parameters:
      screen - The screen to remove.
    • display

      public void display(Screen screen)
      Displays the specified screen by setting
      Parameters:
      screen - The screen to be displayed.
    • display

      public void display(String screenName)
      Displays the Screen with the specified name.
      Parameters:
      screenName - The name of the screen to be displayed.
    • get

      public Screen get(String screenName)
      Gets the screen by its name.
      Parameters:
      screenName - The name of the screen.
      Returns:
      The
    • getAll

      public Collection<Screen> getAll()
      Gets all screens of the game.
      Returns:
      All screens that have been previously added to this instance.
      See Also:
    • current

      public Screen current()
      Gets the currently active screen that is being rendered by the RenderComponent.
      Returns:
      The currently active screen.
      See Also:
    • getChangeCooldown

      public int getChangeCooldown()
      Gets the screen change cooldown which is used to ensure that screens cannot be switched too quickly while the game is running.
      Returns:
      The current change timeout for screens.
      See Also:
    • setChangeCooldown

      public void setChangeCooldown(int changeCooldown)
      Sets the cooldown for changing screens.
      Parameters:
      changeCooldown - The cooldown for changing screens.