Reference · Controllers and canvas player
MountOptionstype
Initial native controller, level, layout, keyboard, clock and host callbacks.
Import it
import type { MountOptions } from "@johnmorrisdotca/karakuri/play";
Definition
interface MountOptions {
game: KarakuriGame;
controller?: Controller;
keyboard?: boolean;
keyboardStep?: number;
level?: number;
lang?: KarakuriLanguage;
ui?: "full" | "board";
room?: () => number;
clock?: "real" | "manual";
onStatus?: (event: StatusEvent) => void;
onChange?: (event: StatusEvent) => void;
}
Members
| Name | Type | Description |
|---|---|---|
game | "save-the-character" | "pin-rescue" | "nuts-and-bolts" | "stretch-grabber" | "grid-escape" | "rope-cut" | "tube-sort" | "choice-story" | |
controller (optional) | Controller | undefined | A matching host-owned controller, for preserving an existing position. |
keyboard (optional) | boolean | undefined | Allow a focused canvas to use the keyboard. Default true. |
keyboardStep (optional) | number | undefined | Arrow movement in game units; Shift always moves one unit. Default 10. |
level (optional) | number | undefined | The level to start on, from 1. |
lang (optional) | KarakuriLanguage | undefined |
|
ui (optional) | "full" | "board" | undefined |
|
room (optional) | (() => number) | undefined | The most height, in pixels, the board may take now. A page that puts something above or under the board says how much room is left
(it is asked again whenever the board is fitted: on a resize, and when the box it sits in changes size). By default most of the
window: 82% of its height, less 120 pixels for the bar and buttons when |
clock (optional) | "real" | "manual" | undefined |
|
onStatus (optional) | ((event: StatusEvent) => void) | undefined | Called whenever the level's status changes (and once at the start, as |
onChange (optional) | ((event: StatusEvent) => void) | undefined | Called after each move, release or step that changed what is shown (the bar's line included). |
Examples
import type { MountOptions } from "@johnmorrisdotca/karakuri/play";
const options: MountOptions = { game: "tube-sort", clock: "manual", keyboard: true };
console.log(options.game);tube-sortWhat it prints (run when this page was built)