Skip to main content

class

org.flixelgdx.Flixel

public final class Flixel

The static singleton entry point and global manager for the FlixelGDX framework.

This class exposes core services, settings, and utility methods needed to develop games and interactive applications using FlixelGDX. Nearly all main gameplay logic interacts with Flixel via this class, either to control the playback loop, switch states/scenes, access global systems (input, audio, asset management, logging, debugging), or modify global properties.

Core Responsibilities

  • State Management: Switches between FlixelState instances to manage major scenes in your game.
  • Input Handling: Provides access to the keyboard manager (Flixel.keys) for polling key states and input events.
  • Sound System: Exposes a global Flixel.sound manager for playing music and sound effects.
  • Asset Loading: Offers a unified Flixel.assets interface for loading, caching, and retrieving textures, sounds, and data.
  • Host integration: Desktop notifications and task attention via Flixel.host. Separate from blocking FlixelAlerter.info(String, String) dialogs.
  • Window control: Transparency helpers and desktop window tweaks via Flixel.window.
  • Logging and Debugging: Centralizes log output through Flixel.log, and supplies tools for in-game watches and performance tracking.
  • Camera and Drawing Context: Handles the active camera selection and global antialiasing options.
  • Signals and Events: Emits signals for state switches, updates, and critical events.
  • Frame timers: FlixelTimer.getGlobalManager() is stepped from FlixelGame. Use FlixelTimer.wait(float, FlixelTimerListener) or start(...) on the manager. Flixel.timeScale scales timer elapsed only (not the whole game loop).

Typical Usage

// Switch states.
Flixel.switchState(new MyGameState());

// Play a sound.
Flixel.sound.play("explosion.mp3");

// Check if a key is pressed.
if (Flixel.keys.justPressed(FlixelKeys.SPACE)) {
// Jump!
}

// Check if a mouse button is pressed.
if (Flixel.mouse.justPressed(FlixelMouseButton.LEFT)) {
// Left mouse button was just pressed!
}

// Log diagnostic information.
Flixel.info("Player has reached checkpoint.");
Flixel.warn("Player is low on health.");
Flixel.error("Game crashed!");

// Load an asset.
Flixel.assets.load("player.png");

// Use the global signal system.
Flixel.Signals.preStateSwitch.add(data -> {
Flixel.info("Now switching to state: " + data.state().toString());
});

Design Notes

  • The Flixel class is not meant to be instantiated. It should be interacted with strictly via its static fields and methods.
  • Custom configuration and subsystems can be plugged in by replacing or augmenting the static references, e.g., custom FlixelLogger or FlixelStackTraceProvider for advanced logging.
  • All engine systems are globally accessible through this class to simplify game logic implementation.

Threading

All Flixel APIs, unless otherwise noted, are intended to be called from the main libGDX rendering thread.

Lifecycle

The Flixel singleton is initialized by the internal game bootstrap sequence. Applications should not attempt to reinitialize or replace this class directly.

Fields

MIN_ELAPSED

public static final float MIN_ELAPSED = 1.0E-6f

Minimum allowed elapsed time in seconds for one frame. FlixelGame clamps the raw libGDX delta to at least this value so a zero-delta does not break motion and timers.


MAX_ELAPSED

public static final float MAX_ELAPSED = 0.1f

Maximum allowed elapsed time in seconds for one frame. FlixelGame clamps the raw libGDX delta to at most this value so a long hitch does not move physics too far in one step.


applyAntialiasingOnStateAdd

public static boolean applyAntialiasingOnStateAdd

Automatically applies the globally set antialiasing value for any member added to the current FlixelState.

Note that when this value is set to true, any FlixelSprite's / FlixelAntialiasable's antialiasing property will be ignored.


game

public static FlixelGame game

The active FlixelGame instance driving the game lifecycle.

This reference is set during Flixel.initialize(FlixelGame) before any other system is brought up. It exposes the main render loop, the camera list, window dimensions, and low-level controls such as fullscreen toggling and framerate caps.

Most game code never needs to touch Flixel.game directly. Prefer the specialized fields (Flixel.sound, Flixel.assets, Flixel.keys, Flixel.cameras, etc.) for day-to-day work. Reach for this field only when the high-level APIs do not cover what you need.

Example:

