Class ScreenManager
java.lang.Object
de.gurkenlabs.litiengine.gui.screens.ScreenManager
public final class ScreenManager
extends java.lang.ObjectThe
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.Constructor Summary
Constructors Constructor Description ScreenManager()You should never call this manually! Instead use theGame.screens()instance.Method Summary
Modifier and Type Method Description voidadd(Screen screen)Adds the specified screen instance to the manager.voidaddScreenChangedListener(ScreenChangedListener listener)Adds the specified screen changed listener to receive events when the current screen was changed.Screencurrent()Gets the currently active screen that is being rendered by theRenderComponent.voiddisplay(Screen screen)Displays the specified screen by settingvoiddisplay(java.lang.String screenName)Displays theScreenwith the specified name.Screenget(java.lang.String screenName)Gets the screen by its name.java.util.Collection<Screen>getAll()Gets all screens of the game.intgetChangeCooldown()Gets the screen change cooldown which is used to ensure that screens cannot be switched too quickly while the game is running.voidremove(Screen screen)Removes the specified screen instance from the manager.voidremoveScreenChangedListener(ScreenChangedListener listener)Removes the specified screen changed listener.voidsetChangeCooldown(int changeCooldown)Sets the cooldown for changing screens.
Constructor Details
ScreenManager
public ScreenManager()You should never call this manually! Instead use the
Game.screens()instance.- See Also:
Game.screens()
Method Details
addScreenChangedListener
Adds the specified screen changed listener to receive events when the current screen was changed.- Parameters:
listener- The listener to add.
removeScreenChangedListener
Removes the specified screen changed listener.- Parameters:
listener- The listener to remove.
add
Adds the specified screen instance to the manager.- Parameters:
screen- The screen to add.
remove
Removes the specified screen instance from the manager.- Parameters:
screen- The screen to remove.
display
Displays the specified screen by setting- Parameters:
screen- The screen to be displayed.
display
public void display(java.lang.String screenName)Displays theScreenwith the specified name.- Parameters:
screenName- The name of the screen to be displayed.
get
Gets the screen by its name.- Parameters:
screenName- The name of the screen.- Returns:
- The
getAll
Gets all screens of the game.- Returns:
- All screens that have been previously added to this instance.
- See Also:
add(Screen)
current
Gets the currently active screen that is being rendered by theRenderComponent.- Returns:
- The currently active screen.
- See Also:
GameWindow.getRenderComponent(),RenderComponent.render()
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:
DEFAULT_CHANGE_COOLDOWN,Game.hasStarted()
setChangeCooldown
public void setChangeCooldown(int changeCooldown)Sets the cooldown for changing screens.- Parameters:
changeCooldown- The cooldown for changing screens.
