Skip to content

GameMessage

GameMessage = { type: "ready"; } | { type: "break"; reason: BreakReason | "unknown"; } | { type: "score"; player: number; score: number; } | { type: "end"; scores: object[]; } | object & GameStats | { type: "picture"; data: string; title?: string; id?: number; }

What the game may send to the screen; anything else is dropped.

{ type: "ready"; }

Assets loaded: the screen hides its loader.


{ type: "break"; reason: BreakReason | "unknown"; }

The game has stopped by itself (see BreakReason): Fabi Play may show an ad there, if its rules allow. Never asked in the middle of play; the answer is always a break-done. ‘unknown’: a reason we don’t take (e.g. ‘pause’), answered at once with no break.


{ type: "score"; player: number; score: number; }

A player’s score so far, shown by the screen.


{ type: "end"; scores: object[]; }

The game is over: each player’s score and stars (0–3).


object & GameStats

Debug, only when init said stats: how many times a second the game drew its avatars (the SDK counts the animation frames drawAvatar or smoothedBody ran in), about once a second; from a game on the engine, also its frame rate, renderer and tier (GameStats). Hosts may ignore it.


{ type: "picture"; data: string; title?: string; id?: number; }

Save a picture on the family’s phone (a drawing, the photo of a wall). data: a base64 data URL, data:image/jpeg or data:image/png, at most MAX_PICTURE_BYTES, whose bytes really are that type (checkPicture); title: a name for it (MAX_PICTURE_TITLE characters); id: the game’s own, echoed in picture-result. Anything else is dropped: a game can send only an image this way. The screen sends it to the phone over their direct link only, never to a server, and answers picture-result.