// Change the game's background color.
Flixel.game.bgColor.set(Color.BLUE);

cameras

public static final Array<FlixelCamera> cameras

The global list of active cameras, ordered back-to-front.

The first entry, Flixel.cameras.first(), is the main camera that the framework follows and renders to by default. Add more cameras for split-screen, picture-in-picture, or separate UI layers.

This reference is final and never null: the framework creates a default camera at startup and refreshes the list (in place) on a state switch, so it is safe to read from your state's create() onward. Mutate it through the list's own methods (for example Array.add); the array itself is never replaced.

Example:

// The main camera.
FlixelCamera main = Flixel.cameras.first();
main.follow(player);

// A second camera for a UI overlay.
Flixel.cameras.add(new FlixelCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()));

alert

public static FlixelAlerter alert

The platform-specific alert dialog provider.

Alert dialogs are blocking modal windows that pause execution until the user dismisses them. Reserve them for critical events (unrecoverable errors, required permission prompts) rather than routine game feedback. For non-blocking OS notifications that do not interrupt gameplay, use Flixel.host instead.

Example:

Flixel.alert.info("Hello", "Welcome to the game!");
Flixel.alert.warn("Warning", "These permissions are required to continue.");
Flixel.alert.error("Save Failed", "Could not write to disk. Check your permissions.");

state

public static FlixelState state

The currently active state.

This is the FlixelState that is updated and drawn every frame. Switch to a different state using Flixel.switchState(FlixelState); reading this field directly is useful when you need to query the current state without holding a separate reference (for example, inside a signal listener or a global utility method).

This field is null until the first call to Flixel.switchState(FlixelState).


currentStateFactory

public static Supplier<FlixelState> currentStateFactory

Factory that produces a fresh instance of the current state for Flixel.resetState().

Updated automatically whenever Flixel.switchState(...) is called. The default Flixel.switchState(FlixelState) overload supplies () -> newState automatically, so this is pre-populated after any normal state switch at no extra cost to the caller.

Set this to null to disable Flixel.resetState() for the current state, making it a no-op.


keys

public static FlixelKeyInputManager keys

The keyboard input manager for the game.

Poll key states every frame using the methods on this manager. FlixelGDX distinguishes between keys that are held down, freshly pressed on the current frame, and freshly released on the current frame, so your game logic can respond precisely to each event type.

Key constants are defined in FlixelKey. Pass any of those constants to the methods below:

Example:

// Check if the spacebar is held.
if (Flixel.keys.pressed(FlixelKey.SPACE)) {
player.jump();
}

// Fire a bullet only on the first frame the key is pressed.
if (Flixel.keys.justPressed(FlixelKey.Z)) {
player.shoot();
}

See Also: FlixelKey


sound

public static FlixelSoundManager sound

The central audio manager.

Use this manager to play sound effects and background music. It separates one-shot sound effects from long-running music tracks and exposes independent volume controls for each category plus a master volume knob that scales both.

The audio backend is platform-specific and is injected by the launcher before Flixel.initialize(FlixelGame). On all platforms, it's typically powered by miniaudio, and for web (TeaVM) it utilizes the Web Audio API.

Example:

// Play a one-shot sound effect.
Flixel.sound.play("hit.wav");

// Start looping background music at half volume.
Flixel.sound.playMusic("theme.ogg", 0.5f, true);

// Mute all audio.
Flixel.sound.setMasterVolume(0f);

assets

public static FlixelAssetManager assets

The central asset manager for the game.

Use this manager to load, cache, and retrieve any external resource your game needs: textures, audio clips, fonts, JSON data files, and more. The manager tracks which assets have been loaded so the same file is never loaded twice and automatically unloads non-persistent assets when states switch, freeing GPU and heap memory between scenes.

Assets marked persistent (see FlixelAssetManager.load(String, boolean)) survive state switches and are ideal for shared resources such as a global UI atlas or a music track that spans multiple states.

Example:

// Load a texture and retrieve it.
Flixel.assets.load("player.png");
FlixelGraphic tex = Flixel.assets.get<FlixelGraphic>("player.png").get();

// Mark an asset persistent so it survives state switches.
Flixel.assets.setPersist("shared_ui_atlas.png", true);

watch

public static FlixelDebugWatchManager watch

The debug watch manager for the game.

