The pack
flow
function flow(opts: FlowOptions = {}): Pack<{ flow: FlowApi }>
The flow pack: a title, a game over and a pause menu as real scenes, with the score and best score that
thread through them. Requires world:screen and the typography pack. Composing it alongside a game that
registers its own title is a loud error — rename flow's with names.
Types
FlowApi
interface FlowApi
game.flow.
score: number— The run's score. Setting it beats the best if it should.readonly best: number— The best score seen; persisted throughsavewhen that pack is composed.add(n: number): number— Add to the score and return the total.start(): void— Start a run: zero the score and go to the play scene.end(win?: boolean): void— End a run: to the game-over scene, which says YOU WIN whenwin.readonly paused: boolean— True while the pause scene is on top.pause(on?: boolean): void— Push or pop the pause scene.readonly won: boolean— Did the last run end in a win — what the game-over scene reads.
FlowNames
interface FlowNames
What the scenes are called, so a game with its own title can rename flow's rather than colliding.
title?: string— The title scene. Default 'title'.gameOver?: string— The game-over scene. Default 'gameOver'.pause?: string— The pause scene, pushed over play. Default 'pause'.play?: string— The scene a start goes to. Default 'play'.
FlowOptions
interface FlowOptions
Manifest options.
heading?: string— The big word on the title. Default 'GAME'.subtitle?: string— A line under it. Default none.prompt?: string— What to press. Default 'PRESS SPACE', or 'TAP TO START' on a touch device.scenes?: ReadonlyArray<'title' | 'gameOver' | 'pause'>— Which scenes to register. Default all three.names?: FlowNames— Scene names, for a game that already owns one of them.confirmKeys?: ReadonlyArray<string>— Key codes that start, confirm and dismiss. Default Space and Enter.pauseKey?: string— Key code that pushes and pops the pause scene. Default 'Escape'.tint?: string— Text colour. Default '#e6e9f5'.dim?: string— Dimmer colour for secondary lines. Default '#8a93b5'.layer?: LayerName— The layer to draw on. Default 'hud', or the last layer.bestKey?: string— Where the best score is kept, ifsaveis composed. Default 'best'.


