Skip to content

createManualTicker

Creates a stopped PixiJS ticker with step-based frame advancement methods.

type ManualTicker = {
ticker: Ticker;
fastForwardFrames(frames: number, deltaTime?: number): Promise<void>;
fastForwardTime(totalTimeMS: number, stepSizeMS?: number): Promise<void>;
};

The driver methods are async — always await them. They own a monotonic absolute clock, so successive calls are exactly additive (no dropped first frame), and they flush microtasks after every tick so promise-based continuations (awaited delay, animation onEnded chains) receive subsequent ticks.

Advance a specific number of frames, each with an optional delta time (defaults to 16ms).

const manual = createManualTicker();
let calls = 0;
manual.ticker.add(() => {
calls++;
});
await manual.fastForwardFrames(10); // 10 frames at 16ms each
await manual.fastForwardFrames(5, 33); // 5 frames at 33ms each (~30fps)
expect(calls).toBe(15);

Advance frames to simulate a total elapsed time, splitting it into steps of a given size (defaults to ~16ms).

await manual.fastForwardTime(1000); // 1 second in ~16ms steps
await manual.fastForwardTime(500, 50); // 500ms in 50ms steps