Game Screens - UQcsse3200/2026-studio-4 GitHub Wiki

Introduction

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.

Screens can also be split into different Game Areas which can be used to create different levels and areas. Read more here!

Usage

Add a new 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
  }

Switch screen

  private void switchScreen(GdxGame game, ScreenType screenType) {
    game.setScreen(screenType);
  }

Workflow of current screens

Game Screen Flow



flowchart TD
    Start([Game starts]) --> Splash[SplashScreen]
    Splash -->|Intro animation finishes| Intro[IntroScreen]
    Intro -->|Intro finishes| Menu[MainMenuScreen]

    Menu -->|Start: choose next save slot| Game[MainGameScreen]
    Menu -->|Load| Load[LoadGameScreen]
    Menu -->|Settings| Settings[SettingsScreen]
    Menu -->|Exit| Exit([Exit game])

    Load -->|Select valid save| Game
    Load -->|Select empty slot: start new game| Game
    Load -->|Back| Menu

    Settings -->|Back| Menu

    Game -->|Player dies| Death[DeathScreen]
    Game -->|Run completed| Win[WinScreen]
    Game -->|Save and exit| Menu
    Game -->|Delete save and exit| Menu

    Death -->|Load savepoint| Game
    Death -->|Main Menu| Menu

    Win -->|Main Menu| Menu

    Game -.->|Screen change disposes current screen| Lifecycle[GdxGame manages screen creation and disposal]
    Menu -.-> Lifecycle
    Load -.-> Lifecycle
    Settings -.-> Lifecycle
    Death -.-> Lifecycle
    Win -.-> Lifecycle