Arcade games, touch controls and phones
Phase 5b added these (ADR 0025). Start from the template with pnpm create-game my-shooter --template arcade, or
use Start from the arcade template in the platform editor.
Arcade kit
Section titled “Arcade kit”Waves. A scene’s waves spawn groups of a prefab over time, entering from just above the view:
at: seconds after the scene starts.countandevery: how many, and the seconds between them.x: a fraction of the view’s width, so it works at any screen width.formation:column,line,vorrandom.components: overrides for the spawned prefab.
wave:<n> is emitted when a wave starts, and waves:done once every wave has spawned and none of their entities is
left.
Components:
Mover: moves by itself; no Body needed.line: at (vx,vy).sineandzigzag: sway sideways byamplitudeeveryperiodseconds.dive: drifts fordelayseconds, then speeds toward where the player was.
Shooter: firesbulletprefabsratetimes a second.- When: automatically, or while
actionis held. - Aim:
up,down, or at theplayer. - Spread:
countbullets overspreaddegrees.
- When: automatically, or while
Projectile: a bullet; it hurts the first entity withHealthandtargetTagthat it touches, then disappears.Score: addspointsto a session counter (score) when its entity’sHealthreaches 0, with an explosion.Offscreen: removes entities that leave the view.KeepInView: keeps the player on screen.TopDownController: steers a ship in eight directions (the top-down controller).
Best scores. recordBest keeps the player’s best value ({ "value": "session.score", "key": "score" }, or
lower: true for times). It is saved with the player’s saves: platform cloud saves when signed in, the browser
otherwise. Bind it as best.score.
Backgrounds. A parallax layer with drift scrolls by itself, for starfields and clouds.
Touch controls
Section titled “Touch controls”On phones and tablets (or with ?touch in the URL), games get on-screen controls. Without a touch section in
game.json, they are made from the input actions:
moveXandmoveYgive a floating joystick;moveXalone gives ◀ ▶ buttons;jump,fire,interact,action,attack,dashandbombgive buttons;pausegives a small corner button.
The controls hide while a menu is up, so taps reach the menu. In dialogue, choices can be tapped.
To choose the layout yourself:
"touch": { "move": { "type": "joystick", "x": "moveX", "y": "moveY", "side": "left", "floating": true, "size": 110 }, "buttons": [{ "action": "fire", "label": "B", "side": "right" }], "pause": "pause"}"enabled": false turns them off (for games played by tapping menus only).
Phones and screen shapes
Section titled “Phones and screen shapes”With "display": { "width": 180, "height": 320, "scaleMode": "expand", "minWidth": 180, "maxWidth": 420 }, the view
keeps its height and widens or narrows to the screen’s shape. The camera shows more or less world, and the HUD and
menus anchor to the real edges, following rotations and resizes.
Without a follow target, the camera centres on the design area (width × height), so extra width appears on both
sides. "orientation": "portrait" (or landscape) shows a “rotate your device” hint on phones held the other way.