BGE/Debug

Alias: BGE.Debug


Enums

BGE.Debug.InputDisplayMode

enumstaticreadonly

How BGE.Debug.InputDisplay shows each player's input.

Properties

  • diagram (default: "diagram") — A remote or gamepad picture per player, with held buttons highlighted
  • text (default: "text") — One line of text per player: held buttons with held times, then stick positions

BGE.Debug.LogLevel

enumstaticreadonly

Properties

  • info (default: "info")
  • warning (default: "warning")
  • error (default: "error")

Other

DebugOptions

static

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

static

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 clears
  • apply (function) — Called after the flags above are applied, for anything else this level should do

DebugToggleOptions

static

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). Aliases
  • action (string) — ControlMap action that steps to the next level instead of the button, when it's bound
  • levels (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 says
  • enabled (boolean) — Does the button do anything (default true)? Turn it off while the button means something

DebugToggle

static

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 when action isn't bound)
  • action (string) — ControlMap action that steps the cycle, when bound
  • enabled (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

CODE
game.enableStandardDebugUi()
game.enableDebugToggle({levels: [{}, {showUi: true, colliders: true}]})

DebugWindow

static

Extends: BGE.UI.UiContainer

Parameters

Returns

  • BGE.Debug.DebugWindow

FpsDisplay

static

Extends: DebugWindow

Parameters

Properties

  • fps (integer)

Returns

  • BGE.Debug.FpsDisplay

GarbageCollectorDisplay

static

Extends: DebugWindow

Parameters

Returns

  • BGE.Debug.GarbageCollectorDisplay

InputDisplay

static

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

Properties

  • mode (BGE.Debug.InputDisplayMode) — Pictures or text - see BGE.Debug.InputDisplayMode
  • diagramScale (float) — Size multiplier for the pictures

Returns

  • BGE.Debug.InputDisplay

InputPlayerState

static

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 stick
  • pressedAt (object) — Lowercased button name -> tracker clock (seconds) when it was pressed, only while held
  • leftStick (BGE.Math.Vector)
  • rightStick (BGE.Math.Vector)

Returns

  • BGE.Debug.InputPlayerState

InputStateTracker

static

Tracks every button each player is holding, from GameInput press/release events.

LogDisplay

static

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

Returns

  • BGE.Debug.LogDisplay

MemoryDisplay

static

Extends: DebugWindow

Parameters

Returns

  • BGE.Debug.MemoryDisplay

PerfStatsOptions

static

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

static

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 (default
  • printToConsole (boolean) — Print the stats to the console (default true)
  • onStats (function) — Called with each interval's stats, e.g. to show or send them. m is this options bag.

PerfStageStats

static

Extends: roAssociativeArray

One stage's average per frame over an interval

Properties

  • ms (float) — Milliseconds per frame
  • count (float) — Times the stage ran per frame

PerfStatsSummary

static

Extends: roAssociativeArray

Frame and stage times over an interval, from BGE.Debug.PerfStats.getSummary()

Properties

  • frames (integer)
  • seconds (float) — Frame times added up
  • fps (float)
  • frameMs (float) — Mean frame time
  • percentiles (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 median
  • stageNames (Array.<string>) — Stage names in report order, and each one's PerfStageStats
  • stages (roAssociativeArray)
  • runId (string)
  • entityCount (integer) — Game.debugPrintPerfStats() only: entity and collider counts, and the last frame's phase
  • colliderCount (integer)
  • phaseMs (roAssociativeArray)

PerfStats

static

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 seen
  • runId (string)

Returns

  • BGE.Debug.PerfStats

Example

CODE
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()