Touch controls for mobile action and platformer games
touchmobilecontrolshapticsd-paduxflutter
Design rules for on-screen controls in a landscape platformer, from published postmortems (Dead Cells mobile port by Playdigious, Celeste mobile) and what Run learned shipping a mobile-web version in 2026-08.
Layout
- Two-handed landscape. Left thumb: movement only. Right thumb: at most 3 action buttons; Run's 4 (ability, run, dash, jump) was at the limit. Remove one with auto-sprint, or fold a rare action into a long-press.
- Never put two actions on one button distinguished by gestures (Dead Cells tried jump + dodge with a swipe: "nightmare to play").
- Bottom 30-40% of the screen belongs to controls; move HUD up.
- Customization is expected (65% of players want it): opacity slider, size slider/presets, drag-to-reposition edit mode saved to prefs, left-handed mirror preset.
D-pad vs joystick
For binary left/right movement a d-pad beats a virtual joystick (no drift, no lost center). Dead Cells players preferred a floating pad 80/20 for a full-direction action game, which is a different problem. Include a small center dead zone.
Slide-capable d-pad (Run v0.8.83): make left/right ONE pointer surface with a per-pointer direction map, so the thumb slides between directions without lifting; 6 px hysteresis at the center (no flicker), a 14 px invisible hit margin (+20 px above), and a haptic tick on direction change. Two independent buttons felt broken.
Sizes and opacity
| Guideline | Minimum |
|---|---|
| Apple HIG | 44x44 pt |
| Material | 48x48 dp |
| Game action buttons | 56-72 dp (64-80 for primary) |
| Run: 64 dp d-pad, 52/72 dp actions with a 0.7-1.3 user scale (raise the floor to 0.8 so | |
| nothing goes under ~42 dp). Extend hit areas ~8 dp beyond the art. Idle opacity 0.2-0.3 with a | |
| clear pressed state (0.15 idle was too faint). |
Haptics
| Event | Strength |
|---|---|
| Coin/pickup | soft tick ~5 ms |
| Jump, landing from height | light ~10 ms |
| Dash, wall kick | medium ~15 ms |
| Death | heavy ~30 ms with shake |
| Level complete | two-pulse success |
| Menu buttons | selectionClick() |
| iOS Core Haptics is consistent; Android varies wildly by device (custom compositions only on | |
| API 30+ with good hardware). Always offer an off switch; test on real devices. A ~20 ms click | |
| sound together with the haptic makes controls feel precise. |
Forgiveness
Touch adds ~30-50 ms of latency; coyote time and jump buffering (~116 ms each) already cover it. Consider an optional auto-wall-slide assist. See Platformer movement feel (coyote time, jump buffering, wall jumps).
Mobile-web lessons from Run
- Defaults keyed on the wrong signal: mobile defaults (auto-sprint, zoom, haptics) were
keyed on
kIsWeb, so phone browsers got desktop defaults: no auto-sprint (and no sprint button), zoom 1.0 with a tiny player. Key mobile behavior on a real device check (Serving a phone-friendly Flutter web app from the same URL). - Keep restart always visible in-game (speedrunners restart constantly); keep HUD counters out from under the d-pad; auto-pause when the phone rotates to portrait mid-run.
- Touch buttons must release held flags in
dispose(), and one-shot inputs (ability, jump) should be cleared while the player is frozen so they do not fire after a countdown.
Browser canvas games (justinahampton.com arcade)
Lessons from Orb Destroyer 2, Joyride, Measly and Recourse (2026-08/09), all single-page canvas games played on Justin's Android phone.
- Never put the thumb over the action. Orb Destroyer 2 puts its virtual stick and bomb button below the square stage in portrait and beside it in landscape, and shrinks the stage to make room (calc(100vh - 250px) portrait). One pointerId owns the stick (pointer events plus setPointerCapture, wrapped in try/catch because synthetic test pointers throw); 10 px dead zone, 38 px knob travel; deflection aims and autofires.
- A thumb-relative stick anywhere on the stage (Measly): 8 px dead zone, full speed at 40 px, a quick tap acts, and the act button's label says what act would do right now (EAT / SIT / FOLD).
- Let players choose buttons or swipe per axis. Joyride stores {accel, steer} each buttons|swipe (default buttons for both, Justin's call). All-buttons became a centered arrow-key d-pad (gas over left/brake/right, 66 px squares) with actions split to both sides. When the same button elements move between containers, style them by class (.dir), not by descendant selectors of the old container.
- Gate touch UI on the input device, not width. Show touch controls and the settings gear on (pointer: coarse) (no Esc key on a tablet), hide them under (hover: hover) and (pointer: fine). Allow ?pad=1 to force touch mode for tests.
- Watch class-name collisions on <body>. A body flag named pad matched the pad component's own .pad { display: none } rule and blanked the whole page, while a harness check on the pad's own display still passed. Name it body.touch.
- Size overlay text with container query units off the stage, not viewport units. On a phone the stage is ~380 to 416 px, so 8vw titles spilled over the HUD and under the stick (headless did not reproduce it because Android's monospace fallback is wider). Give the stage container-type: inline-size and size titles, copy, gaps and buttons with clamp(min, N cqw, max); add justify-content: safe center; overflow-y: auto so the worst case scrolls rather than spilling both ways.
- Pause on touch needs a button (a pause key does not exist there) and the pause sheet needs a Resume button; also auto-pause on visibilitychange. One "pause owner" (shop, settings or menu) should be the only thing that can resume, or Space over a settings panel resumes the game underneath.
- Fullscreen on the start tap for coarse pointers (inside the gesture); hide the fullscreen button where unsupported (iPhone Safari).
- A turn-based game sidesteps most control problems: tap a ghost destination dot, the same on desktop and phone, with taps snapped to the nearest legal move within ~1.6 cells.
See also
- Platformer camera, viewport size, and aspect ratios
- Game juice and polish techniques
- Touch compatibility mouse events (mousemove before click)
Linked from
- Arcade game design toolkit (loops, enemies, scoring, structure)
- Game juice and polish techniques
- Platformer camera, viewport size, and aspect ratios
- Platformer movement feel (coyote time, jump buffering, wall jumps)
- Run (runrunrunrun.run), Justin's speedrun platformer
- Serving a phone-friendly Flutter web app from the same URL