DebugRender

Extra functions for debugging, such as showing all wireframes, hitboxes, and collisions.

Events

NameDescriptionArguments
beforeSaveBefore the DebugRender's canvas context is savedNone
beforeRenderBefore all debug tools are renderedNone
afterRenderAfter all debug tools are renderedNone
afterRestoreAfter the DebugRender's canvas contex is restoredNone

Constructor

new DebugRender(Game)

Creates a debug rendering context for the game.

Parameters:
NameTypeDescription
GameGame

Game to render debug info for

Members

enabled :object

What is rendered

  • enabled.wireframes - Shows wireframes of all physics bodies
  • enabled.collisions - Shows collision points and normals
  • enabled.boundingBox - Shows AABB bounding boxes for physics bodies
  • enabled.centers - Shows center of mass of all physics bodies
  • enabled.broadphase - Shows active non-static broadphase grids cells
Type:
  • object
To Do
  • Add methods for setting these, possibly also in Game
Example
// All options:
game.DebugRender.enabled = {
	wireframes: true,
	centers: true,
	collisions: true,
	broadphase: true,
	boundingBox: true,
}

Methods

on(event, callback)

Bind a callback to an event

Parameters:
NameTypeDescription
eventstring

Name of the event

callbackfunction

Callback run when event is fired

off(event, callback)

Unbinds a callback from an event

Parameters:
NameTypeDescription
eventstring

Name of the event

callbackfunction

Function to unbind

trigger(event, …args)

Triggers an event, firing all bound callbacks

Parameters:
NameTypeAttributesDescription
eventstring

Name of the event

args*<repeatable>

Arguments passed to callbacks