GameLoop
Defined in: GameLoop.ts:29
Game loop with fixed timestep accumulator.
Driven by an external ticker (e.g., PixiJS Ticker) or manual tick() calls
for testing. Implements deterministic fixed updates with variable rendering.
The incoming per-frame delta is wall-clock milliseconds (PixiJS tickers
report deltaMS). tick() converts it to seconds once, so every callback
downstream receives seconds.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new GameLoop(
config?):GameLoop
Defined in: GameLoop.ts:44
Parameters
Section titled “Parameters”config?
Section titled “config?”Returns
Section titled “Returns”GameLoop
Properties
Section titled “Properties”fixedTimestep
Section titled “fixedTimestep”
readonlyfixedTimestep:number
Defined in: GameLoop.ts:31
Fixed timestep in seconds.
maxFixedStepsPerFrame
Section titled “maxFixedStepsPerFrame”
readonlymaxFixedStepsPerFrame:number
Defined in: GameLoop.ts:33
Max fixed steps per frame.
Accessors
Section titled “Accessors”frameCount
Section titled “frameCount”Get Signature
Section titled “Get Signature”get frameCount():
number
Defined in: GameLoop.ts:50
Current frame count.
Returns
Section titled “Returns”number
interpolationAlpha
Section titled “interpolationAlpha”Get Signature
Section titled “Get Signature”get interpolationAlpha():
number
Defined in: GameLoop.ts:60
Ratio of accumulated time to fixed timestep, for physics interpolation.
Returns
Section titled “Returns”number
isRunning
Section titled “isRunning”Get Signature
Section titled “Get Signature”get isRunning():
boolean
Defined in: GameLoop.ts:55
Whether the loop is running.
Returns
Section titled “Returns”boolean
lastTickAt
Section titled “lastTickAt”Get Signature
Section titled “Get Signature”get lastTickAt():
number
Defined in: GameLoop.ts:70
Wall-clock timestamp (ms, performance.now() scale) of the
most recent tick() call, or 0 if tick() has never run. Lets a caller
tell “frozen on purpose” apart from “stalled” without depending on the
frame counter, which doesn’t move either way.
Returns
Section titled “Returns”number
Methods
Section titled “Methods”attachTicker()
Section titled “attachTicker()”attachTicker(
subscribe):void
Defined in: GameLoop.ts:84
Attach an external ticker (e.g., PixiJS Ticker).
The ticker calls tick(dtMs) every frame with the wall-clock delta in
milliseconds. If no ticker is attached, the loop uses requestAnimationFrame.
Parameters
Section titled “Parameters”subscribe
Section titled “subscribe”(callback) => () => void
Returns
Section titled “Returns”void
setCallbacks()
Section titled “setCallbacks()”setCallbacks(
callbacks):void
Defined in: GameLoop.ts:75
Provide the callbacks that the loop invokes each frame.
Parameters
Section titled “Parameters”callbacks
Section titled “callbacks”Returns
Section titled “Returns”void
start()
Section titled “start()”start():
void
Defined in: GameLoop.ts:91
Start the loop.
Returns
Section titled “Returns”void
stop()
Section titled “stop()”stop():
void
Defined in: GameLoop.ts:112
Stop the loop.
Returns
Section titled “Returns”void
tick()
Section titled “tick()”tick(
dtMs):void
Defined in: GameLoop.ts:135
Process one frame. dtMs is the wall-clock delta in milliseconds (the
unit PixiJS tickers report). It is converted to seconds here, so every
callback receives seconds.
A throw that escapes the whole frame — nothing downstream caught it —
stops the loop and rethrows, so it reaches the host (a caller’s own
try/catch, window.onerror, or an unhandled-rejection handler). An
error handled inside the frame (a caller’s try/catch around, say,
entity.emit(...)) never reaches here, so the loop keeps running.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void