Window and rendering
The Saxion Game App allows you to control the game window and rendering settings on desktop platforms. This includes fullscreen/windowed mode, resizing, window title, FPS, and VSync.
⚠️ Note: These methods only work on desktop platforms. They will throw an exception if used on mobile or web platforms.
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
);
Quitting the application
You can programmatically exit the game application by calling:
This signals LibGDX to terminate the application and close the game window. Use this method when you want to close the game, for example when the player selects an “Exit” option from a menu.
Window size
Gives you the exact size of the current window.
Current FPS
Switching to fullscreen
You can switch the game window to fullscreen using the current display mode:
This will make the game fill the entire screen.
Switching to windowed mode
To switch back to a window with a specific size:
Here 800 and 600 are the width and height of the window in pixels.
Enable or disable Resizing
You can allow or prevent the user from resizing the game window:
Changing the window title
You can dynamically change the title of the game window:
Check if fullscreen
You can check whether the game is currently in fullscreen mode:
Returns true if fullscreen, otherwise false.
Setting the target FPS
You can control how many frames per second the game tries to render:
This is useful for controlling the speed of the game loop and reducing CPU/GPU usage. The value must be greater than 0.
Enabling or disabling VSync
VSync synchronizes the frame rate with the monitor's refresh rate to prevent screen tearing: