Skip to content

Overview

@fabiplay/engine is a small 2D engine for Fabi Play games, on top of the SDK. Fabi Play’s own games use it. It is imperative and framework-agnostic, written for developers who don’t know WebGL: you make sprites, shapes and texts once, change their fields every frame, and the engine draws them.

Every movement game repeats the same work. The engine does it once:

  • the canvas: its size, its resolution and devicePixelRatio, on every resize, on a fixed stage 720 units high;
  • mirror mode: a transparent stage and page over the children’s video, your background again when the video goes (see Mirror mode);
  • the hands: every child’s hands in stage units, from the right body for each backdrop, and “touched by a hand” tests (see Hands and touch);
  • the avatars: each child drawn as their avatar, where they stand (see Avatars);
  • pause and breaks: game time, tweens, particles and sound stop by themselves;
  • the renderer: WebGL2, WebGL1 or Canvas 2D, whichever the device has, with a quality tier measured on the device (see Renderers and quality tiers).

It draws everything as sprites from a texture atlas. Shapes and texts are drawn once with Canvas 2D (outline and glow included) and then moved as images, which is the cheap path on every device Fabi Play targets, TVs included.

It has It does not have
A stage, sprites, shapes, text, groups Physics (games need overlap tests, not rigid bodies)
Particles, tweens, timelines, spritesheet animation, sound A scene editor, a component/entity system
Asset loading and texture atlases, nine-slice, bitmap fonts, clips and masks 3D
Filters (colour, blur, drop shadow) and custom shaders (WebGL only), node pools
Body helpers: hands, touch tests, avatars Its own networking: everything comes from the SDK
Mirror mode built in A dependency on React, Preact or any framework
A fixed 720-unit stage, scaled to the screen Any rule that you must use it
Renderer choice, quality tiers, context-loss handling

What is not built yet is listed in Limits.

  • You have no engine, or a hand-written canvas: use it. The first game is about 50 lines.
  • You have an engine already (Phaser, PixiJS, Unity, Godot…): keep it. The SDK gives you the same movements, bodies, avatars and mirror-mode information; you do the drawing.
  • You want menus or a results screen: draw them with the engine, or put HTML over the canvas with engine.hud. Fabi Play already draws the pause menu, the exit popup and the game list, so most games need little UI of their own.

Using it is optional: games built without it are treated exactly the same.

the phone's camera ──▶ Fabi Play's screen (the host) ──postMessage──▶ your game's frame
├─ fabi-play.js / @fabiplay/sdk
└─ @fabiplay/engine (on top of the SDK)

The engine takes the SDK’s Play (from connect()) or the script tag’s FabiPlay, as they are, and listens to their events itself: frames, backdrop, pause, resume and breaks.

  1. Installation: npm or script tag.
  2. Your first game: a complete game, running in the simulator.
  3. The rest of the guide, then the API reference for every field.