Class GameApp

java.lang.Object
nl.saxion.gameapp.GameApp

public class GameApp extends Object
A static utility wrapper around the LibGDX framework that simplifies game development and screen management.

Typical usage involves calling start(String, int, int, int, boolean, String) to initialize the game and then using switchScreen(String) to transition between different game screens.

Example:


 public class MyGame {
     public static void main(String[] args) {
         GameApp.start("My Game", 1280, 720, 60, false, "MainMenu");
     }
 }
 

Screens must be registered before switching, typically through a static registration method or within the game's initialization logic.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Inner class that extends the Game object of LibGDX Used for initializing the game and loading the first screen.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addAnimation(String name, com.badlogic.gdx.graphics.g2d.TextureRegion[] frames, float frameDuration, boolean loop)
    Adds a new animation using manually specified frames.
    static void
    addAnimationFrameFromAtlas(String animationName, String atlasName, String regionName)
    Adds a single region from an atlas to an existing animation.
    static void
    addAnimationFrameFromSpritesheet(String animationName, String spritesheet, int row, int col)
    Adds a single frame from a spritesheet (by row and column) to an existing animation.
    static void
    addAnimationFromAtlas(String name, String atlasName, String prefix, float frameDuration, boolean loop)
    Creates a new animation using all regions in a given atlas that match a prefix.
    static void
    addAnimationFromSpritesheet(String name, String spritesheet, float frameDuration, boolean loop)
    Adds a new animation using all frames from the specified spritesheet.
    static void
    addButton(String name, String skinName, float x, float y, float width, float height, String text)
    Adds a TextButton to the currently active HUD.
    static void
    addCheckBox(String name, String skinName, float x, float y, String text, boolean checked)
    Adds a CheckBox to the currently active HUD.
    static void
    addColor(String name, int r, int g, int b)
    Adds a named color to the global registry using RGB components (0-255) with full opacity.
    static void
    addColor(String name, int r, int g, int b, int a)
    Adds a named color to the global registry using RGBA components (0-255).
    static void
    addColor(String name, com.badlogic.gdx.graphics.Color color)
    Adds a named Color to the global color registry.
    static void
    addCustomUIComponent(String name, com.badlogic.gdx.scenes.scene2d.Actor uiComponent)
    Adds a custom LibGDX Actor to the currently active HUD.
    static void
    addEmptyAnimation(String name, float frameDuration, boolean loop)
    Creates an empty animation with a given frame duration and loop flag.
    static void
    addFont(String name, com.badlogic.gdx.graphics.g2d.BitmapFont font)
    Registers an already created BitmapFont under a given name.
    static void
    addFont(String name, String filePath, float size)
    Overload: Adds a font that scales to world height by default.
    static void
    addFont(String name, String filePath, float size, boolean usePixelSize)
    Loads a TTF or OTF font, optionally scaling it to world height or keeping pixel size.
    static void
    addInterpolator(String name, float start, float end, float duration, com.badlogic.gdx.math.Interpolation strategy)
    Creates a new interpolator with the given name.
    static void
    addInterpolator(String name, float start, float end, float duration, String strategy)
    Creates a new interpolator with the given name.
    static void
    addItemToStore(String name, Object anyType)
    Add item to the application store, so that it can be used in multiple screens.
    static void
    addLabel(String name, String skinName, float x, float y, String text)
    Adds a static Label to the currently active HUD.
    static void
    addMusic(String name, String filePath)
    Loads and stores a music track from a file path under the given name.
    static void
    addParticleEffect(String name, String filePath)
    Load a particle effect and create a pool for it.
    static void
    addProgressBar(String name, String skinName, float x, float y, float width, float height, float min, float max, boolean vertical, float value)
    Adds a ProgressBar to the currently active HUD.
    static void
    addScreen(String name, com.badlogic.gdx.Screen screen)
    Register a screen with a unique name.
    static void
    addSelectBox(String name, String skinName, float x, float y, float width, float height, String... items)
    Adds a SelectBox (drop-down menu) to the currently active HUD.
    static void
    addSkin(String key, String jsonPath)
    Adds a skin to the internal skin registry by loading it from a JSON file.
    static void
    addSlider(String name, String skinName, float x, float y, float width, float height, float min, float max, float step, boolean vertical)
    Adds a Slider to the currently active HUD.
    static void
    addSound(String name, String filePath)
    Loads and stores a sound effect from a file path under the given name.
    static void
    addSpriteSheet(String name, String filePath, int frameWidth, int frameHeight)
    Loads a spritesheet from a file, slices it into frames, and stores the frames.
    static void
    addStyledFont(String name, String filePath, int size, com.badlogic.gdx.graphics.Color color, float borderWidth, com.badlogic.gdx.graphics.Color borderColor, int shadowOffsetX, int shadowOffsetY, com.badlogic.gdx.graphics.Color shadowColor, boolean usePixelSize)
    Loads a styled TTF font with optional border and shadow, with world-scaling or pixel-perfect option.
    static void
    addStyledFont(String name, String filePath, int size, String colorName, float borderWidth, String borderColorName, int shadowOffsetX, int shadowOffsetY, String shadowColorName, boolean usePixelSize)
    Styled font with named colors (throws if color names not found).
    static void
    addTextField(String name, String skinName, float x, float y, float width, float height, String messageText)
    Adds a TextField (input box) to the currently active HUD.
    static void
    addTexture(String name, String filePath)
    Loads a texture from a file path and stores it in the global texture registry.
    static void
    addTexture(String name, String filePath, com.badlogic.gdx.graphics.Texture.TextureFilter filter)
    Loads a texture from a file path and stores it in the global texture registry.
    static void
    addTexture(String name, String filePath, com.badlogic.gdx.graphics.Texture.TextureFilter minFilter, com.badlogic.gdx.graphics.Texture.TextureFilter maxFilter)
    Loads a texture from a file path and stores it in the global texture registry.
    static void
    addTextureAtlas(String name, String filePath)
    Loads a texture atlas and stores it in the internal atlas map.
    static void
    addTimer(String name, float duration, boolean looping)
    Add a timer with simple looping boolean.
    static void
    addTimer(String name, float duration, int loops)
    Add a timer.
    static float
    angleBetween(float x1, float y1, float x2, float y2)
    Calculates the angle in degrees from the first point to the second point.
    static void
    assertCondition(boolean condition, String message)
    Checks a condition and prints a message if it fails.
    static boolean
    circleOverlap(float x1, float y1, float r1, float x2, float y2, float r2)
    Checks if two circles overlap.
    static boolean
    circleOverlap(com.badlogic.gdx.math.Circle c1, com.badlogic.gdx.math.Circle c2)
     
    static float
    clamp(float value, float min, float max)
    Clamps a value to be within the specified minimum and maximum range.
    static void
    Clears the mask completely.
    static void
    Clears the screen to black (0, 0, 0).
    static void
    clearScreen(int r, int g, int b)
    Clears the screen to the specified RGB color.
    static void
    clearScreen(com.badlogic.gdx.graphics.Color color)
    Clears the screen using the specified Color.
    static void
    clearScreen(String colorName)
    Clears the screen using a named color from the color registry.
    Creates a new GameImpl instance for cross-platform backends (Android, iOS, WebGL).
    static void
    debug(Object... values)
    Prints multiple values in a single line.
    static void
    Disable transparency for shape render and sprite batch.
    static void
    Removes an animation.
    static void
    Removes the atlas and disposes it from memory.
    static void
    Remove the font and unload it from the memory.
    static void
    Removes an interpolator from the internal registry.
    static void
    Remove the music and unload it from the memory.
    static void
    Remove the particle effect by name.
    static void
    Disposes of a skin in the registry.
    static void
    Remove the sound and unload it from the memory.
    static void
    Removes the spritesheet and disposes its underlying Texture.
    static void
    Remove the texture and unload it from the memory.
    static void
    Dispose of timer.
    static void
    Removes all UI elements from the current HUD stage.
    static float
    distance(float x1, float y1, float x2, float y2)
    Calculates the distance between two points.
    static void
    drawAnimation(String name, float x, float y)
    Draws the current frame of the animation at the specified bottom-left position.
    static void
    drawAnimation(String name, float x, float y, float width, float height)
    Draws the current frame of the animation at the specified position and size.
    static void
    drawAnimation(String name, float x, float y, float width, float height, float rotationDegrees, boolean flipX, boolean flipY)
    Draws the current frame of the animation at the specified position, size, rotation, and flipping.
    static void
    drawAnimationCentered(String name, float centerX, float centerY)
    Draws the current frame of the animation centered at the specified position.
    static void
    drawAnimationCentered(String name, float centerX, float centerY, float width, float height)
    Draws the current frame of the animation centered at the specified position with the given size.
    static void
    drawAnimationCentered(String name, float centerX, float centerY, float width, float height, float rotationDegrees, boolean flipX, boolean flipY)
    Draws the current frame of the animation centered at the specified position with size, rotation, and flipping.
    static void
    drawAtlasRegion(String atlasName, String regionName, float x, float y)
    Draws a region from an atlas at the specified position.
    static void
    drawAtlasRegion(String atlasName, String regionName, float x, float y, float width, float height)
    Draws a region from an atlas at the specified position with scaling.
    static void
    drawAtlasRegion(String atlasName, String regionName, float x, float y, float width, float height, float rotationDegrees, boolean flipX, boolean flipY)
    Draws a region from an atlas at the specified position with scaling, rotation, and flipping.
    static void
    drawAtlasRegionCentered(String atlasName, String regionName, float centerX, float centerY)
    Draws a region from an atlas centered at a given position.
    static void
    drawAtlasRegionCentered(String atlasName, String regionName, float centerX, float centerY, float width, float height)
    Draws a region from an atlas centered with scaling.
    static void
    drawAtlasRegionCentered(String atlasName, String regionName, float centerX, float centerY, float width, float height, float rotationDegrees, boolean flipX, boolean flipY)
    Draws a region from an atlas centered with scaling, rotation, and flipping.
    static void
    drawCircle(float x, float y, float radius)
    Draws a circle.
    static void
    drawCircle(float x, float y, float radius, int segments)
    Draws a circle with a specified number of segments.
    static void
    drawCircle(float x, float y, float radius, int segments, com.badlogic.gdx.graphics.Color color)
    Draws a circle in a specific color with a specified number of segments.
    static void
    drawCircle(float x, float y, float radius, int segments, String colorName)
    Draws a circle in a specific color with a specified number of segments.
    static void
    drawCircle(float x, float y, float radius, com.badlogic.gdx.graphics.Color color)
    Draws a circle in a specific color.
    static void
    drawCircle(float x, float y, float radius, String colorName)
    Draws a circle in a specific color.
    static void
    drawEllipse(float x, float y, float width, float height)
    Draws an ellipse.
    static void
    drawEllipse(float x, float y, float width, float height, com.badlogic.gdx.graphics.Color color)
    Draws an ellipse in a specific color.
    static void
    drawEllipse(float x, float y, float width, float height, String colorName)
    Draws an ellipse in a specific color.
    static void
    drawEllipseCentered(float centerX, float centerY, float width, float height)
    Draws an ellipse centered on a specified point.
    static void
    drawEllipseCentered(float centerX, float centerY, float width, float height, com.badlogic.gdx.graphics.Color color)
    Draws an ellipse centered on a specified point with a Color object.
    static void
    drawEllipseCentered(float centerX, float centerY, float width, float height, String colorName)
    Draws an ellipse centered on a specified point with a color name.
    static void
    drawLine(float x1, float y1, float x2, float y2)
    Draws a line.
    static void
    drawLine(float x1, float y1, float x2, float y2, com.badlogic.gdx.graphics.Color color)
    Draws a line in a specific color.
    static void
    drawLine(float x1, float y1, float x2, float y2, String colorName)
    Draws a line in a specific color.
    static void
    drawPolygon(float[] vertices)
    Draws a polygon.
    static void
    drawPolygon(float[] vertices, com.badlogic.gdx.graphics.Color color)
    Draws a polygon in a specific color.
    static void
    drawPolygon(float[] vertices, String colorName)
    Draws a polygon in a specific color.
    static void
    drawRect(float x, float y, float width, float height)
    Draws a rectangle.
    static void
    drawRect(float x, float y, float width, float height, com.badlogic.gdx.graphics.Color color)
    Draws a rectangle in a specific color.
    static void
    drawRect(float x, float y, float width, float height, String colorName)
    Draws a rectangle in a specific color.
    static void
    drawRectCentered(float centerX, float centerY, float width, float height)
    Draws a rectangle centered on a specified point.
    static void
    drawRectCentered(float centerX, float centerY, float width, float height, com.badlogic.gdx.graphics.Color color)
    Draws a rectangle centered on a specified point with a Color object.
    static void
    drawRectCentered(float centerX, float centerY, float width, float height, String colorName)
    Draws a rectangle centered on a specified point with a color name.
    static void
    drawRoundedRect(float x, float y, float width, float height, float radius)
    Draws a rounded rectangle using the class's ShapeRenderer.
    static void
    drawRoundedRect(float x, float y, float width, float height, float radius, com.badlogic.gdx.graphics.Color color)
    Draws a rounded rectangle with a specified Color object.
    static void
    drawRoundedRect(float x, float y, float width, float height, float radius, String colorName)
    Draws a rounded rectangle with a specified color name.
    static void
    drawRoundedRectCentered(float centerX, float centerY, float width, float height, float radius)
    Draws a rounded rectangle centered on a specified point.
    static void
    drawRoundedRectCentered(float centerX, float centerY, float width, float height, float radius, com.badlogic.gdx.graphics.Color color)
    Draws a rounded rectangle centered on a specified point with a Color object.
    static void
    drawRoundedRectCentered(float centerX, float centerY, float width, float height, float radius, String colorName)
    Draws a rounded rectangle centered on a specified point with a color name.
    static void
    drawSpritesheetFrame(String name, int row, int col, float x, float y)
    Draw a specific frame from a spritesheet at the given position.
    static void
    drawSpritesheetFrame(String name, int row, int col, float x, float y, float width, float height)
    Draw a specific frame with scaling.
    static void
    drawSpritesheetFrame(String name, int row, int col, float x, float y, float width, float height, float rotationDegrees, boolean flipX, boolean flipY)
    Draw a specific frame with scaling, rotation, and flipping.
    static void
    drawSpritesheetFrameCentered(String name, int row, int col, float centerX, float centerY)
    Draw a frame centered at a given position.
    static void
    drawSpritesheetFrameCentered(String name, int row, int col, float centerX, float centerY, float width, float height)
    Draw a frame centered with scaling.
    static void
    drawSpritesheetFrameCentered(String name, int row, int col, float centerX, float centerY, float width, float height, float rotationDegrees, boolean flipX, boolean flipY)
    Draw a frame centered with scaling, rotation, and flipping.
    static void
    drawText(String fontName, String text, float x, float y, com.badlogic.gdx.graphics.Color color)
    Draws text left-bottom aligned at the specified position with a given color.
    static void
    drawText(String fontName, String text, float x, float y, String color)
    Draws text left-bottom aligned at the specified position with a given color.
    static void
    drawTextCentered(String fontName, String text, float centerX, float centerY, com.badlogic.gdx.graphics.Color color)
    Draws text centered on a specified point with a given color.
    static void
    drawTextCentered(String fontName, String text, float centerX, float centerY, String color)
    Draws text centered on a specified point with a given color.
    static void
    drawTextHorizontallyCentered(String fontName, String text, float centerX, float y, com.badlogic.gdx.graphics.Color color)
    Draws text horizontally centered at a given X-coordinate with a given Y-coordinate and color.
    static void
    drawTextHorizontallyCentered(String fontName, String text, float centerX, float y, String color)
    Overload with color as string.
    static void
    drawTexture(String name, float x, float y)
    Draws a texture at the specified position using the current sprite batch.
    static void
    drawTexture(String name, float x, float y, float width, float height)
    Draws a texture at the specified position and size using the current sprite batch.
    static void
    drawTexture(String name, float x, float y, float width, float height, float rotationDegrees, boolean flipX, boolean flipY)
    Draws a texture at the specified position, size, rotation, and flipping using the current sprite batch.
    static void
    drawTextureCentered(String name, float centerX, float centerY)
    Draws a texture centered at the specified position using the current sprite batch.
    static void
    drawTextureCentered(String name, float centerX, float centerY, float width, float height)
    Draws a texture centered at the specified position with size using the current sprite batch.
    static void
    drawTextureCentered(String name, float centerX, float centerY, float width, float height, float rotationDegrees, boolean flipX, boolean flipY)
    Draws a texture centered at the specified position with size, rotation, and flipping using the current sprite batch.
    static void
    drawTextVerticallyCentered(String fontName, String text, float x, float centerY, com.badlogic.gdx.graphics.Color color)
    Draws text vertically centered at a given Y-coordinate with a given X-coordinate and color.
    static void
    drawTextVerticallyCentered(String fontName, String text, float x, float centerY, String color)
    Overload with color as string.
    static void
    Enable transparency for shape render and sprite batch.
    static void
    Ends the mask definition and applies it to subsequent drawing.
    static void
    Ends the current shape rendering batch.
    static void
    Ends the current sprite rendering batch.
    static void
    error(String message)
    Prints an error message in red.
    static boolean
    fileExists(String fileName)
    Checks if the save file exists.
    static long[]
    Get a list with all active particle id's
    static String[]
    Get the names of all registered colors.
    Retrieves an animation by name.
    static int
    Returns the index of the current frame of the named animation.
    static int
    Returns the total number of frames in the named animation.
    static com.badlogic.gdx.graphics.g2d.TextureAtlas
    Get the texture atlas object.
    static com.badlogic.gdx.graphics.g2d.TextureRegion
    getAtlasRegion(String atlasName, String regionName)
    Retrieves a TextureRegion from a loaded texture atlas.
    static boolean
    Returns whether a CheckBox is currently checked.
    static com.badlogic.gdx.graphics.Color
    Retrieves a named Color from the global color registry.
    static com.badlogic.gdx.Screen
    Returns the currently active Screen of the game.
    static String
    Get the name of the current screen.
    static float
    Returns the time elapsed since the last frame, in seconds.
    static com.badlogic.gdx.graphics.g2d.BitmapFont
    Retrieves a loaded font by its name.
    static int
    Returns the current frame rate of the application, in frames per second (FPS).
    static String[]
    Get a list of all the possible interpolation strategies available
    Retrieves an existing interpolator by name.
    static Object
    Get an item from the application store by name.
    static String
    Returns the text of a Label.
    static com.badlogic.gdx.Game
    WARNING: using this object can heavily influence the behaviour of the GameApp.
    static com.badlogic.gdx.math.Vector2
    Returns the current position of the mouse in screen coordinates as a Vector2.
    static int
    Returns the current X-coordinate of the mouse cursor in screen coordinates.
    static int
    Returns the current Y-coordinate of the mouse cursor in screen coordinates.
    static com.badlogic.gdx.audio.Music
     
    static com.badlogic.gdx.graphics.g2d.ParticleEffectPool
    Only for advanced users: get the particle pool object from the app directly.
    static float
    Retrieves the current value of a ProgressBar on the active HUD.
    static String[]
    Get a list with all screen names that are defined
    static String
    Returns the currently selected item of a SelectBox.
    static com.badlogic.gdx.graphics.glutils.ShapeRenderer
    Returns the shared ShapeRenderer instance used for rendering shapes.
    static com.badlogic.gdx.scenes.scene2d.ui.Skin
    Retrieves a skin from the registry by its key.
    static float
    Returns the current value of a Slider.
    static com.badlogic.gdx.audio.Sound
     
    static com.badlogic.gdx.graphics.g2d.SpriteBatch
    Returns the shared SpriteBatch instance used for rendering sprites.
    static com.badlogic.gdx.graphics.g2d.TextureRegion
    getSpritesheetFrame(String name, int row, int col)
    Retrieve a specific frame from a spritesheet.
    static int
    Returns the number of columns in the specified spritesheet.
    static int
    Returns the number of rows in the specified spritesheet.
    static String
    Returns the current text of a TextField.
    static float
    getTextHeight(String fontName, String text)
    Returns the height of a given text in pixels when rendered with the specified font.
    static com.badlogic.gdx.graphics.Texture
    Retrieves a texture from the global texture registry by name.
    static int
    Returns the height in pixels of the texture with the given name.
    static int
    Returns the width in pixels of the texture with the given name.
    static float
    getTextWidth(String fontName, String text)
    Returns the width of a given text in pixels when rendered with the specified font.
    static Timer
    Retrieve timer object.
    static float
    Get remaining time until next trigger.
    static com.badlogic.gdx.scenes.scene2d.Actor
    Retrieves the raw LibGDX Actor for a given UI element key.
    static int
    Returns the current height of the game window in pixels.
    static int
    Returns the current width of the game window in pixels.
    static float
    Get the height of the world (this method is identical to calling getWorldWidth() in your own screen object)
    static float
    Get the width of the world (this method is identical to calling getWorldWidth() in your own screen object)
    static boolean
    Checks if an animation exists.
    static boolean
    Returns if an atlas is available with the given name
    static boolean
    Checks whether a color with the given name exists in the global registry.
    static boolean
    Returns if font is available with the given name
    static boolean
    Checks whether an interpolator with the given name exists.
    static boolean
    Check if an item exists with the given name
    static boolean
    Returns if music is available with the given name
    static boolean
    Checks whether a particle effect pool exists for the given name.
    static boolean
    Checks whether a skin exists in the registry.
    static boolean
    Returns if a sound is available with the given name
    static boolean
    Returns if a spritesheet is available with the given name.
    static boolean
    Returns if texture is available with the given name
    static boolean
    Returns true if a timer exists.
    static boolean
    Checks whether a UI element with the given key exists in the currently active HUD.
    static void
    Hides the system mouse cursor.
    static void
    Inverts the mask effect.
    static boolean
    Checks if the animation has finished.
    static boolean
    isButtonJustPressed(int button)
    Returns true if the specified mouse button was just pressed this frame.
    static boolean
    isButtonPressed(int button)
    Returns true if the specified mouse button is currently held down.
    static boolean
    Checks if the game is currently in fullscreen mode.
    static boolean
    Checks whether the interpolator has finished its animation.
    static boolean
    isKeyJustPressed(int keyCode)
    Returns true if the specified key was just pressed this frame.
    static boolean
    isKeyPressed(int keyCode)
    Returns true if the specified key is currently held down.
    static boolean
    Checks if the particle effect instance has finished
    static boolean
    Checks whether a timer has finished all its loops.
    static void
    jumpAnimationToFrame(String name, int frameIndex)
    Jumps the named animation to a specific frame.
    static Object
    Loads any object from a binary file.
    static <T> T
    loadFromJson(String fileName, Class<T> type)
    Load an object from a JSON file.
    static void
    log(String message)
    Prints a simple message to the console.
    static void
    log(String name, Object value)
    Prints a variable with its name for easier debugging.
    static float[]
    moveInDirection(float x, float y, float distance, float directionDegrees)
    Computes new coordinates by moving from a starting point in a specified direction and distance.
    static void
    Pause timer.
    static void
    playMusic(String name, boolean looping)
    Plays a music track, optionally looping.
    static void
    playMusic(String name, boolean looping, float volume)
    Plays a music track, optionally looping with a specific volume.
    static long
    Plays a sound effect at full volume (1.0).
    static long
    playSound(String name, float volume)
    Plays a sound effect at the specified volume.
    static boolean
    pointInCircle(float px, float py, float cx, float cy, float radius)
    Checks if a point is inside a circle.
    static boolean
    pointInCircle(com.badlogic.gdx.math.Vector2 point, com.badlogic.gdx.math.Circle circle)
     
    static boolean
    pointInRect(float px, float py, float rx, float ry, float rw, float rh)
    Checks if a point is inside a rectangle.
    static boolean
    pointInRect(com.badlogic.gdx.math.Vector2 point, com.badlogic.gdx.math.Rectangle rect)
     
    static void
    Exits the game application.
    static float
    random(float min, float max)
    Returns a random float value within the specified range.
    static <T> T
    random(List<T> list)
    Returns a random element from a List of any type.
    static <T> T
    random(T[] array)
    Returns a random element from an array.
    static int
    randomInt(int min, int max)
    Returns a random int value within the specified range.
    static boolean
    rectCircleOverlap(float rectX, float rectY, float rectW, float rectH, float circleX, float circleY, float radius)
    Checks if an axis-aligned rectangle and a circle overlap.
    static boolean
    rectCircleOverlap(com.badlogic.gdx.math.Rectangle rect, com.badlogic.gdx.math.Circle circle)
     
    static boolean
    rectContainsRect(float x1, float y1, float w1, float h1, float x2, float y2, float w2, float h2)
    Checks if one rectangle is completely contained within another rectangle.
    static boolean
    rectContainsRect(com.badlogic.gdx.math.Rectangle outer, com.badlogic.gdx.math.Rectangle inner)
     
    static boolean
    rectOverlap(float x1, float y1, float w1, float h1, float x2, float y2, float w2, float h2)
    Checks if two axis-aligned rectangles overlap.
    static boolean
    rectOverlap(com.badlogic.gdx.math.Rectangle r1, com.badlogic.gdx.math.Rectangle r2)
     
    static boolean
    Remove an item from the store by name.
    static void
    Draw one specific particle effect instance.
    static void
    Render all active particle effects using GameApp.spriteBatch.
    static void
    Resets an animation to start from the beginning.
    static void
    resetAnimation(String name, boolean reverse)
    Resets an animation to start from the beginning, optionally reversing it.
    static void
    Resets the interpolator with the given name to start its animation from the beginning.
    static void
    resetInterpolator(String name, boolean reverse)
    Resets the interpolator with the given name to start its animation from the beginning.
    static void
    Reset timer to initial state.
    static void
    Resume timer.
    static void
    saveToBinary(Object object, String fileName)
    Saves any object to a binary file.
    static void
    saveToJson(Object object, String fileName)
    Serialize any object to JSON and save to a file.
    static void
    setCheckBoxValue(String name, boolean checked)
    Sets the checked state of a CheckBox.
    static void
    setColor(int r, int g, int b)
    Sets the current drawing color using RGB components (0-255) with full opacity.
    static void
    setColor(int r, int g, int b, int a)
    Sets the current drawing color using RGBA components (0-255).
    static void
    setColor(com.badlogic.gdx.graphics.Color color)
    Sets the current drawing color for shapes.
    static void
    setColor(String colorName)
    Sets the current drawing color using a registered color name.
    static void
    setCustomCursor(String filePath, int hotspotX, int hotspotY)
    Sets a custom cursor image from a file.
    static void
    setFPS(int fps)
    Sets the target frames per second (FPS) for rendering.
    static void
    setLabelValue(String name, String value)
    Sets the text of a Label.
    static void
    setLineWidth(float width)
    Set the width of the outline when drawing with the shape renderer.
    static void
    setProgressBarValue(String name, float value)
    Sets the value of a ProgressBar on the active HUD.
    static void
    setResizable(boolean resizable)
    Sets whether the game window can be resized by the user.
    static void
    Sets the selected item of a SelectBox.
    static void
    setSliderValue(String name, float value)
    Sets the value of a Slider.
    static void
    setSystemCursor(com.badlogic.gdx.graphics.Cursor.SystemCursor systemCursor)
    Sets the system cursor to one of the default cursors.
    static void
    Sets the text of a TextField.
    static void
    setTimerDuration(String name, float newDuration)
    Change timer duration.
    static void
    Changes the title of the game window.
    static void
    setVSync(boolean vsync)
    Enables or disables vertical synchronization (VSync).
    static void
    Shows the default system mouse cursor.
    static long
    spawnParticleEffect(String name, float x, float y)
    Spawn a particle effect at a position.
    static void
    start(String title, int width, int height, int fps, boolean fullScreen, String firstScreenName)
    Configure the game application and start it immediately.
    static void
    Starts a new mask definition.
    static void
    Begins shape rendering in filled mode.
    static void
    Begins shape rendering in outlined (line) mode.
    static void
    Begins shape rendering in point mode.
    static void
    Begins sprite rendering.
    static void
    Clears all active effects and returns them to their pools.
    static void
    Stops all audio, including sound effects and music.
    static void
    Stops all currently playing music tracks.
    static void
    Stops all currently playing sound effects.
    static void
    Stops a specific music track by name.
    static void
    Stop a specific active particle effect.
    static void
    stopSound(long soundId)
    Stops a specific sound effect by its playback ID.
    static void
    Switches the currently active screen in the game to the one specified by name.
    static void
    Switches the game window to fullscreen mode using the current display mode.
    static void
    switchToWindowedMode(int width, int height)
    Switches the game window to windowed mode with the specified width and height.
    static boolean
    Query if a timer went off in the last update call.
    static void
    Updates the animation by the frame's delta time.
    static float
    Updates the interpolator with the given name and returns the current value.
    static void
    Update all active particle effects.
    static void
    Update single timer using Gdx deltaTime.
    static void
    Update all timers using Gdx deltaTime.
    static void
    warn(String message)
    Prints a warning message in yellow.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GameApp

      public GameApp()
  • Method Details

    • start

      public static void start(String title, int width, int height, int fps, boolean fullScreen, String firstScreenName)
      Configure the game application and start it immediately.

      Developer info: This method creates and launches a new Lwjgl3Application instance using the provided title, resolution, frame rate, and display mode settings. The game begins by displaying the screen identified by firstScreenName.

      Parameters:
      title - the title of the game window
      width - the width of the game window in pixels
      height - the height of the game window in pixels
      fps - the target frames per second (FPS) for rendering
      fullScreen - true to start the game in fullscreen mode; false for windowed mode
      firstScreenName - the name of the first screen to display when the game starts
      Throws:
      IllegalStateException - if the game has already been started
    • createCrossPlatformGame

      public static GameApp.GameImpl createCrossPlatformGame(String firstScreenName)
      Creates a new GameImpl instance for cross-platform backends (Android, iOS, WebGL). Screens must be registered separately before starting the game.
      Parameters:
      firstScreenName - the name of the first screen to display
      Returns:
      the created GameImpl instance
    • quit

      public static void quit()
      Exits the game application.

      This method signals LibGDX to terminate the application and close the game window. Any cleanup logic in ApplicationListener.dispose() will be executed.

    • switchToFullscreen

      public static void switchToFullscreen()
      Switches the game window to fullscreen mode using the current display mode.

      This method only works on desktop platforms using the Lwjgl3 backend.

    • switchToWindowedMode

      public static void switchToWindowedMode(int width, int height)
      Switches the game window to windowed mode with the specified width and height.

      This method only works on desktop platforms using the Lwjgl3 backend.

      Parameters:
      width - the width of the window in pixels
      height - the height of the window in pixels
      Throws:
      RuntimeException - if the current backend does not support windowed mode changes
    • setResizable

      public static void setResizable(boolean resizable)
      Sets whether the game window can be resized by the user.

      This method only works on desktop platforms using the Lwjgl3 backend.

      Parameters:
      resizable - true to allow resizing, false to disable
      Throws:
      RuntimeException - if the current backend does not support changing resizable property
    • setTitle

      public static void setTitle(String title)
      Changes the title of the game window.

      This method only works on desktop platforms using the Lwjgl3 backend.

      Parameters:
      title - the new window title
      Throws:
      RuntimeException - if the current backend does not support changing the window title
    • isFullscreen

      public static boolean isFullscreen()
      Checks if the game is currently in fullscreen mode.

      This method only works on desktop platforms using the Lwjgl3 backend.

      Returns:
      true if the game is fullscreen, false otherwise
      Throws:
      RuntimeException - if the current backend does not support fullscreen mode detection
    • setFPS

      public static void setFPS(int fps)
      Sets the target frames per second (FPS) for rendering.

      This method only works on desktop platforms. Changing the FPS dynamically can help reduce CPU/GPU usage or control the speed of the game loop.

      Parameters:
      fps - the target frames per second (must be > 0)
      Throws:
      IllegalArgumentException - if fps is not positive
    • setVSync

      public static void setVSync(boolean vsync)
      Enables or disables vertical synchronization (VSync).

      When VSync is enabled, the frame rate is synchronized to the monitor's refresh rate to prevent screen tearing. This method only works on desktop platforms.

      Parameters:
      vsync - true to enable VSync, false to disable
    • addScreen

      public static void addScreen(String name, com.badlogic.gdx.Screen screen)
      Register a screen with a unique name.
      Parameters:
      name - Name of the screen
      screen - Screen object
    • getScreenNames

      public static String[] getScreenNames()
      Get a list with all screen names that are defined
      Returns:
      Screen names
    • getCurrentScreenName

      public static String getCurrentScreenName()
      Get the name of the current screen.
      Returns:
      name of the screen or an exception in case it is not found
    • switchScreen

      public static void switchScreen(String name)
      Switches the currently active screen in the game to the one specified by name.
      Parameters:
      name - the name of the screen to switch to; must correspond to a registered screen
      Throws:
      IllegalStateException - if the game has not been started yet.
      IllegalArgumentException - if no screen with the specified name exists.
    • getCurrentScreen

      public static com.badlogic.gdx.Screen getCurrentScreen()
      Returns the currently active Screen of the game.
      Returns:
      the current screen, or null if the game has not been started yet
    • getWindowWidth

      public static int getWindowWidth()
      Returns the current width of the game window in pixels. PLEASE NOTE: THIS IT NOT THE WORLD WIDTH
      Returns:
      the width of the game window in pixels
    • getWindowHeight

      public static int getWindowHeight()
      Returns the current height of the game window in pixels. PLEASE NOTE: THIS IT NOT THE WORLD HEIGHT
      Returns:
      the height of the game window in pixels
    • getWorldWidth

      public static float getWorldWidth()
      Get the width of the world (this method is identical to calling getWorldWidth() in your own screen object)
      Returns:
      width of the world
    • getWorldHeight

      public static float getWorldHeight()
      Get the height of the world (this method is identical to calling getWorldWidth() in your own screen object)
      Returns:
      height of the world
    • getDeltaTime

      public static float getDeltaTime()
      Returns the time elapsed since the last frame, in seconds.

      This is equivalent to Gdx.graphics.getDeltaTime() in LibGDX and is useful for frame rate independent calculations, such as movement or animations.

      Returns:
      the delta time in seconds since the last frame
    • getFramesPerSecond

      public static int getFramesPerSecond()
      Returns the current frame rate of the application, in frames per second (FPS).

      This value is updated by LibGDX each frame and can be used for debugging, performance monitoring, or display in an FPS counter.

      Returns:
      the number of frames rendered in the last second
    • getLibGDXGame

      public static com.badlogic.gdx.Game getLibGDXGame()
      WARNING: using this object can heavily influence the behaviour of the GameApp. This is only useful for advanced users.
      Returns:
      The Game object from LibGDX, use to run this application.
    • getMousePositionInWindowX

      public static int getMousePositionInWindowX()
      Returns the current X-coordinate of the mouse cursor in screen coordinates.
      Returns:
      the X position of the mouse
    • getMousePositionInWindowY

      public static int getMousePositionInWindowY()
      Returns the current Y-coordinate of the mouse cursor in screen coordinates.
      Returns:
      the Y position of the mouse
    • getMousePositionInWindow

      public static com.badlogic.gdx.math.Vector2 getMousePositionInWindow()
      Returns the current position of the mouse in screen coordinates as a Vector2.
      Returns:
      a new Vector2 containing the mouse coordinates
    • isKeyPressed

      public static boolean isKeyPressed(int keyCode)
      Returns true if the specified key is currently held down.
      Parameters:
      keyCode - the key code to check (see Input.Keys)
      Returns:
      true if the key is pressed, false otherwise
    • isKeyJustPressed

      public static boolean isKeyJustPressed(int keyCode)
      Returns true if the specified key was just pressed this frame.
      Parameters:
      keyCode - the key code to check (see Input.Keys)
      Returns:
      true if the key was just pressed, false otherwise
    • isButtonPressed

      public static boolean isButtonPressed(int button)
      Returns true if the specified mouse button is currently held down.
      Parameters:
      button - the mouse button to check (see Input.Buttons)
      Returns:
      true if the button is pressed, false otherwise
    • isButtonJustPressed

      public static boolean isButtonJustPressed(int button)
      Returns true if the specified mouse button was just pressed this frame.
      Parameters:
      button - the mouse button to check (see Input.Buttons)
      Returns:
      true if the button was just pressed, false otherwise
    • addSound

      public static void addSound(String name, String filePath)
      Loads and stores a sound effect from a file path under the given name.
      Parameters:
      name - the name to associate with the sound
      filePath - the internal file path of the sound effect
    • addMusic

      public static void addMusic(String name, String filePath)
      Loads and stores a music track from a file path under the given name.
      Parameters:
      name - the name to associate with the music
      filePath - the internal file path of the music track
    • disposeSound

      public static void disposeSound(String name)
      Remove the sound and unload it from the memory.
      Parameters:
      name - Name of the sound.
    • disposeMusic

      public static void disposeMusic(String name)
      Remove the music and unload it from the memory.
      Parameters:
      name - Name of the music.
    • playSound

      public static long playSound(String name, float volume)
      Plays a sound effect at the specified volume.
      Parameters:
      name - the name of the loaded sound
      volume - the playback volume (0f - 1f)
      Returns:
      the playback ID for the sound instance
      Throws:
      IllegalArgumentException - if the sound has not been loaded
    • playSound

      public static long playSound(String name)
      Plays a sound effect at full volume (1.0).
      Parameters:
      name - the name of the loaded sound
      Returns:
      the playback ID for the sound instance
      Throws:
      IllegalArgumentException - if the sound has not been loaded
    • playMusic

      public static void playMusic(String name, boolean looping)
      Plays a music track, optionally looping.

      If the music is already playing, this method does nothing.

      Parameters:
      name - the name of the loaded music
      looping - true to loop the music, false to play once
      Throws:
      IllegalArgumentException - if the music has not been loaded
    • playMusic

      public static void playMusic(String name, boolean looping, float volume)
      Plays a music track, optionally looping with a specific volume.

      If the music is already playing, this method does nothing.

      Parameters:
      name - the name of the loaded music
      looping - true to loop the music, false to play once
      volume - the playback volume (0f - 1f)
      Throws:
      IllegalArgumentException - if the music has not been loaded
    • stopSound

      public static void stopSound(long soundId)
      Stops a specific sound effect by its playback ID.
      Parameters:
      soundId - the playback ID returned by playSound(String)
    • stopAllSounds

      public static void stopAllSounds()
      Stops all currently playing sound effects.
    • stopMusic

      public static void stopMusic(String name)
      Stops a specific music track by name.
      Parameters:
      name - the name of the loaded music track
    • stopAllMusic

      public static void stopAllMusic()
      Stops all currently playing music tracks.
    • stopAllAudio

      public static void stopAllAudio()
      Stops all audio, including sound effects and music.
    • getSound

      public static com.badlogic.gdx.audio.Sound getSound(String name)
    • getMusic

      public static com.badlogic.gdx.audio.Music getMusic(String name)
    • hasSound

      public static boolean hasSound(String name)
      Returns if a sound is available with the given name
      Parameters:
      name - Name of the sound
      Returns:
      True, if it exists
    • hasMusic

      public static boolean hasMusic(String name)
      Returns if music is available with the given name
      Parameters:
      name - Name of the music
      Returns:
      True, if it exists
    • getShapeRenderer

      public static com.badlogic.gdx.graphics.glutils.ShapeRenderer getShapeRenderer()
      Returns the shared ShapeRenderer instance used for rendering shapes.
      Returns:
      the global ShapeRenderer instance
    • addColor

      public static void addColor(String name, com.badlogic.gdx.graphics.Color color)
      Adds a named Color to the global color registry.
      Parameters:
      name - the name to associate with the color
      color - the Color instance
    • addColor

      public static void addColor(String name, int r, int g, int b, int a)
      Adds a named color to the global registry using RGBA components (0-255).
      Parameters:
      name - the name to associate with the color
      r - red component (0-255)
      g - green component (0-255)
      b - blue component (0-255)
      a - alpha component (0-255)
    • addColor

      public static void addColor(String name, int r, int g, int b)
      Adds a named color to the global registry using RGB components (0-255) with full opacity.
      Parameters:
      name - the name to associate with the color
      r - red component (0-255)
      g - green component (0-255)
      b - blue component (0-255)
    • getColor

      public static com.badlogic.gdx.graphics.Color getColor(String name)
      Retrieves a named Color from the global color registry.
      Parameters:
      name - the name of the color
      Returns:
      the Color associated with the name
      Throws:
      IllegalArgumentException - if the color with the given name does not exist
    • getAllColors

      public static String[] getAllColors()
      Get the names of all registered colors.
      Returns:
      String array with all color names.
    • hasColor

      public static boolean hasColor(String name)
      Checks whether a color with the given name exists in the global registry.
      Parameters:
      name - the name of the color
      Returns:
      true if the color exists, false otherwise
    • startShapeRenderingFilled

      public static void startShapeRenderingFilled()
      Begins shape rendering in filled mode.
    • startShapeRenderingOutlined

      public static void startShapeRenderingOutlined()
      Begins shape rendering in outlined (line) mode.
    • startShapeRenderingPoints

      public static void startShapeRenderingPoints()
      Begins shape rendering in point mode.
    • setLineWidth

      public static void setLineWidth(float width)
      Set the width of the outline when drawing with the shape renderer.
      Parameters:
      width - Width
    • endShapeRendering

      public static void endShapeRendering()
      Ends the current shape rendering batch.
    • clearScreen

      public static void clearScreen(int r, int g, int b)
      Clears the screen to the specified RGB color.
      Parameters:
      r - red component (0-255)
      g - green component (0-255)
      b - blue component (0-255)
    • clearScreen

      public static void clearScreen()
      Clears the screen to black (0, 0, 0).
    • clearScreen

      public static void clearScreen(String colorName)
      Clears the screen using a named color from the color registry.
      Parameters:
      colorName - the name of the color to clear the screen with (see addColor method)
      Throws:
      IllegalArgumentException - if the color name is not found
    • clearScreen

      public static void clearScreen(com.badlogic.gdx.graphics.Color color)
      Clears the screen using the specified Color.
      Parameters:
      color - the color to clear the screen with
    • setColor

      public static void setColor(com.badlogic.gdx.graphics.Color color)
      Sets the current drawing color for shapes.
      Parameters:
      color - the Color to use
    • setColor

      public static void setColor(int r, int g, int b)
      Sets the current drawing color using RGB components (0-255) with full opacity.
      Parameters:
      r - red component (0-255)
      g - green component (0-255)
      b - blue component (0-255)
    • setColor

      public static void setColor(int r, int g, int b, int a)
      Sets the current drawing color using RGBA components (0-255).
      Parameters:
      r - red component (0-255)
      g - green component (0-255)
      b - blue component (0-255)
      a - alpha component (0-255)
    • setColor

      public static void setColor(String colorName)
      Sets the current drawing color using a registered color name.
      Parameters:
      colorName - the name of the color to use
      Throws:
      IllegalArgumentException - if the color name is not found or invalid for masking
    • enableTransparency

      public static void enableTransparency()
      Enable transparency for shape render and sprite batch.
    • disableTransparency

      public static void disableTransparency()
      Disable transparency for shape render and sprite batch.
    • drawRect

      public static void drawRect(float x, float y, float width, float height)
      Draws a rectangle.
      Parameters:
      x - the x-coordinate of the bottom-left corner
      y - the y-coordinate of the bottom-left corner
      width - the width of the rectangle
      height - the height of the rectangle
    • drawRect

      public static void drawRect(float x, float y, float width, float height, String colorName)
      Draws a rectangle in a specific color.
      Parameters:
      x - the x-coordinate of the bottom-left corner
      y - the y-coordinate of the bottom-left corner
      width - the width of the rectangle
      height - the height of the rectangle
      colorName - the name of the color to use
    • drawRect

      public static void drawRect(float x, float y, float width, float height, com.badlogic.gdx.graphics.Color color)
      Draws a rectangle in a specific color.
      Parameters:
      x - the x-coordinate of the bottom-left corner
      y - the y-coordinate of the bottom-left corner
      width - the width of the rectangle
      height - the height of the rectangle
      color - the color object
    • drawRectCentered

      public static void drawRectCentered(float centerX, float centerY, float width, float height)
      Draws a rectangle centered on a specified point.
      Parameters:
      centerX - the x-coordinate of the rectangle's center
      centerY - the y-coordinate of the rectangle's center
      width - the width of the rectangle
      height - the height of the rectangle
    • drawRectCentered

      public static void drawRectCentered(float centerX, float centerY, float width, float height, String colorName)
      Draws a rectangle centered on a specified point with a color name.
      Parameters:
      centerX - the x-coordinate of the rectangle's center
      centerY - the y-coordinate of the rectangle's center
      width - the width of the rectangle
      height - the height of the rectangle
      colorName - the name of the color to use
    • drawRectCentered

      public static void drawRectCentered(float centerX, float centerY, float width, float height, com.badlogic.gdx.graphics.Color color)
      Draws a rectangle centered on a specified point with a Color object.
      Parameters:
      centerX - the x-coordinate of the rectangle's center
      centerY - the y-coordinate of the rectangle's center
      width - the width of the rectangle
      height - the height of the rectangle
      color - the color object to use
    • drawRoundedRect

      public static void drawRoundedRect(float x, float y, float width, float height, float radius)
      Draws a rounded rectangle using the class's ShapeRenderer.

      The rectangle consists of a central rectangle, side rectangles, and quarter-circle corners. Note: This only works properly in filled drawing mode. Outline mode will not render correctly.

      Parameters:
      x - the x-coordinate of the bottom-left corner
      y - the y-coordinate of the bottom-left corner
      width - the width of the rectangle
      height - the height of the rectangle
      radius - the radius of the rounded corners
    • drawRoundedRect

      public static void drawRoundedRect(float x, float y, float width, float height, float radius, String colorName)
      Draws a rounded rectangle with a specified color name.
      Parameters:
      x - the x-coordinate of the bottom-left corner
      y - the y-coordinate of the bottom-left corner
      width - the width of the rectangle
      height - the height of the rectangle
      radius - the radius of the rounded corners
      colorName - the name of the color to use
    • drawRoundedRect

      public static void drawRoundedRect(float x, float y, float width, float height, float radius, com.badlogic.gdx.graphics.Color color)
      Draws a rounded rectangle with a specified Color object.
      Parameters:
      x - the x-coordinate of the bottom-left corner
      y - the y-coordinate of the bottom-left corner
      width - the width of the rectangle
      height - the height of the rectangle
      radius - the radius of the rounded corners
      color - the Color object to use
    • drawRoundedRectCentered

      public static void drawRoundedRectCentered(float centerX, float centerY, float width, float height, float radius)
      Draws a rounded rectangle centered on a specified point.
      Parameters:
      centerX - the x-coordinate of the rectangle's center
      centerY - the y-coordinate of the rectangle's center
      width - the width of the rectangle
      height - the height of the rectangle
      radius - the radius of the rounded corners
    • drawRoundedRectCentered

      public static void drawRoundedRectCentered(float centerX, float centerY, float width, float height, float radius, String colorName)
      Draws a rounded rectangle centered on a specified point with a color name.
      Parameters:
      centerX - the x-coordinate of the rectangle's center
      centerY - the y-coordinate of the rectangle's center
      width - the width of the rectangle
      height - the height of the rectangle
      radius - the radius of the rounded corners
      colorName - the name of the color to use
    • drawRoundedRectCentered

      public static void drawRoundedRectCentered(float centerX, float centerY, float width, float height, float radius, com.badlogic.gdx.graphics.Color color)
      Draws a rounded rectangle centered on a specified point with a Color object.
      Parameters:
      centerX - the x-coordinate of the rectangle's center
      centerY - the y-coordinate of the rectangle's center
      width - the width of the rectangle
      height - the height of the rectangle
      radius - the radius of the rounded corners
      color - the Color object to use
    • drawCircle

      public static void drawCircle(float x, float y, float radius)
      Draws a circle.
      Parameters:
      x - the x-coordinate of the center
      y - the y-coordinate of the center
      radius - the radius of the circle
    • drawCircle

      public static void drawCircle(float x, float y, float radius, String colorName)
      Draws a circle in a specific color.
      Parameters:
      x - the x-coordinate of the center
      y - the y-coordinate of the center
      radius - the radius of the circle
      colorName - the name of the color to use
    • drawCircle

      public static void drawCircle(float x, float y, float radius, com.badlogic.gdx.graphics.Color color)
      Draws a circle in a specific color.
      Parameters:
      x - the x-coordinate of the center
      y - the y-coordinate of the center
      radius - the radius of the circle
      color - the color object
    • drawCircle

      public static void drawCircle(float x, float y, float radius, int segments)
      Draws a circle with a specified number of segments.
      Parameters:
      x - the x-coordinate of the center
      y - the y-coordinate of the center
      radius - the radius of the circle
      segments - the number of segments used to approximate the circle
    • drawCircle

      public static void drawCircle(float x, float y, float radius, int segments, String colorName)
      Draws a circle in a specific color with a specified number of segments.
      Parameters:
      x - the x-coordinate of the center
      y - the y-coordinate of the center
      radius - the radius of the circle
      segments - the number of segments used to approximate the circle
      colorName - the name of the color to use
    • drawCircle

      public static void drawCircle(float x, float y, float radius, int segments, com.badlogic.gdx.graphics.Color color)
      Draws a circle in a specific color with a specified number of segments.
      Parameters:
      x - the x-coordinate of the center
      y - the y-coordinate of the center
      radius - the radius of the circle
      segments - the number of segments used to approximate the circle
      color - the color object
    • drawEllipse

      public static void drawEllipse(float x, float y, float width, float height)
      Draws an ellipse.
      Parameters:
      x - the x-coordinate of the bottom-left corner
      y - the y-coordinate of the bottom-left corner
      width - the width of the ellipse
      height - the height of the ellipse
    • drawEllipse

      public static void drawEllipse(float x, float y, float width, float height, String colorName)
      Draws an ellipse in a specific color.
      Parameters:
      x - the x-coordinate of the bottom-left corner
      y - the y-coordinate of the bottom-left corner
      width - the width of the ellipse
      height - the height of the ellipse
      colorName - the name of the color to use
    • drawEllipse

      public static void drawEllipse(float x, float y, float width, float height, com.badlogic.gdx.graphics.Color color)
      Draws an ellipse in a specific color.
      Parameters:
      x - the x-coordinate of the bottom-left corner
      y - the y-coordinate of the bottom-left corner
      width - the width of the ellipse
      height - the height of the ellipse
      color - the color object
    • drawEllipseCentered

      public static void drawEllipseCentered(float centerX, float centerY, float width, float height)
      Draws an ellipse centered on a specified point.
      Parameters:
      centerX - the x-coordinate of the ellipse's center
      centerY - the y-coordinate of the ellipse's center
      width - the width of the ellipse
      height - the height of the ellipse
    • drawEllipseCentered

      public static void drawEllipseCentered(float centerX, float centerY, float width, float height, String colorName)
      Draws an ellipse centered on a specified point with a color name.
      Parameters:
      centerX - the x-coordinate of the ellipse's center
      centerY - the y-coordinate of the ellipse's center
      width - the width of the ellipse
      height - the height of the ellipse
      colorName - the name of the color to use
    • drawEllipseCentered

      public static void drawEllipseCentered(float centerX, float centerY, float width, float height, com.badlogic.gdx.graphics.Color color)
      Draws an ellipse centered on a specified point with a Color object.
      Parameters:
      centerX - the x-coordinate of the ellipse's center
      centerY - the y-coordinate of the ellipse's center
      width - the width of the ellipse
      height - the height of the ellipse
      color - the color object to use
    • drawLine

      public static void drawLine(float x1, float y1, float x2, float y2)
      Draws a line.
      Parameters:
      x1 - the x-coordinate of the start point
      y1 - the y-coordinate of the start point
      x2 - the x-coordinate of the end point
      y2 - the y-coordinate of the end point
    • drawLine

      public static void drawLine(float x1, float y1, float x2, float y2, String colorName)
      Draws a line in a specific color.
      Parameters:
      x1 - the x-coordinate of the start point
      y1 - the y-coordinate of the start point
      x2 - the x-coordinate of the end point
      y2 - the y-coordinate of the end point
      colorName - the name of the color to use
    • drawLine

      public static void drawLine(float x1, float y1, float x2, float y2, com.badlogic.gdx.graphics.Color color)
      Draws a line in a specific color.
      Parameters:
      x1 - the x-coordinate of the start point
      y1 - the y-coordinate of the start point
      x2 - the x-coordinate of the end point
      y2 - the y-coordinate of the end point
      color - the color object
    • drawPolygon

      public static void drawPolygon(float[] vertices)
      Draws a polygon.
      Parameters:
      vertices - the array of vertices {x1, y1, x2, y2, ...}
    • drawPolygon

      public static void drawPolygon(float[] vertices, String colorName)
      Draws a polygon in a specific color.
      Parameters:
      vertices - the array of vertices {x1, y1, x2, y2, ...}
      colorName - the name of the color to use
    • drawPolygon

      public static void drawPolygon(float[] vertices, com.badlogic.gdx.graphics.Color color)
      Draws a polygon in a specific color.
      Parameters:
      vertices - the array of vertices {x1, y1, x2, y2, ...}
      color - the color object
    • getSpriteBatch

      public static com.badlogic.gdx.graphics.g2d.SpriteBatch getSpriteBatch()
      Returns the shared SpriteBatch instance used for rendering sprites.
      Returns:
      the global SpriteBatch instance
    • startSpriteRendering

      public static void startSpriteRendering()
      Begins sprite rendering.
      Throws:
      IllegalStateException - if called while a mask is active
    • endSpriteRendering

      public static void endSpriteRendering()
      Ends the current sprite rendering batch.
    • addTexture

      public static void addTexture(String name, String filePath)
      Loads a texture from a file path and stores it in the global texture registry.
      Parameters:
      name - the name to associate with the texture
      filePath - the internal file path of the texture image
    • addTexture

      public static void addTexture(String name, String filePath, com.badlogic.gdx.graphics.Texture.TextureFilter filter)
      Loads a texture from a file path and stores it in the global texture registry.
      Parameters:
      name - the name to associate with the texture
      filePath - the internal file path of the texture image
      filter - the quality filter for the texture (when scaling)
    • addTexture

      public static void addTexture(String name, String filePath, com.badlogic.gdx.graphics.Texture.TextureFilter minFilter, com.badlogic.gdx.graphics.Texture.TextureFilter maxFilter)
      Loads a texture from a file path and stores it in the global texture registry.
      Parameters:
      name - the name to associate with the texture
      filePath - the internal file path of the texture image
      minFilter - the filter used when scaling down the texture
      maxFilter - the filter used when scaling up the texture
    • getTexture

      public static com.badlogic.gdx.graphics.Texture getTexture(String name)
      Retrieves a texture from the global texture registry by name.
      Parameters:
      name - the name of the texture
      Returns:
      the Texture associated with the name
      Throws:
      IllegalArgumentException - if the texture has not been loaded
    • getTextureWidth

      public static int getTextureWidth(String name)
      Returns the width in pixels of the texture with the given name.
      Parameters:
      name - the name or identifier of the texture
      Returns:
      the width of the texture in pixels
      Throws:
      IllegalArgumentException - if no texture is found for the given name
    • getTextureHeight

      public static int getTextureHeight(String name)
      Returns the height in pixels of the texture with the given name.
      Parameters:
      name - the name or identifier of the texture
      Returns:
      the height of the texture in pixels
      Throws:
      IllegalArgumentException - if no texture is found for the given name
    • hasTexture

      public static boolean hasTexture(String name)
      Returns if texture is available with the given name
      Parameters:
      name - Name of the texture
      Returns:
      True, if it exists
    • disposeTexture

      public static void disposeTexture(String name)
      Remove the texture and unload it from the memory.
      Parameters:
      name - Name of the texture
    • drawTexture

      public static void drawTexture(String name, float x, float y)
      Draws a texture at the specified position using the current sprite batch.
      Parameters:
      name - the name of the loaded texture
      x - the x-coordinate of the bottom-left corner
      y - the y-coordinate of the bottom-left corner
      Throws:
      IllegalArgumentException - if the texture has not been loaded
    • drawTexture

      public static void drawTexture(String name, float x, float y, float width, float height)
      Draws a texture at the specified position and size using the current sprite batch.
      Parameters:
      name - the name of the loaded texture
      x - the x-coordinate of the bottom-left corner
      y - the y-coordinate of the bottom-left corner
      width - the width to draw the texture
      height - the height to draw the texture
      Throws:
      IllegalArgumentException - if the texture has not been loaded
    • drawTexture

      public static void drawTexture(String name, float x, float y, float width, float height, float rotationDegrees, boolean flipX, boolean flipY)
      Draws a texture at the specified position, size, rotation, and flipping using the current sprite batch.

      The rotation is performed around the center of the drawn texture. Flip parameters allow mirroring horizontally or vertically.

      Parameters:
      name - the name of the loaded texture
      x - the x-coordinate of the bottom-left corner
      y - the y-coordinate of the bottom-left corner
      width - the width to draw the texture
      height - the height to draw the texture
      rotationDegrees - the rotation in degrees (clockwise)
      flipX - whether to flip the texture horizontally
      flipY - whether to flip the texture vertically
      Throws:
      IllegalArgumentException - if the texture has not been loaded
    • drawTextureCentered

      public static void drawTextureCentered(String name, float centerX, float centerY)
      Draws a texture centered at the specified position using the current sprite batch.
      Parameters:
      name - the name of the loaded texture
      centerX - the x-coordinate of the center
      centerY - the y-coordinate of the center
      Throws:
      IllegalArgumentException - if the texture has not been loaded
    • drawTextureCentered

      public static void drawTextureCentered(String name, float centerX, float centerY, float width, float height)
      Draws a texture centered at the specified position with size using the current sprite batch.
      Parameters:
      name - the name of the loaded texture
      centerX - the x-coordinate of the center
      centerY - the y-coordinate of the center
      width - the width to draw the texture
      height - the height to draw the texture
      Throws:
      IllegalArgumentException - if the texture has not been loaded
    • drawTextureCentered

      public static void drawTextureCentered(String name, float centerX, float centerY, float width, float height, float rotationDegrees, boolean flipX, boolean flipY)
      Draws a texture centered at the specified position with size, rotation, and flipping using the current sprite batch.

      Rotation is around the center of the texture.

      Parameters:
      name - the name of the loaded texture
      centerX - the x-coordinate of the center
      centerY - the y-coordinate of the center
      width - the width to draw the texture
      height - the height to draw the texture
      rotationDegrees - the rotation in degrees (clockwise)
      flipX - whether to flip the texture horizontally
      flipY - whether to flip the texture vertically
      Throws:
      IllegalArgumentException - if the texture has not been loaded
    • addFont

      public static void addFont(String name, String filePath, float size, boolean usePixelSize)
      Loads a TTF or OTF font, optionally scaling it to world height or keeping pixel size.
      Parameters:
      name - Name to reference the font
      filePath - Path to the TTF/OTF file in assets
      size - Font size in pixels
      usePixelSize - True to use literal pixel size (good for HUD), false to scale to world height
    • addFont

      public static void addFont(String name, String filePath, float size)
      Overload: Adds a font that scales to world height by default.
      Parameters:
      name - Name to reference the font
      filePath - Path to the TTF/OTF file
      size - Font size in pixels
    • addFont

      public static void addFont(String name, com.badlogic.gdx.graphics.g2d.BitmapFont font)
      Registers an already created BitmapFont under a given name.
      Parameters:
      name - Name to reference the font
      font - Pre-created BitmapFont
    • addStyledFont

      public static void addStyledFont(String name, String filePath, int size, com.badlogic.gdx.graphics.Color color, float borderWidth, com.badlogic.gdx.graphics.Color borderColor, int shadowOffsetX, int shadowOffsetY, com.badlogic.gdx.graphics.Color shadowColor, boolean usePixelSize)
      Loads a styled TTF font with optional border and shadow, with world-scaling or pixel-perfect option.
      Parameters:
      name - Name to reference the font
      filePath - Path to the TTF/OTF file
      size - Font size in pixels
      color - Base color
      borderWidth - Width of border (0 = no border)
      borderColor - Color of border (ignored if borderWidth = 0)
      shadowOffsetX - Shadow X offset
      shadowOffsetY - Shadow Y offset
      shadowColor - Shadow color
      usePixelSize - True to use pixel size (HUD), false to scale to world height
    • addStyledFont

      public static void addStyledFont(String name, String filePath, int size, String colorName, float borderWidth, String borderColorName, int shadowOffsetX, int shadowOffsetY, String shadowColorName, boolean usePixelSize)
      Styled font with named colors (throws if color names not found).
      Parameters:
      name - Name to reference the font
      filePath - TTF/OTF file path
      size - Font size
      colorName - Base color name
      borderWidth - Border width
      borderColorName - Border color name
      shadowOffsetX - Shadow X offset
      shadowOffsetY - Shadow Y offset
      shadowColorName - Shadow color name
      usePixelSize - True = pixel size, false = world-scaled
    • getFont

      public static com.badlogic.gdx.graphics.g2d.BitmapFont getFont(String name)
      Retrieves a loaded font by its name.
      Parameters:
      name - Name of the loaded font.
      Returns:
      The BitmapFont associated with the given name.
      Throws:
      IllegalArgumentException - if the font is not found.
    • hasFont

      public static boolean hasFont(String name)
      Returns if font is available with the given name
      Parameters:
      name - Name of the font
      Returns:
      True, if it exists
    • disposeFont

      public static void disposeFont(String name)
      Remove the font and unload it from the memory.
      Parameters:
      name - Name of the font.
    • drawText

      public static void drawText(String fontName, String text, float x, float y, com.badlogic.gdx.graphics.Color color)
      Draws text left-bottom aligned at the specified position with a given color.
      Parameters:
      fontName - Name of the loaded font.
      text - Text to draw.
      x - X-coordinate of the bottom-left corner of the text.
      y - Y-coordinate of the bottom-left corner of the text.
      color - Color to render the text.
    • drawText

      public static void drawText(String fontName, String text, float x, float y, String color)
      Draws text left-bottom aligned at the specified position with a given color.
      Parameters:
      fontName - Name of the loaded font.
      text - Text to draw.
      x - X-coordinate of the bottom-left corner of the text.
      y - Y-coordinate of the bottom-left corner of the text.
      color - Color to render the text.
    • drawTextCentered

      public static void drawTextCentered(String fontName, String text, float centerX, float centerY, com.badlogic.gdx.graphics.Color color)
      Draws text centered on a specified point with a given color.
      Parameters:
      fontName - Name of the loaded font.
      text - Text to draw.
      centerX - X-coordinate of the center of the text.
      centerY - Y-coordinate of the center of the text.
      color - Color to render the text.
    • drawTextCentered

      public static void drawTextCentered(String fontName, String text, float centerX, float centerY, String color)
      Draws text centered on a specified point with a given color.
      Parameters:
      fontName - Name of the loaded font.
      text - Text to draw.
      centerX - X-coordinate of the center of the text.
      centerY - Y-coordinate of the center of the text.
      color - Color to render the text.
    • drawTextHorizontallyCentered

      public static void drawTextHorizontallyCentered(String fontName, String text, float centerX, float y, com.badlogic.gdx.graphics.Color color)
      Draws text horizontally centered at a given X-coordinate with a given Y-coordinate and color.
      Parameters:
      fontName - Name of the loaded font.
      text - Text to draw.
      centerX - X-coordinate of the horizontal center of the text.
      y - Y-coordinate for the text baseline.
      color - Color to render the text.
    • drawTextHorizontallyCentered

      public static void drawTextHorizontallyCentered(String fontName, String text, float centerX, float y, String color)
      Overload with color as string.
    • drawTextVerticallyCentered

      public static void drawTextVerticallyCentered(String fontName, String text, float x, float centerY, com.badlogic.gdx.graphics.Color color)
      Draws text vertically centered at a given Y-coordinate with a given X-coordinate and color.
      Parameters:
      fontName - Name of the loaded font.
      text - Text to draw.
      x - X-coordinate for the left of the text.
      centerY - Y-coordinate of the vertical center of the text.
      color - Color to render the text.
    • drawTextVerticallyCentered

      public static void drawTextVerticallyCentered(String fontName, String text, float x, float centerY, String color)
      Overload with color as string.
    • getTextWidth

      public static float getTextWidth(String fontName, String text)
      Returns the width of a given text in pixels when rendered with the specified font.
      Parameters:
      fontName - Name of the loaded font.
      text - Text to measure.
      Returns:
      Width of the text in pixels.
    • getTextHeight

      public static float getTextHeight(String fontName, String text)
      Returns the height of a given text in pixels when rendered with the specified font.
      Parameters:
      fontName - Name of the loaded font.
      text - Text to measure.
      Returns:
      Height of the text in pixels.
    • clamp

      public static float clamp(float value, float min, float max)
      Clamps a value to be within the specified minimum and maximum range.
      Parameters:
      value - the value to clamp
      min - the minimum allowable value
      max - the maximum allowable value
      Returns:
      the clamped value; if value is less than min, returns min, if value is greater than max, returns max, otherwise returns value itself
    • random

      public static float random(float min, float max)
      Returns a random float value within the specified range. The minimim is inclusive, the maximum is exclusive.
      Parameters:
      min - the lower bound
      max - the upper bound
      Returns:
      a random float between min and max
    • randomInt

      public static int randomInt(int min, int max)
      Returns a random int value within the specified range. The minimim is inclusive, the maximum is exclusive.
      Parameters:
      min - the lower bound
      max - the upper bound
      Returns:
      a random int between min and max
    • random

      public static <T> T random(T[] array)
      Returns a random element from an array.
      Type Parameters:
      T - type of elements
      Parameters:
      array - the array to pick from
      Returns:
      a random element from the array
      Throws:
      IllegalArgumentException - if the array is null or empty
    • random

      public static <T> T random(List<T> list)
      Returns a random element from a List of any type.
      Type Parameters:
      T - the type of elements
      Parameters:
      list - the list to pick from
      Returns:
      a random element from the list
      Throws:
      IllegalArgumentException - if the list is null or empty
    • rectOverlap

      public static boolean rectOverlap(float x1, float y1, float w1, float h1, float x2, float y2, float w2, float h2)
      Checks if two axis-aligned rectangles overlap.
      Parameters:
      x1 - X of first rectangle
      y1 - Y of first rectangle
      w1 - Width of first rectangle
      h1 - Height of first rectangle
      x2 - X of second rectangle
      y2 - Y of second rectangle
      w2 - Width of second rectangle
      h2 - Height of second rectangle
      Returns:
      true if the rectangles intersect
    • rectOverlap

      public static boolean rectOverlap(com.badlogic.gdx.math.Rectangle r1, com.badlogic.gdx.math.Rectangle r2)
    • circleOverlap

      public static boolean circleOverlap(float x1, float y1, float r1, float x2, float y2, float r2)
      Checks if two circles overlap.
      Parameters:
      x1 - X center of first circle
      y1 - Y center of first circle
      r1 - Radius of first circle
      x2 - X center of second circle
      y2 - Y center of second circle
      r2 - Radius of second circle
      Returns:
      true if the circles intersect
    • circleOverlap

      public static boolean circleOverlap(com.badlogic.gdx.math.Circle c1, com.badlogic.gdx.math.Circle c2)
    • rectCircleOverlap

      public static boolean rectCircleOverlap(float rectX, float rectY, float rectW, float rectH, float circleX, float circleY, float radius)
      Checks if an axis-aligned rectangle and a circle overlap.
      Parameters:
      rectX - X of rectangle
      rectY - Y of rectangle
      rectW - Width of rectangle
      rectH - Height of rectangle
      circleX - X center of circle
      circleY - Y center of circle
      radius - Radius of circle
      Returns:
      true if the rectangle and circle intersect
    • rectCircleOverlap

      public static boolean rectCircleOverlap(com.badlogic.gdx.math.Rectangle rect, com.badlogic.gdx.math.Circle circle)
    • pointInRect

      public static boolean pointInRect(float px, float py, float rx, float ry, float rw, float rh)
      Checks if a point is inside a rectangle.
      Parameters:
      px - X coordinate of the point
      py - Y coordinate of the point
      rx - X of rectangle
      ry - Y of rectangle
      rw - Width of rectangle
      rh - Height of rectangle
      Returns:
      true if the point is inside the rectangle
    • pointInRect

      public static boolean pointInRect(com.badlogic.gdx.math.Vector2 point, com.badlogic.gdx.math.Rectangle rect)
    • pointInCircle

      public static boolean pointInCircle(float px, float py, float cx, float cy, float radius)
      Checks if a point is inside a circle.
      Parameters:
      px - X coordinate of the point
      py - Y coordinate of the point
      cx - X center of circle
      cy - Y center of circle
      radius - Radius of the circle
      Returns:
      true if the point is inside the circle
    • pointInCircle

      public static boolean pointInCircle(com.badlogic.gdx.math.Vector2 point, com.badlogic.gdx.math.Circle circle)
    • rectContainsRect

      public static boolean rectContainsRect(float x1, float y1, float w1, float h1, float x2, float y2, float w2, float h2)
      Checks if one rectangle is completely contained within another rectangle.
      Parameters:
      x1 - X of outer rectangle
      y1 - Y of outer rectangle
      w1 - Width of outer rectangle
      h1 - Height of outer rectangle
      x2 - X of inner rectangle
      y2 - Y of inner rectangle
      w2 - Width of inner rectangle
      h2 - Height of inner rectangle
      Returns:
      true if the inner rectangle is fully inside the outer rectangle
    • rectContainsRect

      public static boolean rectContainsRect(com.badlogic.gdx.math.Rectangle outer, com.badlogic.gdx.math.Rectangle inner)
    • distance

      public static float distance(float x1, float y1, float x2, float y2)
      Calculates the distance between two points.
      Parameters:
      x1 - X of first point
      y1 - Y of first point
      x2 - X of second point
      y2 - Y of second point
      Returns:
      distance between the points
    • angleBetween

      public static float angleBetween(float x1, float y1, float x2, float y2)
      Calculates the angle in degrees from the first point to the second point. 0 degrees points to the right (positive X axis), angles increase counter-clockwise.
      Parameters:
      x1 - X of first point
      y1 - Y of first point
      x2 - X of second point
      y2 - Y of second point
      Returns:
      angle in degrees from the first point to the second point
    • moveInDirection

      public static float[] moveInDirection(float x, float y, float distance, float directionDegrees)
      Computes new coordinates by moving from a starting point in a specified direction and distance.

      The direction is in degrees, where 0° points to the right (positive X-axis) and increases counterclockwise: 90° is up, 180° is left, 270° is down.

      Parameters:
      x - the starting x-coordinate
      y - the starting y-coordinate
      distance - the distance to move (can also be thought of as speed)
      directionDegrees - the movement direction in degrees
      Returns:
      a float array of length 2, where index 0 is the new x-coordinate and index 1 is the new y-coordinate
    • addItemToStore

      public static void addItemToStore(String name, Object anyType)
      Add item to the application store, so that it can be used in multiple screens.
      Parameters:
      name - Key in the store
      anyType - Object to store
    • hasItemInStore

      public static boolean hasItemInStore(String name)
      Check if an item exists with the given name
      Parameters:
      name - Name of the item
      Returns:
      True, in case the item exists.
    • getItemFromStore

      public static Object getItemFromStore(String name)
      Get an item from the application store by name.
      Parameters:
      name - Name of the item in the store
      Returns:
      Object, if available. Otherwise, exception.
    • removeItemFromStore

      public static boolean removeItemFromStore(String name)
      Remove an item from the store by name.
      Parameters:
      name - Name of the item
      Returns:
      true if the item existed and was removed, false otherwise
    • saveToBinary

      public static void saveToBinary(Object object, String fileName)
      Saves any object to a binary file.
      Parameters:
      object - the object to serialize
      fileName - the file name (e.g., "savegame.bin")
    • loadFromBinary

      public static Object loadFromBinary(String fileName)
      Loads any object from a binary file.
      Parameters:
      fileName - the file name
      Returns:
      the deserialized object, or null if file doesn't exist
    • fileExists

      public static boolean fileExists(String fileName)
      Checks if the save file exists.
      Parameters:
      fileName - filename
      Returns:
      true, if the file exists
    • saveToJson

      public static void saveToJson(Object object, String fileName)
      Serialize any object to JSON and save to a file.
      Parameters:
      object - the object to serialize
      fileName - the file name (e.g., "savegame.json")
    • loadFromJson

      public static <T> T loadFromJson(String fileName, Class<T> type)
      Load an object from a JSON file.
      Type Parameters:
      T - the type parameter
      Parameters:
      fileName - the file name
      type - the class type of the object to load
      Returns:
      the deserialized object
      Throws:
      IllegalArgumentException - if the file doesn't exist
    • addInterpolator

      public static void addInterpolator(String name, float start, float end, float duration, com.badlogic.gdx.math.Interpolation strategy)
      Creates a new interpolator with the given name. If an interpolator with the same name exists, it will be replaced.
      Parameters:
      name - the unique name of the interpolator
      start - the starting value
      end - the ending value
      duration - the duration of the interpolation in seconds
      strategy - the interpolation strategy (e.g., Interpolation.pow2Out, Interpolation.bounce)
    • addInterpolator

      public static void addInterpolator(String name, float start, float end, float duration, String strategy)
      Creates a new interpolator with the given name. If an interpolator with the same name exists, it will be replaced.
      Parameters:
      name - the unique name of the interpolator
      start - the starting value
      end - the ending value
      duration - the duration of the interpolation in seconds
      strategy - the interpolation strategy (e.g., "bounce", "elastic", "pow1")
    • getInterpolationStrategies

      public static String[] getInterpolationStrategies()
      Get a list of all the possible interpolation strategies available
      Returns:
      String[] with all possible interpolation strategies.
    • disposeInterpolator

      public static void disposeInterpolator(String name)
      Removes an interpolator from the internal registry. After calling this, the interpolator with the given name will no longer exist.
      Parameters:
      name - the name of the interpolator to remove (case-insensitive)
    • hasInterpolator

      public static boolean hasInterpolator(String name)
      Checks whether an interpolator with the given name exists.
      Parameters:
      name - the name of the interpolator to check (case-insensitive)
      Returns:
      true if the interpolator exists, false otherwise
    • getInterpolator

      public static Interpolator getInterpolator(String name)
      Retrieves an existing interpolator by name. Use this if you need to access the interpolator object directly.
      Parameters:
      name - the name of the interpolator to retrieve (case-insensitive)
      Returns:
      the Interpolator instance, or null if it does not exist
    • updateInterpolator

      public static float updateInterpolator(String name)
      Updates the interpolator with the given name and returns the current value.

      This method should be called every frame (e.g., inside the render loop).

      Parameters:
      name - the name of the interpolator
      Returns:
      the current interpolated value
      Throws:
      IllegalArgumentException - if no interpolator exists with the given name
    • isInterpolatorFinished

      public static boolean isInterpolatorFinished(String name)
      Checks whether the interpolator has finished its animation.
      Parameters:
      name - the name of the interpolator
      Returns:
      true if the interpolation has completed, false otherwise
      Throws:
      IllegalArgumentException - if no interpolator exists with the given name
    • resetInterpolator

      public static void resetInterpolator(String name)
      Resets the interpolator with the given name to start its animation from the beginning. If the interpolator does not exist, this method does nothing.
      Parameters:
      name - the name of the interpolator
    • resetInterpolator

      public static void resetInterpolator(String name, boolean reverse)
      Resets the interpolator with the given name to start its animation from the beginning. If the interpolator does not exist, this method does nothing.
      Parameters:
      name - the name of the interpolator
      reverse - should the animation be reversed?
    • addSpriteSheet

      public static void addSpriteSheet(String name, String filePath, int frameWidth, int frameHeight)
      Loads a spritesheet from a file, slices it into frames, and stores the frames. The underlying Texture is not added to the global texture map.
      Parameters:
      name - the name to identify the spritesheet
      filePath - the internal file path of the texture
      frameWidth - the width of a single frame
      frameHeight - the height of a single frame
    • getSpritesheetFrame

      public static com.badlogic.gdx.graphics.g2d.TextureRegion getSpritesheetFrame(String name, int row, int col)
      Retrieve a specific frame from a spritesheet.
      Parameters:
      name - the spritesheet name
      row - the row index (0-based)
      col - the column index (0-based)
      Returns:
      the TextureRegion for the requested frame
      Throws:
      IllegalArgumentException - if the spritesheet does not exist
      IndexOutOfBoundsException - if row/col are invalid
    • drawSpritesheetFrame

      public static void drawSpritesheetFrame(String name, int row, int col, float x, float y)
      Draw a specific frame from a spritesheet at the given position.
      Parameters:
      name - the spritesheet name
      row - the row index (0-based)
      col - the column index (0-based)
      x - the x-coordinate of the bottom-left corner
      y - the y-coordinate of the bottom-left corner
    • drawSpritesheetFrame

      public static void drawSpritesheetFrame(String name, int row, int col, float x, float y, float width, float height)
      Draw a specific frame with scaling.
      Parameters:
      name - the spritesheet name
      row - the row index (0-based)
      col - the column index (0-based)
      x - the x-coordinate
      y - the y-coordinate
      width - the width to draw
      height - the height to draw
    • drawSpritesheetFrame

      public static void drawSpritesheetFrame(String name, int row, int col, float x, float y, float width, float height, float rotationDegrees, boolean flipX, boolean flipY)
      Draw a specific frame with scaling, rotation, and flipping.
      Parameters:
      name - the spritesheet name
      row - the row index (0-based)
      col - the column index (0-based)
      x - the x-coordinate
      y - the y-coordinate
      width - the width to draw
      height - the height to draw
      rotationDegrees - rotation in degrees (clockwise)
      flipX - whether to flip horizontally
      flipY - whether to flip vertically
    • drawSpritesheetFrameCentered

      public static void drawSpritesheetFrameCentered(String name, int row, int col, float centerX, float centerY)
      Draw a frame centered at a given position.
      Parameters:
      name - the spritesheet name
      row - the row index (0-based)
      col - the column index (0-based)
      centerX - the x-coordinate of the center
      centerY - the y-coordinate of the center
    • drawSpritesheetFrameCentered

      public static void drawSpritesheetFrameCentered(String name, int row, int col, float centerX, float centerY, float width, float height)
      Draw a frame centered with scaling.
      Parameters:
      name - the spritesheet name
      row - the row index (0-based)
      col - the column index (0-based)
      centerX - the x-coordinate of the center
      centerY - the y-coordinate of the center
      width - the width to draw
      height - the height to draw
    • drawSpritesheetFrameCentered

      public static void drawSpritesheetFrameCentered(String name, int row, int col, float centerX, float centerY, float width, float height, float rotationDegrees, boolean flipX, boolean flipY)
      Draw a frame centered with scaling, rotation, and flipping.
      Parameters:
      name - the spritesheet name
      row - the row index (0-based)
      col - the column index (0-based)
      centerX - the x-coordinate of the center
      centerY - the y-coordinate of the center
      width - the width to draw
      height - the height to draw
      rotationDegrees - rotation in degrees (clockwise)
      flipX - whether to flip horizontally
      flipY - whether to flip vertically
    • getSpritesheetNumberOfRows

      public static int getSpritesheetNumberOfRows(String name)
      Returns the number of rows in the specified spritesheet.
      Parameters:
      name - the name of the spritesheet
      Returns:
      the number of rows
      Throws:
      IllegalArgumentException - if the spritesheet does not exist
    • getSpritesheetNumberOfCols

      public static int getSpritesheetNumberOfCols(String name)
      Returns the number of columns in the specified spritesheet.

      Assumes all rows have the same number of columns.

      Parameters:
      name - the name of the spritesheet
      Returns:
      the number of columns
      Throws:
      IllegalArgumentException - if the spritesheet does not exist
    • hasSpritesheet

      public static boolean hasSpritesheet(String name)
      Returns if a spritesheet is available with the given name.
      Parameters:
      name - the name of the spritesheet
      Returns:
      true if it exists, false otherwise
    • disposeSpritesheet

      public static void disposeSpritesheet(String name)
      Removes the spritesheet and disposes its underlying Texture.
      Parameters:
      name - the name of the spritesheet
    • addTextureAtlas

      public static void addTextureAtlas(String name, String filePath)
      Loads a texture atlas and stores it in the internal atlas map.
      Parameters:
      name - the name to identify the atlas
      filePath - the path to the .atlas file
    • hasAtlas

      public static boolean hasAtlas(String name)
      Returns if an atlas is available with the given name
      Parameters:
      name - the name of the atlas
      Returns:
      true if it exists, false otherwise
    • disposeAtlas

      public static void disposeAtlas(String name)
      Removes the atlas and disposes it from memory.
      Parameters:
      name - the name of the atlas
    • getAtlasRegion

      public static com.badlogic.gdx.graphics.g2d.TextureRegion getAtlasRegion(String atlasName, String regionName)
      Retrieves a TextureRegion from a loaded texture atlas.

      This method automatically supports both single-region and indexed multi-region atlases. If the region name ends with an underscore followed by a number (e.g. "walk_1"), the method will interpret it as an indexed region and fetch the correct frame from the corresponding atlas sequence.

      For example:

       getAtlasRegion("characters", "walk_0"); // retrieves the first frame
       getAtlasRegion("characters", "walk_1"); // retrieves the second frame
       getAtlasRegion("characters", "idle");   // retrieves a single non-indexed region
       
      Parameters:
      atlasName - the name of the atlas
      regionName - the name of the region inside the atlas (optionally ending with _N)
      Returns:
      the TextureRegion for the requested region
      Throws:
      IllegalArgumentException - if the atlas or region does not exist
    • getAtlas

      public static com.badlogic.gdx.graphics.g2d.TextureAtlas getAtlas(String name)
      Get the texture atlas object.
      Parameters:
      name - Name of the texture atlas
      Returns:
      Texture atlas object
    • drawAtlasRegion

      public static void drawAtlasRegion(String atlasName, String regionName, float x, float y)
      Draws a region from an atlas at the specified position.
      Parameters:
      atlasName - the name of the atlas
      regionName - the name of the region
      x - the x-coordinate of the bottom-left corner
      y - the y-coordinate of the bottom-left corner
    • drawAtlasRegion

      public static void drawAtlasRegion(String atlasName, String regionName, float x, float y, float width, float height)
      Draws a region from an atlas at the specified position with scaling.
      Parameters:
      atlasName - the name of the atlas
      regionName - the name of the region
      x - the x-coordinate
      y - the y-coordinate
      width - the width to draw
      height - the height to draw
    • drawAtlasRegion

      public static void drawAtlasRegion(String atlasName, String regionName, float x, float y, float width, float height, float rotationDegrees, boolean flipX, boolean flipY)
      Draws a region from an atlas at the specified position with scaling, rotation, and flipping.
      Parameters:
      atlasName - the name of the atlas
      regionName - the name of the region
      x - the x-coordinate
      y - the y-coordinate
      width - the width to draw
      height - the height to draw
      rotationDegrees - rotation in degrees (clockwise)
      flipX - whether to flip horizontally
      flipY - whether to flip vertically
    • drawAtlasRegionCentered

      public static void drawAtlasRegionCentered(String atlasName, String regionName, float centerX, float centerY)
      Draws a region from an atlas centered at a given position.
      Parameters:
      atlasName - the name of the atlas
      regionName - the name of the region
      centerX - the x-coordinate of the center
      centerY - the y-coordinate of the center
    • drawAtlasRegionCentered

      public static void drawAtlasRegionCentered(String atlasName, String regionName, float centerX, float centerY, float width, float height)
      Draws a region from an atlas centered with scaling.
      Parameters:
      atlasName - the name of the atlas
      regionName - the name of the region
      centerX - the x-coordinate of the center
      centerY - the y-coordinate of the center
      width - the width to draw
      height - the height to draw
    • drawAtlasRegionCentered

      public static void drawAtlasRegionCentered(String atlasName, String regionName, float centerX, float centerY, float width, float height, float rotationDegrees, boolean flipX, boolean flipY)
      Draws a region from an atlas centered with scaling, rotation, and flipping.
      Parameters:
      atlasName - the name of the atlas
      regionName - the name of the region
      centerX - the x-coordinate of the center
      centerY - the y-coordinate of the center
      width - the width to draw
      height - the height to draw
      rotationDegrees - rotation in degrees (clockwise)
      flipX - whether to flip horizontally
      flipY - whether to flip vertically
    • addEmptyAnimation

      public static void addEmptyAnimation(String name, float frameDuration, boolean loop)
      Creates an empty animation with a given frame duration and loop flag. Frames can be added manually later using addAnimationFrame or addAnimationFrameFromAtlas.
      Parameters:
      name - the unique name of the animation
      frameDuration - the duration of each frame in seconds
      loop - whether the animation should loop
    • addAnimationFromSpritesheet

      public static void addAnimationFromSpritesheet(String name, String spritesheet, float frameDuration, boolean loop)
      Adds a new animation using all frames from the specified spritesheet. Frames are taken row by row, left to right. Replaces any existing animation with the same name.
      Parameters:
      name - the unique animation name
      spritesheet - the name of the spritesheet
      frameDuration - seconds per frame
      loop - whether the animation should loop
      Throws:
      IllegalArgumentException - if the spritesheet does not exist
    • addAnimation

      public static void addAnimation(String name, com.badlogic.gdx.graphics.g2d.TextureRegion[] frames, float frameDuration, boolean loop)
      Adds a new animation using manually specified frames. Replaces any existing animation with the same name.
      Parameters:
      name - the unique animation name
      frames - the array of frames to use
      frameDuration - seconds per frame
      loop - whether the animation should loop
    • addAnimationFrameFromSpritesheet

      public static void addAnimationFrameFromSpritesheet(String animationName, String spritesheet, int row, int col)
      Adds a single frame from a spritesheet (by row and column) to an existing animation.

      The animation **must already exist**. Use addEmptyAnimation(String, float, boolean) or one of the other add-animation methods to create it first.

      Parameters:
      animationName - the name of the animation (must already exist)
      spritesheet - the name of the spritesheet
      row - the row index (0-based)
      col - the column index (0-based)
      Throws:
      IllegalArgumentException - if the spritesheet or animation does not exist
      IndexOutOfBoundsException - if row/col are out of bounds
    • addAnimationFromAtlas

      public static void addAnimationFromAtlas(String name, String atlasName, String prefix, float frameDuration, boolean loop)
      Creates a new animation using all regions in a given atlas that match a prefix. Regions are automatically sorted alphabetically.
      Parameters:
      name - the name of the animation
      atlasName - the name of the loaded atlas
      prefix - the prefix of the region names to include (e.g., "run_")
      frameDuration - duration of each frame in seconds
      loop - whether the animation should loop
    • addAnimationFrameFromAtlas

      public static void addAnimationFrameFromAtlas(String animationName, String atlasName, String regionName)
      Adds a single region from an atlas to an existing animation.
      Parameters:
      animationName - the name of the animation
      atlasName - the name of the atlas
      regionName - the specific region name to add
    • hasAnimation

      public static boolean hasAnimation(String name)
      Checks if an animation exists.
      Parameters:
      name - the animation name
      Returns:
      true if it exists
    • disposeAnimation

      public static void disposeAnimation(String name)
      Removes an animation.
      Parameters:
      name - the animation name
    • getAnimation

      public static SpriteAnimation getAnimation(String name)
      Retrieves an animation by name.
      Parameters:
      name - the animation name
      Returns:
      the SpriteAnimation instance, or null if it does not exist
    • updateAnimation

      public static void updateAnimation(String name)
      Updates the animation by the frame's delta time.

      Students do not need to handle TextureRegion directly; drawing methods will automatically use the current frame.

      Parameters:
      name - the name of the animation
      Throws:
      IllegalArgumentException - if no animation exists with the given name
    • drawAnimation

      public static void drawAnimation(String name, float x, float y)
      Draws the current frame of the animation at the specified bottom-left position.
      Parameters:
      name - the name of the animation
      x - the x-coordinate of the bottom-left corner
      y - the y-coordinate of the bottom-left corner
      Throws:
      IllegalArgumentException - if no animation exists with the given name
    • drawAnimation

      public static void drawAnimation(String name, float x, float y, float width, float height)
      Draws the current frame of the animation at the specified position and size.
      Parameters:
      name - the name of the animation
      x - the x-coordinate of the bottom-left corner
      y - the y-coordinate of the bottom-left corner
      width - the width to draw
      height - the height to draw
      Throws:
      IllegalArgumentException - if no animation exists with the given name
    • drawAnimation

      public static void drawAnimation(String name, float x, float y, float width, float height, float rotationDegrees, boolean flipX, boolean flipY)
      Draws the current frame of the animation at the specified position, size, rotation, and flipping.
      Parameters:
      name - the name of the animation
      x - the x-coordinate of the bottom-left corner
      y - the y-coordinate of the bottom-left corner
      width - the width to draw
      height - the height to draw
      rotationDegrees - rotation in degrees (clockwise)
      flipX - whether to flip the frame horizontally
      flipY - whether to flip the frame vertically
      Throws:
      IllegalArgumentException - if no animation exists with the given name
    • drawAnimationCentered

      public static void drawAnimationCentered(String name, float centerX, float centerY)
      Draws the current frame of the animation centered at the specified position.
      Parameters:
      name - the name of the animation
      centerX - the x-coordinate of the center
      centerY - the y-coordinate of the center
      Throws:
      IllegalArgumentException - if no animation exists with the given name
    • drawAnimationCentered

      public static void drawAnimationCentered(String name, float centerX, float centerY, float width, float height)
      Draws the current frame of the animation centered at the specified position with the given size.
      Parameters:
      name - the name of the animation
      centerX - the x-coordinate of the center
      centerY - the y-coordinate of the center
      width - the width to draw
      height - the height to draw
      Throws:
      IllegalArgumentException - if no animation exists with the given name
    • drawAnimationCentered

      public static void drawAnimationCentered(String name, float centerX, float centerY, float width, float height, float rotationDegrees, boolean flipX, boolean flipY)
      Draws the current frame of the animation centered at the specified position with size, rotation, and flipping.
      Parameters:
      name - the name of the animation
      centerX - the x-coordinate of the center
      centerY - the y-coordinate of the center
      width - the width to draw
      height - the height to draw
      rotationDegrees - rotation in degrees (clockwise)
      flipX - whether to flip the frame horizontally
      flipY - whether to flip the frame vertically
      Throws:
      IllegalArgumentException - if no animation exists with the given name
    • isAnimationFinished

      public static boolean isAnimationFinished(String name)
      Checks if the animation has finished.
      Parameters:
      name - the animation name
      Returns:
      true if finished, false otherwise
      Throws:
      IllegalArgumentException - if no animation exists with the given name
    • resetAnimation

      public static void resetAnimation(String name)
      Resets an animation to start from the beginning.
      Parameters:
      name - the animation name
    • resetAnimation

      public static void resetAnimation(String name, boolean reverse)
      Resets an animation to start from the beginning, optionally reversing it.
      Parameters:
      name - the animation name
      reverse - whether to reverse the animation
    • jumpAnimationToFrame

      public static void jumpAnimationToFrame(String name, int frameIndex)
      Jumps the named animation to a specific frame.
      Parameters:
      name - the name of the animation
      frameIndex - the 0-based index of the frame
      Throws:
      IllegalArgumentException - if no animation exists with the given name
      IndexOutOfBoundsException - if the frame index is invalid
    • getAnimationCurrentFrameIndex

      public static int getAnimationCurrentFrameIndex(String name)
      Returns the index of the current frame of the named animation.
      Parameters:
      name - the name of the animation
      Returns:
      the 0-based index of the current frame
      Throws:
      IllegalArgumentException - if no animation exists with the given name
    • getAnimationFrameCount

      public static int getAnimationFrameCount(String name)
      Returns the total number of frames in the named animation.
      Parameters:
      name - the name of the animation
      Returns:
      the total number of frames
      Throws:
      IllegalArgumentException - if no animation exists with the given name
    • hideCursor

      public static void hideCursor()
      Hides the system mouse cursor.

      The cursor will be invisible, but you can still get the mouse coordinates.

    • showCursor

      public static void showCursor()
      Shows the default system mouse cursor.
    • setCustomCursor

      public static void setCustomCursor(String filePath, int hotspotX, int hotspotY)
      Sets a custom cursor image from a file.
      Parameters:
      filePath - the path to the cursor image (PNG)
      hotspotX - the x-coordinate of the active point (tip)
      hotspotY - the y-coordinate of the active point (tip)
    • setSystemCursor

      public static void setSystemCursor(com.badlogic.gdx.graphics.Cursor.SystemCursor systemCursor)
      Sets the system cursor to one of the default cursors.
      Parameters:
      systemCursor - the system cursor to use (e.g., Arrow, Hand, Crosshair, VerticalResize)
    • startMask

      public static void startMask()
      Starts a new mask definition. All subsequent shapes or textures will define the mask area.
      Throws:
      IllegalStateException - if sprite or shape rendering is currently active
    • endMask

      public static void endMask()
      Ends the mask definition and applies it to subsequent drawing. By default, the mask shows what was drawn in the mask layer.
    • invertMask

      public static void invertMask()
      Inverts the mask effect. Subsequent drawing will render outside the mask instead of inside it.
    • clearMask

      public static void clearMask()
      Clears the mask completely. Subsequent drawing will not be affected by any mask.
    • addParticleEffect

      public static void addParticleEffect(String name, String filePath)
      Load a particle effect and create a pool for it.
      Parameters:
      name - unique name of the effect
      filePath - path to the .p file (particle image must be in the same folder)
    • spawnParticleEffect

      public static long spawnParticleEffect(String name, float x, float y)
      Spawn a particle effect at a position.
      Parameters:
      name - the particle effect name
      x - x-coordinate in the world
      y - y-coordinate in the world
      Returns:
      unique ID of this spawned effect
    • stopParticleEffect

      public static void stopParticleEffect(long id)
      Stop a specific active particle effect.
      Parameters:
      id - the unique ID returned from spawnParticleEffect
    • updateParticleEffects

      public static void updateParticleEffects()
      Update all active particle effects. Uses delta from Gdx.graphics.getDeltaTime().
    • renderParticleEffects

      public static void renderParticleEffects()
      Render all active particle effects using GameApp.spriteBatch.
    • renderParticleEffect

      public static void renderParticleEffect(Long id)
      Draw one specific particle effect instance. In most cases you want to use the method `renderParticleEffects()`, to render all effects at the same time!
      Parameters:
      id - Id of the particle effect instance
    • isParticleEffectFinished

      public static boolean isParticleEffectFinished(Long id)
      Checks if the particle effect instance has finished
      Parameters:
      id - Id of the particle effect instance
      Returns:
      True if it has finished
    • stopAllActiveParticleEffects

      public static void stopAllActiveParticleEffects()
      Clears all active effects and returns them to their pools.
    • getParticleEffectPool

      public static com.badlogic.gdx.graphics.g2d.ParticleEffectPool getParticleEffectPool(String name)
      Only for advanced users: get the particle pool object from the app directly. With this object you can trigger all particle effects manually.
      Parameters:
      name - Name of the particle effect
      Returns:
      ParticlePool object
    • getActiveParticleEffects

      public static long[] getActiveParticleEffects()
      Get a list with all active particle id's
      Returns:
      List with active particle id's
    • hasParticleEffect

      public static boolean hasParticleEffect(String name)
      Checks whether a particle effect pool exists for the given name.
      Parameters:
      name - the particle effect name
      Returns:
      true if the pool exists, false otherwise
    • disposeParticleEffect

      public static void disposeParticleEffect(String name)
      Remove the particle effect by name. This will not stop the active particle effect!
      Parameters:
      name - the name of the particle effect to dispose
    • addTimer

      public static void addTimer(String name, float duration, int loops)
      Add a timer.
      Parameters:
      name - unique timer name
      duration - duration in seconds
      loops - -1 = infinite, 1 = single-shot, >1 = limited loops
    • addTimer

      public static void addTimer(String name, float duration, boolean looping)
      Add a timer with simple looping boolean.
      Parameters:
      name - timer name
      duration - duration in seconds
      looping - true = infinite, false = single-shot
    • hasTimer

      public static boolean hasTimer(String name)
      Returns true if a timer exists.
    • getTimer

      public static Timer getTimer(String name)
      Retrieve timer object.
    • disposeTimer

      public static void disposeTimer(String name)
      Dispose of timer.
    • resetTimer

      public static void resetTimer(String name)
      Reset timer to initial state.
    • pauseTimer

      public static void pauseTimer(String name)
      Pause timer.
    • resumeTimer

      public static void resumeTimer(String name)
      Resume timer.
    • setTimerDuration

      public static void setTimerDuration(String name, float newDuration)
      Change timer duration.
    • getTimerRemaining

      public static float getTimerRemaining(String name)
      Get remaining time until next trigger.
    • updateTimers

      public static void updateTimers()
      Update all timers using Gdx deltaTime. Call once per frame.
    • updateTimer

      public static void updateTimer(String name)
      Update single timer using Gdx deltaTime.
    • timerWentOff

      public static boolean timerWentOff(String name)
      Query if a timer went off in the last update call. This does NOT update the timer.
    • isTimerFinished

      public static boolean isTimerFinished(String name)
      Checks whether a timer has finished all its loops.

      For infinite timers (-1 loops), this always returns false.

      Parameters:
      name - the timer name
      Returns:
      true if finished, false otherwise
      Throws:
      IllegalArgumentException - if no timer exists with the given name
    • log

      public static void log(String message)
      Prints a simple message to the console.
      Parameters:
      message - the message to print
    • log

      public static void log(String name, Object value)
      Prints a variable with its name for easier debugging.
      Parameters:
      name - the name of the variable
      value - the value of the variable
    • warn

      public static void warn(String message)
      Prints a warning message in yellow.
      Parameters:
      message - the warning message
    • error

      public static void error(String message)
      Prints an error message in red.
      Parameters:
      message - the error message
    • debug

      public static void debug(Object... values)
      Prints multiple values in a single line. Useful for quick debugging of multiple variables.
      Parameters:
      values - the values to print (can include labels)
    • assertCondition

      public static void assertCondition(boolean condition, String message)
      Checks a condition and prints a message if it fails. Useful for teaching simple assertions.
      Parameters:
      condition - the condition to test
      message - the message to print if condition is false
    • addSkin

      public static void addSkin(String key, String jsonPath)
      Adds a skin to the internal skin registry by loading it from a JSON file. The JSON file must reference the associated texture atlas correctly.
      Parameters:
      key - unique key to reference the skin later
      jsonPath - path to the skin JSON file in the assets folder (e.g., "skins/ui.json")
      Throws:
      GdxRuntimeException - if the skin or atlas cannot be loaded
    • hasSkin

      public static boolean hasSkin(String key)
      Checks whether a skin exists in the registry.
      Parameters:
      key - skin key
      Returns:
      true if the skin exists
    • getSkin

      public static com.badlogic.gdx.scenes.scene2d.ui.Skin getSkin(String key)
      Retrieves a skin from the registry by its key.
      Parameters:
      key - skin key
      Returns:
      Skin object or null if not found
    • disposeSkin

      public static void disposeSkin(String key)
      Disposes of a skin in the registry.
      Parameters:
      key - skin key
    • disposeUIElements

      public static void disposeUIElements()
      Removes all UI elements from the current HUD stage.
    • addCustomUIComponent

      public static void addCustomUIComponent(String name, com.badlogic.gdx.scenes.scene2d.Actor uiComponent)
      Adds a custom LibGDX Actor to the currently active HUD.

      This method can be used to add any UI element that is not yet supported by the convenience methods, such as images, custom widgets, or third-party actors. When the actor triggers any events, you should handle them inside the actor itself or by adding listeners.

      Parameters:
      name - unique key for the UI element
      uiComponent - the Actor to add to the HUD stage
      Throws:
      IllegalStateException - if no active HUD is available or HUD is disabled
      RuntimeException - if an element with the same name already exists
    • getUIElement

      public static com.badlogic.gdx.scenes.scene2d.Actor getUIElement(String name)
      Retrieves the raw LibGDX Actor for a given UI element key.

      This works for any UI element added via GameApp's addButton, addSlider, addCheckBox, addTextField, addSelectBox, addProgressBar, or addCustomUIComponent methods.

      Parameters:
      name - the key of the UI element
      Returns:
      the Actor associated with the key
      Throws:
      IllegalArgumentException - if no UI element with the given name exists
    • hasUIElement

      public static boolean hasUIElement(String name)
      Checks whether a UI element with the given key exists in the currently active HUD.
      Parameters:
      name - the key of the UI element
      Returns:
      true if the element exists, false otherwise
    • addButton

      public static void addButton(String name, String skinName, float x, float y, float width, float height, String text)
      Adds a TextButton to the currently active HUD.

      When the button is clicked, HUD.onUIInteraction(String, Object) will be called with the button's key and a null value.

      Parameters:
      name - unique key for the button
      skinName - name of the skin to use
      x - X position in HUD coordinates
      y - Y position in HUD coordinates
      width - button width
      height - button height
      text - text displayed on the button
      Throws:
      RuntimeException - if the specified skin cannot be found
      IllegalStateException - if no active HUD is available or HUD is disabled
    • addCheckBox

      public static void addCheckBox(String name, String skinName, float x, float y, String text, boolean checked)
      Adds a CheckBox to the currently active HUD.

      The checkbox can be used for boolean user input. When its state changes, HUD.onUIInteraction(String, Object) is called with the checkbox's key and a Boolean indicating its new state.

      Parameters:
      name - unique key for the checkbox
      skinName - name of the skin to use
      x - X position in HUD coordinates
      y - Y position in HUD coordinates
      text - label text displayed next to the checkbox
      checked - whether the checkbox is initially checked
      Throws:
      RuntimeException - if the specified skin cannot be found
      IllegalStateException - if no active HUD is available or HUD is disabled
    • addSlider

      public static void addSlider(String name, String skinName, float x, float y, float width, float height, float min, float max, float step, boolean vertical)
      Adds a Slider to the currently active HUD.

      Sliders allow users to select a value in a numeric range by dragging. When the slider's value changes, HUD.onUIInteraction(String, Object) is called with the slider’s key and current float value.

      Parameters:
      name - unique key for the slider
      skinName - name of the skin to use
      x - X position in HUD coordinates
      y - Y position in HUD coordinates
      width - slider width
      height - slider height
      min - minimum slider value
      max - maximum slider value
      step - increment step size
      vertical - true for vertical, false for horizontal
      Throws:
      RuntimeException - if the specified skin cannot be found
      IllegalStateException - if no active HUD is available or HUD is disabled
    • addTextField

      public static void addTextField(String name, String skinName, float x, float y, float width, float height, String messageText)
      Adds a TextField (input box) to the currently active HUD.

      Text fields allow the player to type text input. When the value changes, HUD.onUIInteraction(String, Object) is triggered with the key and the text string.

      Parameters:
      name - unique key for the text field
      skinName - name of the skin to use
      x - X position in HUD coordinates
      y - Y position in HUD coordinates
      width - text field width
      height - text field height
      messageText - initial message that is shown
      Throws:
      RuntimeException - if the specified skin cannot be found
      IllegalStateException - if no active HUD is available or HUD is disabled
    • addSelectBox

      public static void addSelectBox(String name, String skinName, float x, float y, float width, float height, String... items)
      Adds a SelectBox (drop-down menu) to the currently active HUD.

      Select boxes let players choose from a list of predefined options. When the selected option changes, HUD.onUIInteraction(String, Object) is called with the selected value (String).

      Parameters:
      name - unique key for the select box
      skinName - name of the skin to use
      x - X position in HUD coordinates
      y - Y position in HUD coordinates
      width - select box width
      height - select box height
      items - array of selectable items
      Throws:
      RuntimeException - if the specified skin cannot be found
      IllegalStateException - if no active HUD is available or HUD is disabled
    • addLabel

      public static void addLabel(String name, String skinName, float x, float y, String text)
      Adds a static Label to the currently active HUD.

      Labels display read-only text on the screen, useful for titles or indicators. They do not trigger any HUD.onUIInteraction(String, Object) events.

      Parameters:
      name - unique key for the label
      skinName - name of the skin to use
      x - X position in HUD coordinates
      y - Y position in HUD coordinates
      text - text to display
      Throws:
      RuntimeException - if the specified skin cannot be found
      IllegalStateException - if no active HUD is available or HUD is disabled
    • addProgressBar

      public static void addProgressBar(String name, String skinName, float x, float y, float width, float height, float min, float max, boolean vertical, float value)
      Adds a ProgressBar to the currently active HUD.

      The progress bar is a visual indicator of a value between min and max.

      Parameters:
      name - unique key for the progress bar
      skinName - name of the skin to use
      x - X position in HUD coordinates
      y - Y position in HUD coordinates
      width - progress bar width
      height - progress bar height
      min - minimum value of the progress bar
      max - maximum value of the progress bar
      vertical - true if the bar should be vertical, false if horizontal
      value - initial value of the progress bar
      Throws:
      RuntimeException - if the specified skin cannot be found
      IllegalStateException - if no active HUD is available or HUD is disabled
    • getTextFieldValue

      public static String getTextFieldValue(String name)
      Returns the current text of a TextField.
      Parameters:
      name - unique element key
      Returns:
      the text currently in the field
      Throws:
      IllegalArgumentException - if no TextField exists with this key
    • setTextFieldValue

      public static void setTextFieldValue(String name, String value)
      Sets the text of a TextField.
      Parameters:
      name - unique element key
      value - text value to set
      Throws:
      IllegalArgumentException - if no TextField exists with this key
    • getCheckBoxValue

      public static boolean getCheckBoxValue(String name)
      Returns whether a CheckBox is currently checked.
      Parameters:
      name - unique element key
      Returns:
      true if checked, false if unchecked
      Throws:
      IllegalArgumentException - if no CheckBox exists with this key
    • setCheckBoxValue

      public static void setCheckBoxValue(String name, boolean checked)
      Sets the checked state of a CheckBox.
      Parameters:
      name - unique element key
      checked - true to check the box, false to uncheck it
      Throws:
      IllegalArgumentException - if no CheckBox exists with this key
    • getSliderValue

      public static float getSliderValue(String name)
      Returns the current value of a Slider.
      Parameters:
      name - unique element key
      Returns:
      the slider's current float value
      Throws:
      IllegalArgumentException - if no Slider exists with this key
    • setSliderValue

      public static void setSliderValue(String name, float value)
      Sets the value of a Slider.
      Parameters:
      name - unique element key
      value - new value for the slider
      Throws:
      IllegalArgumentException - if no Slider exists with this key
    • getSelectBoxValue

      public static String getSelectBoxValue(String name)
      Returns the currently selected item of a SelectBox.
      Parameters:
      name - unique element key
      Returns:
      the selected string item
      Throws:
      IllegalArgumentException - if no SelectBox exists with this key
    • setSelectBoxValue

      public static void setSelectBoxValue(String name, String value)
      Sets the selected item of a SelectBox.
      Parameters:
      name - unique element key
      value - the item to select, must be one of the box's available items
      Throws:
      IllegalArgumentException - if no SelectBox exists with this key
    • getLabelValue

      public static String getLabelValue(String name)
      Returns the text of a Label.
      Parameters:
      name - unique element key
      Returns:
      the text displayed by the label
      Throws:
      IllegalArgumentException - if no Label exists with this key
    • setLabelValue

      public static void setLabelValue(String name, String value)
      Sets the text of a Label.
      Parameters:
      name - unique element key
      value - new text to display
      Throws:
      IllegalArgumentException - if no Label exists with this key
    • getProgressBarValue

      public static float getProgressBarValue(String name)
      Retrieves the current value of a ProgressBar on the active HUD.
      Parameters:
      name - unique key of the progress bar
      Returns:
      current value of the progress bar
      Throws:
      IllegalArgumentException - if no progress bar with the specified name exists
    • setProgressBarValue

      public static void setProgressBarValue(String name, float value)
      Sets the value of a ProgressBar on the active HUD.
      Parameters:
      name - unique key of the progress bar
      value - new value to set; will be clamped to the progress bar's min and max
      Throws:
      IllegalArgumentException - if no progress bar with the specified name exists