A watch is a named, live value that the debug overlay displays while the game runs. Watches are an efficient way to inspect frame-by-frame state (player position, health, physics variables) without scattering temporary log statements throughout your code.

Add a watch with a name and a supplier lambda; the overlay calls the supplier every frame to refresh the displayed value. Remove watches you no longer need to keep the overlay clean. Suppliers are never called when the overlay is hidden, so there is no runtime cost in release builds.

Example:

// Show the player's position live in the debug overlay.
Flixel.watch.add("Player X", player::getX);
Flixel.watch.add("Player Y", player::getY);
Flixel.watch.add("Total Score", () -> orbs + gemsAmount);

// Remove a watch when it is no longer needed.
Flixel.watch.remove("Player X");

debug

public static FlixelDebugManager debug

The central debug manager for the game.

The debug manager is the primary interface to FlixelGDX's built-in debugging toolset. It bridges game code and the active FlixelDebugOverlay without requiring a direct reference to the overlay or even knowing whether one is installed. All methods are safe to call in any build and no-op gracefully when the game is not running in debug mode.

Key capabilities:

The overlay itself is created by a factory set before the game starts. Desktop launchers typically supply a richer overlay (for example, one built with Dear ImGui), while headless or web builds fall back to FlixelHeadlessDebugOverlay. Use Flixel.setDebugOverlay(Supplier<FlixelDebugOverlay>) to install a custom factory before Flixel.initialize(FlixelGame).

Example:

// Show the debug overlay when the game starts (debug mode only).
Flixel.debug.setVisible(true);

// Draw bounding boxes over all objects.
Flixel.debug.setDrawDebug(true);

// Register a custom console command.
Flixel.debug.registerCommand("god", args -> player.setInvincible(true));

save

public static FlixelSave save

The preferences-based save data helper for the game.

FlixelSave wraps libGDX's Preferences system to provide a simple key-value store that persists between sessions. It is backed by platform-native storage: a .prefs file on desktop, browser localStorage on web, and the equivalent on mobile.

Call FlixelSave.bind(String, String) once before using any other method to open (or create) the named preferences file. After that, read and write values directly through the FlixelSave.data map, then flush them to disk with FlixelSave.flush().

Example:

// Open the save file (typically in FlixelState.create()).
Flixel.save.bind("MySaveFile", "slot1");

// Read and write a high score.
int prevBest = (int) Flixel.save.data.get("highScore", 0);
if (score > prevBest) {
Flixel.save.data.put("highScore", score);
Flixel.save.flush();
}

mouse

public static FlixelMouseManager mouse

The mouse and pointer input manager for the game.

Poll button states and screen-space coordinates every frame. Like Flixel.keys, this manager distinguishes between buttons that are currently held, just pressed this frame, and just released this frame, so your code can react precisely to each event. Button constants are defined in FlixelMouseButton.

Example:

// Fire on the first frame the left button is pressed.
if (Flixel.mouse.justPressed(FlixelMouseButton.LEFT)) {
spawnBullet(Flixel.mouse.getWorldX(), Flixel.mouse.getWorldY());
}

// Pan the camera while the right button is held.
if (Flixel.mouse.pressed(FlixelMouseButton.RIGHT)) {
camera.pan(Flixel.mouse.getDeltaX(), Flixel.mouse.getDeltaY());
}

See Also: FlixelMouseButton


touches

public static FlixelTouchManager touches

The multitouch input manager for the game.

Tracks up to FlixelTouchManager.DEFAULT_MAX_POINTERS simultaneous fingers. Access per-pointer state through the pre-allocated list array, or use the convenience methods for quick checks:

// React on first contact.
if (Flixel.touches.list[0].isJustPressed()) {
spawnEffect(Flixel.touches.list[0].worldX, Flixel.touches.list[0].worldY);
}

// Check how many fingers are down.
if (Flixel.touches.count() >= 2) {
beginPinchZoom();
}

See Also: FlixelTouchManager, FlixelTouch


gamepads

public static FlixelGamepadInputManager gamepads

The gamepad and controller input manager.

The gamepad system is disabled by default. Set FlixelGamepadInputManager.enabled to true before the game loop starts if your game needs controller support:

Flixel.gamepads.enabled = true;

