FlixelDebugManager
View sourceclass
org.flixelgdx.debug.FlixelDebugManager
The single entry point for everything related to the FlixelGDX debugger.
An instance of this class is automatically created when Flixel.initialize(FlixelGame) runs and is exposed as the static field Flixel.debug, mirroring how Flixel.sound, Flixel.assets, and friends work. From your game code you can do things like:
Flixel.debug.toggleVisible();
Flixel.debug.setDrawDebug(true);
Flixel.debug.registerCommand("hello", args -> Flixel.info("Hi!"));
Flixel.debug.executeCommand("hello");
// Customize keybinds via the overlay field (null-safe: only set after debug mode starts).
if (Flixel.debug.overlay != null) {
Flixel.debug.overlay.toggleKey = FlixelKey.F1;
}
The manager is intentionally lightweight: it forwards visibility/hitbox toggles to the active FlixelDebugOverlay, owns the registry of console commands, and tracks the "currently inspected sprite" for the texture inspector window. The overlay itself (and the platform-specific UI) reads from the manager rather than the other way around so the manager can stay platform-agnostic and reflection-free.
Custom commands
Use FlixelDebugManager.registerCommand(String, Consumer<FlixelDebugCommandArgs>) with a handler that receives FlixelDebugCommandArgs. That keeps parsing explicit and avoids reflection, which is important on platforms where reflection is restricted (TeaVM, R8/ProGuard-shrunk Android builds).
Thread safety
All public methods are intended to be called from the libGDX main thread. Reading the registered commands map outside the main thread is unsupported.
Constructors
FlixelDebugManager()
Internal: registers the small set of always-available commands (help, clear, etc.).
Fields
MAX_HISTORY_ENTRIES
Maximum entries kept in the input history (oldest are dropped first).
overlay
The active debug overlay. Defaults to FlixelNoopDebugOverlay.INSTANCE so this field is never null, meaning callers do not need a null check. When debug mode starts, Flixel replaces this with a real overlay instance.
Access keybinds and visibility via this field:
Flixel.debug.overlay.toggleKey = FlixelKey.F1;
Flixel.debug.overlay.setVisible(true);
Methods
isVisible()
Returns true when the overlay is on screen.
setVisible(boolean)
Shows or hides the overlay.
Parameters:
| Name | Description |
|---|---|
visible | true to show, false to hide. |
toggleVisible()
Toggles the overlay visibility.
isDrawDebug()
Returns true when bounding-box drawing (hitboxes) is on.
setDrawDebug(boolean)
Sets whether bounding boxes (hitboxes) should be drawn.
Parameters:
| Name | Description |
|---|---|
drawDebug | true to draw, false to hide. |
toggleDrawDebug()
Toggles bounding-box drawing.
setInspectedSprite(FlixelObject)
Sets the sprite currently inspected by the texture inspector window. Pass null to clear the selection.
Parameters:
| Name | Description |
|---|---|
obj | The sprite to inspect, or null to clear. |
getInspectedSprite()
Returns the sprite currently inspected, or null if no sprite is selected (or the previously selected sprite has been destroyed). The returned sprite may be of any subclass of FlixelObject.
Returns: The inspected sprite, or null.
getDraggedSprite()
Returns the sprite that is currently being dragged via the LMB picker, or null.
trackBatch(FlixelBatch)
Registers a FlixelBatch whose FlixelBatch.getRenderCalls() will be included in the debugger's total render-call count shown in the Stats panel. The framework's own batch is already counted automatically; call this for any additional batches your game creates.
Registering a batch that is already tracked is a no-op. The batch must remain valid (not disposed) for as long as it is registered. Call FlixelDebugManager.untrackBatch(FlixelBatch) before disposing a tracked batch.
Example:
FlixelBatch uiBatch = new FlixelSpriteBatch();
Flixel.debug.trackBatch(uiBatch);
Parameters:
| Name | Description |
|---|---|
batch | The batch to track. Must not be null. |
untrackBatch(FlixelBatch)
Removes a batch that was previously registered via FlixelDebugManager.trackBatch(FlixelBatch). Passing a batch that was never registered is a no-op.
Parameters:
| Name | Description |
|---|---|
batch | The batch to stop tracking. |
getTrackedBatches()
addTrackerEntry(FlixelDebugTrackerEntry)
Registers a FlixelDebugTrackerEntry whose label -> value pairs are shown as a named, collapsible group in the overlay's Tracker panel. Registering the same entry twice is a no-op.
Example:
Flixel.debug.addTrackerEntry(new EnemyTrackerEntry(enemyManager));
Parameters:
| Name | Description |
|---|---|
entry | The entry to register. Must not be null. |
removeTrackerEntry(FlixelDebugTrackerEntry)
Removes a previously registered tracker entry. Passing an entry that was never registered is a no-op.
Parameters:
| Name | Description |
|---|---|
entry | The entry to stop tracking. |
registerCommand(String, Consumer<FlixelDebugCommandArgs>)
Registers a console command. The handler receives a FlixelDebugCommandArgs object that wraps the positional tokens the user typed after the command name.
Example:
Flixel.debug.registerCommand("hello", args -> {
String name = args.getString(0, "World"); // 0 = The first argument after the command name.
Flixel.info("Hello, " + name + "!");
});
Parameters:
| Name | Description |
|---|---|
name | The command name (the first token typed in the console). |
handler | The handler invoked when the command runs. |
unregisterCommand(String)
Removes a previously registered command.
Parameters:
| Name | Description |
|---|---|
name | The command name to remove. |
executeCommand(String)
Executes a raw command line. The first whitespace-separated token is the command name and any remaining tokens become positional arguments. Logs an error to Flixel.log if the command does not exist.
Parameters:
| Name | Description |
|---|---|
commandLine | The raw input line (for example "spawn enemy.png 1.5"). |
Returns: true if a command matched and was executed; false otherwise.
getCommandHistory()
Returns the in-memory command history (oldest first). The returned array is the live backing store and must not be modified. Use Array.size and indexed access to read it.
Returns: The command history (live, do not modify).
getRegisteredCommandNames()
Returns the Array of registered command names. The returned array is freshly allocated.
hasCommand(String)
Returns true if a command with the given name is registered.