Classes
ManualTicker
class ManualTicker implements ManualTickSource
From @phaser-ae/kernel
A tick source driven by hand, for headless runs, tests and replays: tick(dt) runs one frame dt seconds after the
last. Its time is synthetic and starts at 0; start runs one tick straight away, so the clock has its starting point.
start(onTick: (now: Seconds) => void): void— Begin callingonTickwith a monotonic wall time in seconds. Calling it again replaces the previous callback.stop(): void— Stop callingonTick; the game calls it fromstop().tick(dt: Seconds): void— Advance the synthetic time bydtseconds and run one frame.
RafTickSource
class RafTickSource implements TickSource
From @phaser-ae/kernel
The browser's tick source: one tick per requestAnimationFrame, with its timestamp in seconds. Restartable.
start(onTick: (now: Seconds) => void): void— Begin callingonTickwith a monotonic wall time in seconds. Calling it again replaces the previous callback.stop(): void— Stop callingonTick; the game calls it fromstop().
Types
Clock
interface Clock
From @phaser-ae/kernel
The single time authority: all game time flows from here. The tick source says "now"; the clock decides how much simulation that is — a fixed-step accumulator with pause, time scale and a catch-up clamp — and the interpolation alpha every world draws at.
readonly step: Seconds— Fixed simulation step, seconds. Set atcreateGame; constant thereafter.readonly time: Seconds— Simulation time elapsed since boot, advancing only by whole steps.readonly frame: number— Steps run so far. With the rng seed, this locates any moment for replay.readonly alpha: number— Fraction of a step left over after the last one, 0..1: how farrenderlerps from the previous state to the current one.readonly dt: Seconds— Wall-clock delta of the most recent tick, after the clamp. Informational.timeScale: number— 1 = real time; 0.2 = slow motion; 0 holds the simulation while frames still draw. A hitstop dips it.catchUpClamp: Seconds— The most wall time one tick may turn into simulation, seconds. Default 0.1 (six steps at 60 Hz): a hitch catches up, a backgrounded tab does not flood.readonly paused: boolean— True while paused, bypause()or by a hidden page underbackgroundPolicy: 'pause': no steps run,alphafreezes, theworldinput layer is suspended.pause(): void— Hold the simulation. Frames still render; theshellanduiinput layers stay live.resume(): void— Resume. The first tick after is a zero-length one, so the time paused never becomes a catch-up burst.advanceSteps(n?: number): void— While paused: runnfixed steps (default 1) on the next frame, a frame advance. Ignored when not paused.readonly held: boolean— True while held: the wall clock no longer moves the game; onlygame.advance(seconds)does.hold(): void— Take the game off the wall clock: no step, no frame and no draw happens untilgame.advance(seconds)runs them, as fast as the machine can. For tools that drive the game (a test, an agent playing it, a recorder), never for gameplay: a player's pause ispause(). Input that arrives while held is stamped with the game's time, so a press and release withadvance(0.1)between them is a 0.1 s press.release(): void— Back on the wall clock from now. The time spent held never becomes a catch-up burst.
ManualTickSource
interface ManualTickSource extends TickSource
From @phaser-ae/kernel
A tick source the caller drives by hand, one frame at a time. Deterministic.
tick(dt: Seconds): void— Advance the synthetic time bydtseconds and run one frame.
TickSource
interface TickSource
From @phaser-ae/kernel
What fires frames: it says "now", and the clock decides how much simulation that is. The kernel ships two:
RafTickSource (requestAnimationFrame, the default in a browser) and ManualTicker (driven by hand: headless
runs, tests, replays). A host may supply its own through GameOptions.tick.
start(onTick: (nowSeconds: Seconds) => void): void— Begin callingonTickwith a monotonic wall time in seconds. Calling it again replaces the previous callback.stop(): void— Stop callingonTick; the game calls it fromstop().
