public final class ScreenManager
extends java.lang.Object
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 and Description |
---|
ScreenManager()
You should never call this manually! Instead use the
Game.screens() instance. |
Modifier and Type | Method and Description |
---|---|
void |
add(Screen screen)
Adds the specified screen instance to the manager.
|
void |
addScreenChangedListener(ScreenChangedListener listener)
Adds the specified screen changed listener to receive events when the current screen was changed.
|
Screen |
current()
Gets the currently active screen that is being rendered by the
RenderComponent . |
void |
display(Screen screen)
Displays the specified screen by setting
|
void |
display(java.lang.String screenName)
Displays the
Screen with the specified name. |
Screen |
get(java.lang.String screenName)
Gets the screen by its name.
|
java.util.Collection<Screen> |
getAll()
Gets all screens of the game.
|
int |
getChangeCooldown()
Gets the screen change cooldown which is used to ensure that screens cannot be switched too quickly while the game is running.
|
void |
remove(Screen screen)
Removes the specified screen instance from the manager.
|
void |
removeScreenChangedListener(ScreenChangedListener listener)
Removes the specified screen changed listener.
|
void |
setChangeCooldown(int changeCooldown)
Sets the cooldown for changing screens.
|
public ScreenManager()
You should never call this manually! Instead use the Game.screens()
instance.
Game.screens()
public void addScreenChangedListener(ScreenChangedListener listener)
listener
- The listener to add.public void removeScreenChangedListener(ScreenChangedListener listener)
listener
- The listener to remove.public void add(Screen screen)
screen
- The screen to add.public void remove(Screen screen)
screen
- The screen to remove.public void display(Screen screen)
screen
- The screen to be displayed.public void display(java.lang.String screenName)
Screen
with the specified name.screenName
- The name of the screen to be displayed.public Screen get(java.lang.String screenName)
screenName
- The name of the screen.public java.util.Collection<Screen> getAll()
add(Screen)
public Screen current()
RenderComponent
.GameWindow.getRenderComponent()
,
RenderComponent.render()
public int getChangeCooldown()
DEFAULT_CHANGE_COOLDOWN
,
Game.hasStarted()
public void setChangeCooldown(int changeCooldown)
changeCooldown
- The cooldown for changing screens.