Skip to content

Screens

A Screen represents a part of your game (like a menu, level, or settings screen). The Saxion Game App makes working with screens simple, while still letting you access all of LibGDX if needed.

This article mainly focuses on the ScalableGameScreen, since that is the type of screen that we advice you to use for your game! At the bottom of this article you will find more information about the alternatives (only useable by advanced users).

Creating ScalableGameScreen

The ScalableGameScreen is the default screen type and what most students should use (and where you want to start with)!

Automatically handles world coordinates, so your game logic can work consistently across different window sizes and resolutions. The camera mathematics are done for you, so you only need to worry about writing game logic and rendering.

Best for beginners or for quickly creating games where the camera does not need advanced behavior. Use the ScalableGameScreen if you want your world to remain consistent across different screen sizes. Please consult the documentation about coordinate systems to understand the difference between world and window coordinates.

public class MainMenuScreen extends ScalableGameScreen {

    public MainMenuScreen() {
        super(800, 600); // Define the size of the world
    }

    @Override
    public void show() {
        // Initialize screen-specific resources
    }

    @Override
    public void render(float delta) {
        // IMPORTANT: this will make sure world coordinates and the window coordinates are in sync.
        super(delta);

        // Your logic, input handling and rendering here
        GameApp.clearScreen("white");
        GameApp.startSpriteRendering();
        // Draw the button on the center of the screen
        GameApp.drawTextureCentered("buttonPlay", getWorldWidth()/2f, getWorldHeight()/2f);
        GameApp.endSpriteRendering();
    }

    @Override
    public void hide() {
        // Dispose screen-specific resources
    }
}

Registering screens

Your application will have one main class, where the application is started. This is also the place where you add the available screens to your application. You have to register every screen with a unique name. Registering screens can be done using:

GameApp.addScreen("MainMenu", new MainMenuScreen());
GameApp.addScreen("Level1", new Level1Screen());

Switching screens

When your application is active, you want to be able to switch to a different screen. For example when the user is game over, when the main menu needs to be shown or when the user needs to be sent to the next level.

You can switch screens by using the switchScreen method and providing the name of the screen:

GameApp.switchScreen("Level1");

Getting world dimensions

The world dimensions can be asked from the current Screen itself (no need to use the GameApp for that).

float width = getWorldWidth();
float height = getWorldHeight();

Starting the application

To launch your game, use GameApp.start():

GameApp.start(
    "My Game",   // Window title
    800,         // Width of the window
    600,         // Height of the window
    60,          // FPS
    false,       // Fullscreen
    "MainMenu"   // First screen to show
);

More information about controlling the application, see the Window and rendering settings article.

Example of starting the application

This is an example of what the starting class of the application could look like:

import nl.saxion.gameapp.GameApp;
import nl.saxion.gameapp.ScalableGameScreen;

public class Main {

    public static void main(String[] args) {
        // Register screens with unique names
        GameApp.addScreen("MainMenu", new MainMenuScreen());
        GameApp.addScreen("Level1", new Level1());

        // Start the game with the first screen
        GameApp.start(
            "My Saxion Game", // Window title
            800,              // Width of the window
            600,              // Height of the window
            60,               // Target FPS
            false,            // Fullscreen
            "MainMenu"        // First screen to display
        );
    }
}

Other screen types

All screens in Saxion Game App are based on the GameScreen, ScalableGameScreen or CameraControlledGameScreen class:

Creating ScalableGameScreen

The ScalableGameScreen has been explained in this article. It is the basic game screen that we advice you to use for your games.

Example use cases:

  • Puzzle games (e.g., Tetris-style)
  • Simple 2D platformers where the entire level is shown in the window
  • Menu screens or HUD-heavy applications
  • Card games or board games
  • Tower defense games with a fixed overview of the entire playing field

CameraControlledGameScreen (advanced)

This screen is experimental and was added last-minute. Students with some experience in object-oriented programming, who want scrolling, zoomable worlds without writing all camera math themselves could use this screen type.

  • Automatically handles a camera that follows a target, e.g., a player or moving object.
  • Includes smooth camera movement (lerping), automatic viewport scaling, and zooming (additive or multiplicative).
  • Clamps the camera so the viewport never shows outside the world.
  • Provides utility methods for mouse-to-world conversion, viewport edges, and HUD drawing.

Example use cases:

  • Platformers like Mario or Celeste (camera follows the player)
  • Top-down adventure games like Zelda (camera follows player through a large map)
  • Shoot ’em ups or twin-stick shooters with scrolling maps
  • RTS or strategy games with zoomable maps
  • Simulation games where the camera needs to track moving objects

There is a complete article about this screen in the Experimental features > Camera Controlled Screen section.

GameScreen (expert)

This screen gives full control over camera and viewport, but requires you to manage everything yourself.

  • You are responsible for creating and updating the camera, viewport, and projection matrices.
  • Advanced students can use it to experiment with custom rendering pipelines, dynamic zoom, multiple cameras, or special effects.
  • Only recommended for very advanced users with experience in game development and LibGDX.

Example use cases:

  • Strategy games with multiple cameras
  • Physics-based simulations where custom camera movement is required
  • Games with parallax layers or multiple viewports
  • Experimental or research projects requiring full control over rendering