LogoIgnis

Debugging

Seeing what the engine is actually doing.

Loading the scene…

Ignis ships with a handful of high-level debugging tools. But first, a demonstration.

This site binds the numbers 1 through 4 on your keyboard to debug mode toggles. The status of each debug mode is reflected in the site's header.

The demo on the right has a hidden input box. Hit 3 to find the input box, then tap it!

Debug Modes#

Ignis.debug allows you to set a DebugMode, or null to draw nothing. The mode selects which type of wireframe is drawn in all live Scene objects.

ModeRenders
spatialSpatialNode origin and extents.
collisionColliderNode shapes.
inputInputNode hit areas.
layoutLayoutNode boxes.

One mode draws at a time. spatial shows the most, covering every node that has a shape, drawn as its bounding box. The other three narrow to a single category, and draw its true shape rather than the box around it, so reach for them when spatial starts getting too noisy.

In all four modes, every SpatialNode marks its origin with a small cross, drawn in that mode's own color, so narrowing to one category still tells you where each node is placed.

You can also customize the Paint for each debug mode. For example, Ignis.debug.inputPaint specifies how InputNode will draw its debug visuals.

debugDraw#

Wireframes are drawn on top of a scene by executing an additional rendering pass. Use debugDraw to add your own debug visuals to this secondary rendering pass:

// Only called when a debug mode is enabled:
debugDraw((canvas) {
  canvas.drawRect(shape.rect(), Ignis.debug.paint);
});
By the way...

debugDraw follows the same rules and restrictions as draw.

DebugControlsNode#

DebugControlsNode sets up standard debugging controls for any scene, binding several common debugging actions to Ignis.controls. The key(s) that trigger each action are completely customizable.

KeyAction
F1Toggles the spatial debug mode.
F2Toggles the collision debug mode.
F3Toggles the input debug mode.
F4Toggles the layout debug mode.
F5Pauses and resumes the scene.
F6Turns debug mode off.

Add it to your scenes in debug builds for instant debuggability:

@override
void build() {
  super.build();
  if (kDebugMode) add(DebugControlsNode());
}
By the way...

If your game binds any of these keys, the low default priority on DebugControlsNode will let your game respond instead.

Disclaimer#

No slimes were injured in the making of this page.