FlixelGDX's gamepad system is built on the gdx-controllers extension. It abstracts physical controllers (Xbox, PlayStation, generic USB) behind a set of logical button and axis codes defined in FlixelGamepadButton, so the same game code works across different controller layouts without any platform-specific branching.

Each connected controller is identified by a zero-based index. Player 1's controller is index 0, player 2's is index 1, and so on. Query button states with FlixelGamepadInputManager.pressed(int, int), FlixelGamepadInputManager.justPressed(int, int), and FlixelGamepadInputManager.justReleased(int, int), or read analog axes with FlixelGamepadInputManager.getAxis(int, int).

Example:

// Opt in to controller support before the game loop starts.
Flixel.gamepads.enabled = true;

// Check if player 1 pressed the A button this frame.
if (Flixel.gamepads.justPressed(0, FlixelGamepadButton.A)) {
player.jump();
}

// Read the left stick's horizontal axis for movement.
float horizontal = Flixel.gamepads.getAxis(0, FlixelGamepadButton.AXIS_LEFT_X);
player.setVelocityX(horizontal * MOVE_SPEED * elapsed);

See Also: FlixelGamepadButton


log

public static FlixelLogger log

The default logger used for game diagnostics and debugging output.

The logger formats and routes messages to the console, the in-game debug overlay, and optionally a persistent log file. It supports three severity levels: informational (FlixelLogger.info(Object)), warnings (FlixelLogger.warn(Object)), and errors (FlixelLogger.error(Object)), each visually distinguished by color in terminals that support ANSI codes.

For convenience, the three most common logging calls are promoted to static methods on Flixel itself: Flixel.info(Object), Flixel.warn(Object), and Flixel.error(String). These all delegate to this field.

Each message is automatically annotated with the calling class name and line number by the active FlixelStackTraceProvider, making it easy to trace output back to its source without a full stack dump.

To write logs to a file, call FlixelLogger.startFileLogging() after configuring FlixelLogger.setCanStoreLogs(boolean) and optionally FlixelLogger.setLogsFolder(String).

Example:

// Simple convenience wrappers on Flixel itself.
Flixel.info("Player spawned.");
Flixel.warn("Low health!");
Flixel.error("Save file corrupted.");

// Create a log with a distinguishing tag.
Flixel.info("AI", "Pathfinding recalculated.");

// Enable persistent file logging at startup.
Flixel.log.setCanStoreLogs(true);
Flixel.log.startFileLogging();

window

public static FlixelWindow window

Desktop window integration for transparency helpers, opacity control, and OS-level window tweaks.

On desktop (LWJGL3), this field is replaced by a real implementation before Flixel.initialize(FlixelGame) runs. On an unknown platform it falls back to FlixelNoopWindow, which silently ignores every call, so you can always write Flixel.window.setOpacity(0.8f) without wrapping it in a platform check.

Typical uses include transparent window backgrounds for overlay-style applications, programmatic window repositioning, and toggling window decorations (title bar, border) at runtime.

Example:

// Make the window semi-transparent.
Flixel.window.setOpacity(0.85f);

// Remove the title bar and border.
Flixel.window.setDecorated(false);

host

public static FlixelHostIntegration host

Host OS integration for toast notifications and taskbar attention signals.

On desktop (LWJGL3), this field is replaced by a platform-specific implementation before Flixel.initialize(FlixelGame) runs. On all other platforms it falls back to FlixelNoopHostIntegration, so calls are always safe to make regardless of platform.

This is distinct from the blocking alert dialogs exposed by FlixelAlerter.info(String, String): host notifications appear as non-intrusive OS toasts (system tray popups, notification center entries) and do not interrupt gameplay. Taskbar attention requests flash the game's taskbar button to draw the user's eye after the window has been minimized or sent to the background.

Example:

// Show a non-blocking OS notification when a download finishes.
Flixel.host.sendNotification("Download complete", "Your level pack is ready to play.");

// Flash the taskbar button to get the user's attention.
Flixel.host.requestAttention();

haptics

public static FlixelHaptics haptics

Haptic (vibration) feedback for mobile devices.

On platforms without a vibration motor (desktop, web) this defaults to a silent no-op, so all calls are always safe to make. Check FlixelHaptics.isSupported() first if your game logic needs to know whether feedback will actually fire.

Example:

