Class ScreenManager
java.lang.Object
de.gurkenlabs.litiengine.gui.screens.ScreenManager
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 Summary
ConstructorsConstructorDescriptionYou should never call this manually! Instead use theGame.screens()instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the specified screen instance to the manager.voidAdds the specified screen changed listener to receive events when the current screen was changed.current()Gets the currently active screen that is being rendered by theRenderComponent.voidDisplays the specified screen by settingvoidDisplays theScreenwith the specified name.Gets the screen by its name.getAll()Gets all screens of the game.intGets the screen change cooldown which is used to ensure that screens cannot be switched too quickly while the game is running.voidRemoves the specified screen instance from the manager.voidRemoves 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 theGame.screens()instance.- See Also:
-
-
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
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:
-
current
Gets the currently active screen that is being rendered by theRenderComponent.- 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.
-