Skip to content

KernelAPI reference

Class DebugDraw

Namespace: MicroEngine.Core
Assembly: MicroEngine.dll
Guide: Game lifecycle and time

Shapes and text any code can ask for while the game runs, drawn above the scenes at the end of the frame (DebugDraw): a ray an enemy casts, the box a move swept, a path, a value next to an entity. Calls do nothing while Enabled is off, so they can stay in shipped code.

C#
public sealed class DebugDraw

Inheritance

object ← DebugDraw

Examples

C#
// In Load:
DebugDraw.Enabled = true;
// Anywhere in an update:
game.DebugDraw.Line(enemy.Position, player.Position, Color.Red);
game.DebugDraw.Physics(world);

Remarks

An item drawn with seconds: 0 shows for one frame; ask for it every update to keep it. A longer one stays that many seconds of real time. World items follow the camera of the scene on top (WorldCamera); screen items are in the canvas’s pixels. Lines are one world unit (or one canvas pixel) thick.

Properties

Count

Items waiting to be drawn (the current frame’s and the longer-lived ones).

C#
public int Count { get; }

Property Value

int

Enabled

Whether calls are recorded and drawn. Off by default; turning it off drops what is pending.

C#
public bool Enabled { get; set; }

Property Value

bool

Methods

Circle(Vector2, float, Color, float, DebugSpace)

The outline of a circle.

C#
public void Circle(Vector2 center, float radius, Color color, float seconds = 0, DebugSpace space = DebugSpace.World)

Parameters

center Vector2

radius float

color Color

seconds float

space DebugSpace

Line(Vector2, Vector2, Color, float, DebugSpace)

A line from from to to.

C#
public void Line(Vector2 from, Vector2 to, Color color, float seconds = 0, DebugSpace space = DebugSpace.World)

Parameters

from Vector2

to Vector2

color Color

seconds float

space DebugSpace

Physics(IPhysicsWorld2D, RectF?)

Draws world as it is now: every shape of every body (coloured by body kind; sensors and one-way shapes in their own colour, PhysicsColors), the solid and one-way tiles of tile grids inside tileArea (by default what the current scene’s camera shows, or the canvas), and a normal for each contact that began during the latest step. Does nothing while Enabled is off.

C#
public void Physics(IPhysicsWorld2D world, RectF? tileArea = null)

Parameters

world IPhysicsWorld2D

tileArea RectF?

Exceptions

PhysicsCapabilityException

The backend does not declare ShapeInspection.

Point(Vector2, Color, float, float, DebugSpace)

A small cross at position (size wide).

C#
public void Point(Vector2 position, Color color, float size = 4, float seconds = 0, DebugSpace space = DebugSpace.World)

Parameters

position Vector2

color Color

size float

seconds float

space DebugSpace

Rect(RectF, Color, float, DebugSpace)

The outline of rect.

C#
public void Rect(RectF rect, Color color, float seconds = 0, DebugSpace space = DebugSpace.World)

Parameters

rect RectF

color Color

seconds float

space DebugSpace

Text(Vector2, string, Color, float, DebugSpace)

text in the game’s font (Font), its top-left corner at position.

C#
public void Text(Vector2 position, string text, Color color, float seconds = 0, DebugSpace space = DebugSpace.World)

Parameters

position Vector2

text string

color Color

seconds float

space DebugSpace