// Short pulse when the player takes damage.
Flixel.haptics.vibrate(60);

// Repeating heartbeat pattern (restarts from index 0) while a timer is critical.
Flixel.haptics.vibrate(new long[] { 0, 80, 120, 80, 600 }, 0);

// Cancel when the timer ends.
Flixel.haptics.cancel();

See Also: FlixelHaptics


timeScale

public static float timeScale

Global timescale applied to the game's update loop each frame.

1f is normal speed; values below 1f slow the game down, values above 1f speed it up. The raw platform delta is clamped to [Flixel.MIN_ELAPSED, Flixel.MAX_ELAPSED] first, then multiplied by this value before being stored in Flixel.elapsed and passed to update(). All systems that read Flixel.getElapsed() (such as physics, animations, tweens, timers, and camera follow) are affected uniformly.

The debug overlay's Controls panel exposes a slider for this value at runtime (range 0.1x to 4.0x).


stackTraceProvider

public static FlixelStackTraceProvider stackTraceProvider

System used to detect where a log comes from when a log is created.


logFileHandler

public static FlixelLogFileHandler logFileHandler

Platform-specific handler for writing log output to a file. May be null on platforms that do not support file logging (e.g., web/TeaVM).


logConsoleSink

public static FlixelLogConsoleSink logConsoleSink

When non-null, FlixelLogger sends each console line here instead of System.out (for example, styled output in the browser). Set before Flixel.initialize(FlixelGame).


soundFactory

public static Factory soundFactory

Platform-specific factory for creating sounds, groups, and effect nodes. Set by the launcher before Flixel.initialize(FlixelGame).


Methods

initialize(FlixelGame)

public static void initialize(FlixelGame gameInstance)

Initializes the entire Flixel system.

This gets called BEFORE FlixelGame.create() is executed. It sets up every core system that Flixel needs to work, such as FlixelAssetManager, audio system, key input manager, logger, backend systems for different platforms, and more.

Parameters:

NameDescription
gameInstanceThe FlixelGame instance to use.

Throws:

TypeDescription
IllegalStateExceptionIf Flixel has already been initialized.

switchState(FlixelState)

public static void switchState(FlixelState newState)

Sets the current state to the provided state.

Parameters:

NameDescription
newStateThe new FlixelState to set as the current state.

switchState(FlixelState, boolean)

public static void switchState(FlixelState newState, boolean clearTweens)

Sets the current state to the provided state.

Parameters:

NameDescription
newStateThe new FlixelState to set as the current state.
clearTweensShould all active tweens be canceled and their pools be cleared?

switchState(FlixelState, boolean, boolean)

public static void switchState(FlixelState newState, boolean clearTweens, boolean clearTimers)

Sets the current state to the provided state.

Parameters:

NameDescription
newStateThe new FlixelState to set as the current state.
clearTweensShould all active tweens be canceled and their pools be cleared?
clearTimersShould all active timers be canceled?

switchState(FlixelState, boolean, boolean, boolean)

public static void switchState(FlixelState newState, boolean clearTweens, boolean clearTimers, boolean triggerGC)

Sets the current state to the provided state.

Parameters:

NameDescription
newStateThe new FlixelState to set as the current state.
clearTweensShould all active tweens be canceled and their pools be cleared?
clearTimersShould all active timers be canceled?
triggerGCShould Java's garbage collector be triggered for memory cleanup?

switchState(FlixelState, boolean, boolean, boolean, Supplier<FlixelState>)

public static void switchState(FlixelState newState, boolean clearTweens, boolean clearTimers, boolean triggerGC, Supplier<FlixelState> stateFactory)

Sets the current state to the provided state.

Parameters:

NameDescription
newStateThe new FlixelState to set as the current state.
clearTweensShould all active tweens be canceled and their pools be cleared?
clearTimersShould all active timers be canceled?
triggerGCShould Java's garbage collector be triggered for memory cleanup?
stateFactoryThe factory to use to create a new state instance when Flixel.resetState() is called.

debug(Object)

public static void debug(Object message)

Logs a debug message using the default tag.

Parameters:

NameDescription
messageThe message to log.

debug(String, Object)

public static void debug(String tag, Object message)

Logs a debug message under a custom tag.

Parameters:

NameDescription
tagThe tag to log the message under.
messageThe message to log.

