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.
What it does for you
Section titled “What it does for you”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.
What it has, and what it does not
Section titled “What it has, and what it does not”| 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.
When to use it
Section titled “When to use it”- 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.
How it fits together
Section titled “How it fits together”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.
Where next
Section titled “Where next”- Installation: npm or script tag.
- Your first game: a complete game, running in the simulator.
- The rest of the guide, then the API reference for every field.