Skip to content

Game Screens

Anastasia Laczko edited this page Jun 11, 2021 · 11 revisions

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);
  }

Table of Contents

Home

How to Play

Introduction

Game Features

Main Character

Enemies
The Final Boss

Landscape Objects

Shop
Inventory
Achievements
Camera

Crystal

Infrastructure

Audio

User Interfaces Across All Pages
Juicy UI
User Interfaces Buildings
Guidebook
[Resource Management](Resource-Management)
Map
Day and Night Cycle
Unified Grid System (UGS)
Polishing

Game Engine

Getting Started

Entities and Components

Service Locator

Loading Resources

Logging

Unit Testing

Debug Terminal

Input Handling

UI

Animations

Audio

AI

Physics

Game Screens and Areas

Terrain

Concurrency & Threading

Settings

Troubleshooting

MacOS Setup Guide

Clone this wiki locally