LittleJS 1.28.0

Debug

LittleJS Debug System

  • Press Esc to toggle debug overlay with object picking
  • Number keys toggle debug visualizations (physics, particles, etc.) while the overlay is open
  • +/- keys control time scale for slow motion/fast forward while the overlay is open
  • setDebugKeysAlways lets those keys work with the overlay closed too
  • ASSERT and LOG macros for development (removed in release builds)
  • Debug primitive rendering (rectangles, circles, lines, points, text)
  • Screenshot support
  • FPS counter and performance watermark
  • Debug overlay shows mouse position and picked objects

Functions

Members

Constants

Functions

ASSERT(assert, …output)engineDebug.js:90

Asserts if the expression is false, does nothing in release builds Halts execution if the assert fails and throws an error

assert *

any value, the assert fails when it is falsy

…output Object

error message output

debugCircle(pos, size, color, time, fill, screenSpace)engineDebug.js:177

Draw a debug circle in world space, or on the screen with screenSpace

pos Vector2
size number optional, default 0

diameter

color Color|string optional
time number optional, default 0
fill boolean optional, default false
screenSpace boolean optional, default drawScreenSpace
debugClear()engineDebug.js:280

Clear all debug primitives in the list

debugLine(posA, posB, color, width, time, screenSpace)engineDebug.js:210

Draw a debug line in world space, or on the screen with screenSpace

posA Vector2
posB Vector2
color Color|string optional
width number optional, default 0.1
time number optional, default 0
screenSpace boolean optional, default drawScreenSpace
debugOverlap(posA, sizeA, posB, sizeB, color, time, screenSpace)engineDebug.js:232

Draw a debug combined axis aligned bounding box in world space, or on the screen with screenSpace

posA Vector2
sizeA Vector2
posB Vector2
sizeB Vector2
color Color|string optional
time number optional
screenSpace boolean optional, default drawScreenSpace
debugPoint(pos, color, time, angle, screenSpace)engineDebug.js:199

Draw a debug point in world space, or on the screen with screenSpace

pos Vector2
color Color|string optional
time number optional
angle number optional
screenSpace boolean optional, default drawScreenSpace
debugPoly(pos, points, color, time, angle, fill, screenSpace)engineDebug.js:152

Draw a debug poly in world space, or on the screen with screenSpace

pos Vector2
points Array<Vector2>
color Color|string optional
time number optional, default 0
angle number optional, default 0
fill boolean optional, default false
screenSpace boolean optional, default drawScreenSpace
debugRect(pos, size, color, time, angle, fill, screenSpace)engineDebug.js:128

Draw a debug rectangle in world space, or on the screen with screenSpace

pos Vector2
size Vector2 optional, default vec2()
color Color|string optional
time number optional, default 0
angle number optional, default 0
fill boolean optional, default false
screenSpace boolean optional, default drawScreenSpace
debugScreenshot()engineDebug.js:284

Trigger debug system to take a screenshot

debugShowErrors()engineDebug.js:290

Breaks on all asserts/errors, hides the canvas, and shows message in plain text This is a good function to call at the start of your game to catch all errors In release builds this function has no effect

debugText(text, pos, size, color, time, angle, font, screenSpace)engineDebug.js:260

Draw debug text in world space, or on the screen with screenSpace

text string|number
pos Vector2
size number optional, default 1
color Color|string optional
time number optional, default 0
angle number optional, default 0
font string optional, default monospace
screenSpace boolean optional, default drawScreenSpace
LOG(…output)engineDebug.js:117

Log to console if debug is enabled, does nothing in release builds

…output Object

message output

setDebugKey(key)engineSettings.js:947

Set key code used to toggle debug mode, Esc by default

key string
setDebugKeysAlways(enable)engineSettings.js:952

Set if the debug keys work while the overlay is closed, the number keys and the +/- time keys

enable boolean optional, default true
setDebugLineWidth(width)engineSettings.js:942

Set the width in pixels of the outlines debug shapes are drawn with

width number
setDebugOverlay(show)engineDebug.js:64

Open or close the debug overlay from code, as the debug key does; does nothing in release builds

show boolean optional, default true
setDebugTweakables(show)engineSettings.js:957

Set if the tweakables panel is shown, as 9 does while the debug overlay is open

show boolean optional, default true
setDebugWatermark(show)engineSettings.js:937

Set if watermark with FPS should be shown

show boolean

Members

debugKey : string default EscapeengineDebug.js:46

Key code used to toggle debug mode, Esc by default

debugKeysAlways : boolean default falseengineDebug.js:53

Let the debug keys work while the overlay is closed, the number keys and the +/- time keys, for a game that does not use them; off by default, so they only work while the overlay is open

debugLineWidth : number default 2engineDebug.js:34

Width in pixels of the outlines debug shapes are drawn with, the physics boxes and the tile collision view among them; larger makes them easier to see

debugOverlay : boolean default falseengineDebug.js:59

True if the debug overlay is active, always false in release builds

debugTweakables : boolean default falseengineDebug.js:71

True if the tweakables panel is shown, 9 toggles it while the overlay is open; set it to show the panel from the start, the panel is never shown in release builds

debugWatermark : boolean default trueengineDebug.js:40

True if watermark with FPS should be shown, false in release builds

Constants

debug : boolean default trueengineDebug.js:21

True if debug is enabled

debugPointSize : number default 0.5engineDebug.js:27

Size to render debug points by default