debug(String, Object, Object...)

public static void debug(String tag, Object message, Object... args)

Logs a debug message under a custom tag, replacing each {} placeholder with the corresponding argument in order.

Parameters:

NameDescription
tagThe tag to log the message under.
messageThe format string, where each {} is replaced by the next argument.
argsThe arguments to substitute into the message.

info(Object)

public static void info(Object message)

Logs a generic informational message. This is likely the method you'll use the most, as it's for general messages that don't fit into the other log methods.

Parameters:

NameDescription
messageThe message to log.

info(String, Object)

public static void info(String tag, Object message)

Logs a generic informational message with a custom tag. This is likely the method you'll use the most, as it's for general messages that don't fit into the other log methods.

Parameters:

NameDescription
tagThe tag to log the message under.
messageThe message to log.

info(String, Object, Object...)

public static void info(String tag, Object message, Object... args)

Logs an informational message under a custom tag, replacing each {} placeholder with the corresponding argument in order.

Parameters:

NameDescription
tagThe tag to log the message under.
messageThe format string, where each {} is replaced by the next argument.
argsThe arguments to substitute into the message.

warn(Object)

public static void warn(Object message)

Logs a generic warning message. This is for messages that are not errors, but are still important to note.

Parameters:

NameDescription
messageThe message to log.

warn(String, Object)

public static void warn(String tag, Object message)

Logs a warning message with a custom tag. This is for messages that are not errors but are still important to note.

Parameters:

NameDescription
tagThe tag to log the message under.
messageThe message to log.

warn(String, Object, Object...)

public static void warn(String tag, Object message, Object... args)

Logs a warning message under a custom tag, replacing each {} placeholder with the corresponding argument in order.

Parameters:

NameDescription
tagThe tag to log the message under.
messageThe format string, where each {} is replaced by the next argument.
argsThe arguments to substitute into the message.

error(String)

public static void error(String message)

Logs an error message with red highlighting (and the file location underlined). This is for events that are typically not recoverable.

Parameters:

NameDescription
messageThe message to log.

error(Object, Throwable)

public static void error(Object message, Throwable throwable)

Logs an error message with red highlighting (and the file location underlined), including the throwable's string representation.

Parameters:

NameDescription
messageThe message to log.
throwableThe throwable to log.

error(String, Object)

public static void error(String tag, Object message)

Logs an error message with red highlighting (and the file location underlined) under a custom tag.

Parameters:

NameDescription
tagThe tag to log the message under.
messageThe message to log.

error(String, Object, Throwable)

public static void error(String tag, Object message, Throwable throwable)

Logs an error message with red highlighting (and the file location underlined) under a custom tag, including the throwable's string representation.

Parameters:

NameDescription
tagThe tag to log the message under.
messageThe message to log.
throwableThe throwable to log.

error(Object, Throwable, Object...)

public static void error(Object message, Throwable throwable, Object... args)

Logs an error message using the default tag, replacing each {} placeholder with the corresponding argument in order, including the throwable's string representation.

Parameters:

NameDescription
messageThe format string, where each {} is replaced by the next argument.
throwableThe throwable to log.
argsThe arguments to substitute into the message.

error(String, Object, Object...)

public static void error(String tag, Object message, Object... args)

Logs an error message under a custom tag, replacing each {} placeholder with the corresponding argument in order.

Parameters:

NameDescription
tagThe tag to log the message under.
messageThe format string, where each {} is replaced by the next argument.
argsThe arguments to substitute into the message.

error(String, Object, Throwable, Object...)

public static void error(String tag, Object message, Throwable throwable, Object... args)

Logs an error message under a custom tag, replacing each {} placeholder with the corresponding argument in order, including the throwable's string representation.

Parameters:

NameDescription
tagThe tag to log the message under.
messageThe format string, where each {} is replaced by the next argument.
throwableThe throwable to log.
argsThe arguments to substitute into the message.

ensureAssets()

public static FlixelAssetManager ensureAssets()

Ensures Flixel.assets is available for embedded libGDX usage.

If Flixel has not been initialized yet, this creates a default asset manager on first use. Note that audio loaders are only registered once the global audio system is initialized.


getWidth()

public static int getWidth()

Returns the visible width of the game world in game pixels.

