BGE/Debug
Alias: BGE.Debug
Enums
BGE.Debug.InputDisplayMode
How BGE.Debug.InputDisplay shows each player's input.
Properties
diagram(default: "diagram") — A remote or gamepad picture per player, with held buttons highlightedtext(default: "text") — One line of text per player: held buttons with held times, then stick positions
BGE.Debug.LogLevel
Properties
info(default: "info")warning(default: "warning")error(default: "error")
Other
DebugOptions
Properties
draw_colliders(boolean)draw_collider_names(boolean)draw_safe_zones(boolean)colliders_color(integer)safe_action_zone_color(dynamic)safe_title_zone_color(dynamic)limit_frame_rate(integer)show_debug_ui(boolean)draw_debugUi_to_screen(boolean)draw_entity_axes(boolean)draw_entity_names(boolean)draw_scene_object_normals(boolean)print_perf_stats(boolean)perf_stats_interval_seconds(float)
Returns
BGE.Debug.DebugOptions
DebugLevel
Extends: roAssociativeArray
One step of a BGE.Debug.DebugToggle cycle. Every field is optional.
The flags (showUi, colliders, entityDetails, safeZones, occlusion) a toggle manages are the ones any of its levels sets: a level turns those on or off (missing = off), and flags no level mentions are left alone, so a game can still set them itself.
Properties
showUi(boolean) — Show the debug UI panels (Game.debugShowUi())colliders(boolean) — Draw colliders (Game.debugDrawColliders())entityDetails(boolean) — Draw entity axes and names (Game.debugDrawEntityDetails())safeZones(boolean) — Draw the title/action safe zones (Game.debugDrawSafeZones())occlusion(boolean) — Draw the occlusion culling overlay (Game.debugDrawOcclusion())panels(roAssociativeArray) — Replaces the debug UI's panels with Game.enableStandardDebugUi(panels) - this clearsapply(function) — Called after the flags above are applied, for anything else this level should do
DebugToggleOptions
Extends: roAssociativeArray
Options for Game.enableDebugToggle(). Every field is optional.
Properties
button(string) — Remote button that steps to the next level (default "options", the * button). Aliasesaction(string) — ControlMap action that steps to the next level instead of the button, when it's boundlevels(Array.<BGE.Debug.DebugLevel>) — The cycle, in order (default: off, panels, + entity details, + colliders)startLevel(integer) — Index of the level the game starts at (default 0). It isn't applied - it only saysenabled(boolean) — Does the button do anything (default true)? Turn it off while the button means something
DebugToggle
Steps through a cycle of debug overlays each time a button (or ControlMap action) is pressed, wrapping back to the first. Made by Game.enableDebugToggle(); nothing is bound until a game calls that.
It acts on presses before entities get them and doesn't consume them, so pick a button gameplay doesn't use, or turn enabled off while it does. It still works while the game is paused, but not in a frame a UI widget captured input (GameInput.consume()).
Each change posts a "debugLevelChanged" game event ({level, previousLevel}). Subclass to change how a level is applied (applyLevel()) or what happens after (onLevelChanged()), and assign the instance to game.debugToggle.
Parameters
game(BGE.Game)options(BGE.Debug.DebugToggleOptions, optional, default: "{}")
Properties
button(string) — Remote button that steps the cycle (used whenactionisn't bound)action(string) — ControlMap action that steps the cycle, when boundenabled(boolean) — Does the button do anything?game(BGE.Game)levels(Array.<BGE.Debug.DebugLevel>)level(integer)managedFlags(roAssociativeArray) — Flags any level sets - the only ones applyLevel() touches
Returns
BGE.Debug.DebugToggle
Example
game.enableStandardDebugUi()
game.enableDebugToggle({levels: [{}, {showUi: true, colliders: true}]})DebugWindow
Extends: BGE.UI.UiContainer
Parameters
game(BGE.Game)
Returns
BGE.Debug.DebugWindow
FpsDisplay
Extends: DebugWindow
Parameters
game(BGE.Game)
Properties
fps(integer)
Returns
BGE.Debug.FpsDisplay
GarbageCollectorDisplay
Extends: DebugWindow
Parameters
game(BGE.Game)
Returns
BGE.Debug.GarbageCollectorDisplay
InputDisplay
Extends: DebugWindow
Debug window showing every player's input: by default one picture per player - a Roku remote or a gamepad - with every held button highlighted and stick positions shown, or one line of text per player (see mode).
Parameters
game(BGE.Game)
Properties
mode(BGE.Debug.InputDisplayMode) — Pictures or text - see BGE.Debug.InputDisplayModediagramScale(float) — Size multiplier for the pictures
Returns
BGE.Debug.InputDisplay
InputPlayerState
What one player's remote/gamepad/controller is doing right now, as tracked by BGE.Debug.InputStateTracker for the input debug window.
Parameters
playerIndex(integer)
Properties
playerIndex(integer)isGamepad(boolean) — True once this player sends a gamepad-only button or moves a stickpressedAt(object) — Lowercased button name -> tracker clock (seconds) when it was pressed, only while heldleftStick(BGE.Math.Vector)rightStick(BGE.Math.Vector)
Returns
BGE.Debug.InputPlayerState
InputStateTracker
Tracks every button each player is holding, from GameInput press/release events.
LogDisplay
Extends: DebugWindow
A debug window that shows the most recent messages logged via Game.log(), color coded by level (white for info, yellow for warning, red for error). Auto-scrolls to always show the latest entries.
Parameters
game(BGE.Game)
Returns
BGE.Debug.LogDisplay
MemoryDisplay
Extends: DebugWindow
Parameters
game(BGE.Game)
Returns
BGE.Debug.MemoryDisplay
PerfStatsOptions
Extends: roAssociativeArray
Options for BGE.Debug.PerfStats. Every field is optional.
Properties
stageNames(Array.<string>) — Only these stages, in this order (default: every stage the frames report)percentiles(Array.<float>) — Frame time percentiles to report, 0 to 1 (default [0.5, 0.9]); 0.5 prints as "med"spikeFactor(float) — A frame over spikeFactor times the median frame time counts as a spike (default 1.5)runId(string) — Added to the summary and the printed line, to tell runs apart in a log (default "")
GamePerfStatsOptions
Extends: BGE.Debug.PerfStatsOptions
Options for Game.debugPrintPerfStats(): PerfStatsOptions plus these. Every field is optional.
Properties
stages(boolean) — Turn on the game canvas renderer's profileStages and include its stage times (defaultprintToConsole(boolean) — Print the stats to the console (default true)onStats(function) — Called with each interval's stats, e.g. to show or send them.mis this options bag.
PerfStageStats
Extends: roAssociativeArray
One stage's average per frame over an interval
Properties
ms(float) — Milliseconds per framecount(float) — Times the stage ran per frame
PerfStatsSummary
Extends: roAssociativeArray
Frame and stage times over an interval, from BGE.Debug.PerfStats.getSummary()
Properties
frames(integer)seconds(float) — Frame times added upfps(float)frameMs(float) — Mean frame timepercentiles(Array.<float>) — The options' percentiles, and the frame time at each (same order)percentileMs(Array.<float>)medianMs(float)maxMs(float)spikes(integer) — Frames over spikeFactor times the medianstageNames(Array.<string>) — Stage names in report order, and each one's PerfStageStatsstages(roAssociativeArray)runId(string)entityCount(integer) — Game.debugPrintPerfStats() only: entity and collider counts, and the last frame's phasecolliderCount(integer)phaseMs(roAssociativeArray)
PerfStats
Collects frame times and named stage times (e.g. Renderer.getStageMsLastFrame()) over an interval, and summarizes them: fps, mean frame time, percentiles, the longest frame, spikes and each stage's average. Game.debugPrintPerfStats() uses one; a game can keep its own for its own report.
Parameters
options(BGE.Debug.PerfStatsOptions, optional, default: "{}") — stageNames, percentiles, spikeFactor, runId
Properties
percentiles(Array.<float>)spikeFactor(float)stageNames(Array.<string>) — Stages to report, in order; empty reports every stage in the order first seenrunId(string)
Returns
BGE.Debug.PerfStats
Example
stats = new BGE.Debug.PerfStats({runId: "a"})
' each frame
stats.addFrame(dt * 1000, renderer.getStageMsLastFrame(), renderer.getStageCountsLastFrame())
' every few seconds
print "PERF " + stats.format(stats.getSummary())
stats.reset()