mwg API
    Preparing search index...

    Class Player

    Re-dispatches recorded events at their recorded frames.

    const player = new Player(deserializeReplay(saved), (a) => Input.onAction.dispatch(a), game.onFrame);
    // ...drive the loop by hand: game.step(1 / 60) per frame...

    Events are dispatched on the frame signal whose count has reached their stamp, before the player's own count advances - the same relative point a live action held during recording. dispatch usually forwards into Input.onAction, but tests pass a collector instead.

    import { Player, Signal, deserializeReplay } from '@datamoc/mw_games/core';

    declare const saved: string; // written by serializeReplay, see Recorder

    const onFrame = new Signal<number>();
    const replayed: string[] = [];

    const player = new Player(deserializeReplay(saved), (action) => replayed.push(action), onFrame);
    onFrame.dispatch(0);

    console.log(player.done);
    player.stop();
    Index
    • get done(): boolean

      True once every event has been dispatched.

      Returns boolean