FlixelDebugWatchManager
View sourceclass
org.flixelgdx.debug.FlixelDebugWatchManager
Manages the variable watch list for the debug overlay. Watch entries are getter-based (no reflection). Each entry is a display name mapped to a Supplier whose value is polled every frame.
Access via Flixel.watch. The API mirrors HaxeFlixel's FlxG.watch front-end as closely as possible while staying idiomatic in Java.
- FlixelDebugWatchManager.add(String, Supplier<?>): watch a supplier (equivalent to HaxeFlixel's
addFunction) - FlixelDebugWatchManager.remove(String): remove a watched entry by name
- FlixelDebugWatchManager.addMouse() / FlixelDebugWatchManager.removeMouse(): convenience for mouse coordinates
Constructors
FlixelDebugWatchManager()
Methods
add(String, Supplier<?>)
Registers a watch entry. If an entry with the same name already exists it is replaced. Equivalent to HaxeFlixel's FlxG.watch.addFunction.
Parameters:
| Name | Description |
|---|---|
displayName | The label shown in the watch panel. |
valueGetter | A supplier that returns the current value each frame. |
add(String, ByteSupplier)
Registers a byte-valued watch entry without boxing.
Parameters:
| Name | Description |
|---|---|
displayName | The label shown in the watch panel. |
valueGetter | A supplier that returns a primitive byte each frame. |
add(String, ShortSupplier)
Registers a short-valued watch entry without boxing.
Parameters:
| Name | Description |
|---|---|
displayName | The label shown in the watch panel. |
valueGetter | A supplier that returns a primitive short each frame. |
add(String, IntSupplier)
Registers an int-valued watch entry without boxing.
Parameters:
| Name | Description |
|---|---|
displayName | The label shown in the watch panel. |
valueGetter | A supplier that returns a primitive int each frame. |
add(String, LongSupplier)
Registers a long-valued watch entry without boxing.
Parameters:
| Name | Description |
|---|---|
displayName | The label shown in the watch panel. |
valueGetter | A supplier that returns a primitive long each frame. |
add(String, FloatSupplier)
Registers a float-valued watch entry without boxing.
Parameters:
| Name | Description |
|---|---|
displayName | The label shown in the watch panel. |
valueGetter | A supplier that returns a primitive float each frame. |
add(String, DoubleSupplier)
Registers a double-valued watch entry without boxing.
Parameters:
| Name | Description |
|---|---|
displayName | The label shown in the watch panel. |
valueGetter | A supplier that returns a primitive double each frame. |
add(String, BooleanSupplier)
Registers a boolean-valued watch entry without boxing.
Parameters:
| Name | Description |
|---|---|
displayName | The label shown in the watch panel. |
valueGetter | A supplier that returns a primitive boolean each frame. |
add(String, CharSupplier)
Registers a char-valued watch entry without boxing.
Parameters:
| Name | Description |
|---|---|
displayName | The label shown in the watch panel. |
valueGetter | A supplier that returns a primitive char each frame. |
remove(String)
Removes a previously registered watch entry by name.
Parameters:
| Name | Description |
|---|---|
displayName | The label of the entry to remove. |
addMouse()
Adds a convenience watch entry that shows the current mouse screen position.
removeMouse()
Removes the convenience mouse position watch entry.
forEach(BiConsumer<String,String>)
Iterates every watch entry, invoking the callback with each display name and its current resolved value string. The value string is materialized for the callback; prefer FlixelDebugWatchManager.fillWatchLines(Array<FlixelString>) when drawing to avoid per-entry String churn in tight loops.
Parameters:
| Name | Description |
|---|---|
callback | Receives (displayName, currentValueString) for every entry. |
fillWatchLines(Array<FlixelString>)
Formats all watch lines into output, reusing existing FlixelString slots and shrinking the array when fewer watches are registered. Each line includes markup for the debug overlay.
Prefer FlixelDebugWatchManager.fillWatchEntries(Array<FlixelString>, Array<FlixelString>) when the renderer (for example a Dear ImGui based overlay) is responsible for coloring keys and values separately, since that path avoids appending markup tokens that the renderer has to ignore anyway.
Parameters:
| Name | Description |
|---|---|
output | Cleared and filled with one FlixelString per watch entry (order follows Map.entrySet()). |
fillWatchEntries(Array<FlixelString>, Array<FlixelString>)
Fills two parallel arrays with each watch entry's name and its current value, reusing existing FlixelString slots so that no allocations happen on the steady-state path.
This is the preferred path when the debug renderer can color keys and values on its own (for example Dear ImGui's TextColored), since neither array contains color markup. Both arrays are guaranteed to have the same size on return.
Parameters:
| Name | Description |
|---|---|
keys | Cleared and filled with one entry per watch's display name. |
values | Cleared and filled with one entry per watch's current value (no formatting prefix). |
isEmpty()
Returns true when there are no watch entries registered.
clear()
Clears all watch entries.
WatchEntry
interface
org.flixelgdx.debug.FlixelDebugWatchManager.WatchEntry
Internal hook for formatting a watch value into a FlixelString without returning an intermediate String.
Methods
appendValue(FlixelString)
Appends the current watch value to out. Implementations must not clear out; callers own the prefix and lifecycle.
Parameters:
| Name | Description |
|---|---|
out | Destination buffer. |