-
Notifications
You must be signed in to change notification settings - Fork 0
Game Screens
Anastasia Laczko edited this page May 30, 2021
·
11 revisions
The game contains several screen which which each implement libgdx's ScreenAdapter interface. Screen are responsible for initiating important game services, loading screen resources, drawing the background and UI, rendering the entities, handling input, etc.
Only one screen is shown at a time and GDXGame.java
contains functionality for transitioning between screens. Screen transitions are triggered by the current screen.
Within the base game, there are 3 screens: Main Menu Screen, Main Game Screen, and Settings Screen. The Main Menu Screen is the starting screen.
Create a new screen class, e.g. NewScreen.
public class NewScreen extends ScreenAdapter {
...
}
Then, register the new screen in GDXGame.java
by adding NEW_SCREEN
to ScreenType
and modifying newScreen
:
private Screen newScreen(ScreenType screenType) {
switch (screenType) {
...
case NEW_SCREEN:
return new NewScreen(this);
...
}
}
public enum ScreenType {
MAIN_MENU, MAIN_GAME, SETTINGS, NEW_SCREEN
}
private void switchScreen(GdxGame game, ScreenType screenType) {
game.setScreen(screenType);
}
The Final Boss
Shop
Inventory
Achievements
Infrastructure
User Interfaces Across All Pages
User Interfaces Buildings
Guidebook
[Resource Management](Resource-Management)