When cameras are active, this equals the first camera's viewport world width, which accounts for the active FlixelCamera.viewportFactory. For example, on Android where the launcher installs a libGDX ExtendViewport, the value is the full screen-filling width rather than the fixed design width. Before any camera is created, the initial width from the FlixelGame constructor is returned instead.


getHeight()

public static int getHeight()

Returns the visible height of the game world in game pixels.

When cameras are active, this equals the first camera's viewport world height, which accounts for the active FlixelCamera.viewportFactory. For example, on Android where the launcher installs a libGDX ExtendViewport, the value is the full screen-filling height rather than the fixed design height. Before any camera is created, the initial height from the FlixelGame constructor is returned instead.


getSize()

public static Vector2 getSize()

Returns the game's initial size in game pixels, as set in the FlixelGame constructor.

Unlike Flixel.getWidth() and Flixel.getHeight(), this always reflects the fixed design dimensions that were set upon the game's initialization and is not affected by the active viewport type. The returned Vector2 is the live internal vector. Do not modify it.


getElapsed()

public static float getElapsed()

Returns the capped elapsed time (in seconds) for the current frame. This value is clamped between Flixel.MIN_ELAPSED and Flixel.MAX_ELAPSED by FlixelGame each frame.


getRawElapsed()

public static float getRawElapsed()

Returns the raw platform delta (in seconds) for the current frame, clamped to [Flixel.MIN_ELAPSED, Flixel.MAX_ELAPSED] but not multiplied by Flixel.timeScale. Use this when you need actual wall-clock frame time regardless of the active time scale.


setDebugMode(boolean)

public static void setDebugMode(boolean enabled)

Sets whether the game is running in debug mode. This may only be called once, typically from the platform launcher before the game starts. A second call throws an IllegalStateException.

Parameters:

NameDescription
enabledtrue to enable debug mode.

Throws:

TypeDescription
IllegalStateExceptionIf called more than once.

isDebugMode()

public static boolean isDebugMode()

setRuntimeMode(FlixelRuntimeMode)

public static void setRuntimeMode(FlixelRuntimeMode mode)

Sets the runtime mode for the game. This may only be called once, typically from the platform launcher before the game starts. A second call throws an IllegalStateException.

Parameters:

NameDescription
modeThe FlixelRuntimeMode to set.

Throws:

TypeDescription
IllegalStateExceptionIf called more than once.

getRuntimeMode()

public static FlixelRuntimeMode getRuntimeMode()

Returns the current runtime mode. Defaults to FlixelRuntimeMode.RELEASE.


resetState()

public static void resetState()

Refreshes the current state by creating a new instance from the factory last set by Flixel.switchState(...). Does nothing if the factory is null.

This is the equivalent of calling Flixel.switchState(new CurrentState()).


setDebugOverlay(Supplier<FlixelDebugOverlay>)

public static void setDebugOverlay(Supplier<FlixelDebugOverlay> factory)

Sets a factory that produces the FlixelDebugOverlay used when debug mode is enabled. This can be called either in the launcher (before the game starts) or in the FlixelGame.create() method itself.

A factory is used instead of a new instance directly for timing, so that way the debug overlay can be set even before GL context is created.

The default factory builds FlixelHeadlessDebugOverlay (no extra UI panels). Desktop launchers normally replace this with a richer overlay (for example, Dear ImGui) before Flixel.initialize(FlixelGame).

Example:

Flixel.setDebugOverlay(MyCustomOverlay::new);

Parameters:

NameDescription
factoryA supplier that creates a new FlixelDebugOverlay (or subclass).

getDrawCamera()

public static FlixelCamera getDrawCamera()

The camera currently being drawn in FlixelDrawable.draw(FlixelBatch), or null if not in a camera pass.


isOnDrawCamera(FlixelCamera[])

public static boolean isOnDrawCamera(FlixelCamera[] cameras)

Whether something with the given cameras list should render during the current draw pass. null or an empty array means all cameras; otherwise, the object is drawn only if Flixel.getDrawCamera() is reference-equal to an entry.


isAntialiasing()

public static boolean isAntialiasing()

setAntialiasing(boolean)

public static void setAntialiasing(boolean enabled)

Sets antialiasing to be applied to all FlixelSprite / FlixelAntialiasable objects.

