1681-engine / index / drawColliders
Function: drawColliders() ​
ts
function drawColliders(
world,
draw,
colors?,
colorOf?,
line?
): void;Defined in: src/physics/drawColliders.ts:52
Draws every body's bounding box, coloured by what it is: the usual body of a DebugOverlay's colliders callback, which otherwise made every game keep a list of its own bodies just to show them.
ts
new DebugOverlay(engine, { colliders: (draw) => drawColliders(physics, draw) });colorOf picks a game's own colour for a body (a one-way plank, a hazard), or returns undefined for the default. A circle is drawn as its bounding box: the overlay draws boxes, and a box round a circle still shows where it is. Given line (the overlay hands it over as its second argument), a turned box or a polygon is drawn as its own outline, and a circle that rotates gets a spoke showing its angle.
ts
new DebugOverlay(engine, { colliders: (draw, line) => drawColliders(physics, draw, {}, undefined, line) });Parameters ​
| Parameter | Type |
|---|---|
world | PhysicsWorld |
draw | ColliderBoxDrawer |
colors | Partial<ColliderColors> |
colorOf? | (body) => number | undefined |
line? | ColliderLineDrawer |
Returns ​
void