本文へ移動

Karakuriからくり

8つの標準のパズルで遊び、探索や再現できる物理を使い、ポインターやキーボードで操作する盤を表示できます。

「からくり」は、仕組みや工夫した装置を表す言葉です。 名前について(英語)

目次

リファレンス · 操作とキャンバスの表示

mountKarakuri関数

リファレンスの説明と例は英語です。見出しと目次は日本語です。

Plays one game of the package in host: a canvas that scales to the box it is given, the pointer (finger or mouse) wired to the game, a fixed-step loop that runs only while something moves, and (with ui: "full") the bar, the buttons and the card that says how a level ended. Safe to call again on the same host: the old game is taken down first. The focused canvas accepts arrows, Enter/Space, Escape and Home when keyboard is enabled.

インポート

import { mountKarakuri } from "@johnmorrisdotca/karakuri/play";

定義

function mountKarakuri(host: HTMLElement, options: MountOptions): KarakuriMount

引数

名前型説明
hostHTMLElement

The element that owns this player's canvas and controls.

optionsMountOptions

Native game/controller, presentation, clock and lifecycle choices.

戻り値

KarakuriMount

A handle for reading the controller, changing levels/language, stepping, fitting and cleanup.

例

import { mountKarakuri } from "@johnmorrisdotca/karakuri/play";
if (typeof document !== "undefined") {
  const player = mountKarakuri(document.createElement("div"), { game: "tube-sort", clock: "manual" });
  player.destroy();
}
console.log(typeof mountKarakuri);
function

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/karakuri 0.2.1 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。