Calling this function automatically updates the current state. Note that if you want this value to actually apply to any FlixelSprite / FlixelAntialiasable object being added to a FlixelState, set Flixel.applyAntialiasingOnStateAdd to true.

Parameters:

NameDescription
enabledIf antialiasing should be applied to all current FlixelSprite / FlixelAntialiasable objects.

getWorldBounds()

public static float[] getWorldBounds()

Returns the world bounds used for collision broad-phase culling. The returned array is [x, y, width, height].


setWorldBounds(float, float, float, float)

public static void setWorldBounds(float x, float y, float width, float height)

Sets the world bounds used for collision culling.

Parameters:

NameDescription
xLeft edge of the world.
yTop edge of the world.
widthWidth of the world in pixels.
heightHeight of the world in pixels.

overlap(FlixelBasic, FlixelBasic, BiConsumer<FlixelObject,FlixelObject>, BiFunction<FlixelObject,FlixelObject,Boolean>)

public static boolean overlap(FlixelBasic objectOrGroup1, FlixelBasic objectOrGroup2, BiConsumer<FlixelObject,FlixelObject> notifyCallback, BiFunction<FlixelObject,FlixelObject,Boolean> processCallback)

Checks for overlaps between two objects or groups. Can be called with any combination of single FlixelObjects and FlixelGroupables.

Parameters:

NameDescription
objectOrGroup1First object or group (may be null to use the current state).
objectOrGroup2Second object or group (may be null to use the current state).
notifyCallbackCalled for each overlapping pair. May be null.
processCallbackIf provided, must return true for the pair to count as overlapping. Pass null for simple AABB overlap.

Returns: true if any overlaps were detected.


overlap(FlixelBasic, FlixelBasic)

public static boolean overlap(FlixelBasic objectOrGroup1, FlixelBasic objectOrGroup2)

Shorthand for Flixel.overlap(...) with no callbacks.


collide(FlixelBasic, FlixelBasic, BiConsumer<FlixelObject,FlixelObject>)

public static boolean collide(FlixelBasic objectOrGroup1, FlixelBasic objectOrGroup2, BiConsumer<FlixelObject,FlixelObject> notifyCallback)

Checks for overlaps and separates colliding objects. Equivalent to calling Flixel.overlap(...) with FlixelObject.separate(FlixelObject, FlixelObject) as the process callback.

Parameters:

NameDescription
objectOrGroup1First object or group.
objectOrGroup2Second object or group.
notifyCallbackCalled for each pair that was separated. May be null.

Returns: true if any objects were separated.


collide(FlixelBasic, FlixelBasic)

public static boolean collide(FlixelBasic objectOrGroup1, FlixelBasic objectOrGroup2)

Shorthand for Flixel.collide(...) with no notifyCallback.


getVersion()

public static String getVersion()

Returns the version of the FlixelGDX library.

The version is read from a version.properties file in the module .jar file, where it is defined as version=<version>. If the file is not found, or the version is not defined, the method returns "Unknown", although this should never happen in theory.

Returns: The version of the FlixelGDX library.


Signals

class

org.flixelgdx.Flixel.Signals

public static final class Signals

Contains all the global events that get dispatched when something happens in the game.

This includes anything from the screen being switched, the game updating every frame, and just about everything you can think of.

NOTE: Anything with the pre and post prefixes always mean the same thing. If a signal has pre, then the signal gets ran BEFORE any functionality is executed, and post means AFTER all functionality was executed.

Fields

preUpdate

public static final FlixelSignal<UpdateSignalData> preUpdate

postUpdate

public static final FlixelSignal<UpdateSignalData> postUpdate

preDraw

public static final FlixelSignal<Void> preDraw

postDraw

public static final FlixelSignal<Void> postDraw

preStateSwitch

public static final FlixelSignal<StateSwitchSignalData> preStateSwitch

postStateSwitch

public static final FlixelSignal<StateSwitchSignalData> postStateSwitch

preGameClose

public static final FlixelSignal<Void> preGameClose

postGameClose

public static final FlixelSignal<Void> postGameClose

windowFocused

public static final FlixelSignal<Void> windowFocused

windowUnfocused

public static final FlixelSignal<Void> windowUnfocused

windowMinimized

public static final FlixelSignal<Void> windowMinimized