Bash.tv → GitHub → itch.io

Make browser games play well on phones and tablets. Picking the right touch scheme for the genre (tap, swipe, drag, floating joystick, on-screen buttons, tilt), thumb-reachable layouts, hit areas, multi-touch, stopping page scroll and zoom, safe areas and notches, haptics, and testing at phone sizes. Includes a drop-in floating joystick and buttons (touch-controls.js). Use for "make it work on ...

Download skill (.zip) Files on GitHub

Mobile game controls

Half of Bash viewers are on phones. Design the touch scheme with the game, not after it.

Pick the scheme by genre

Game Best touch scheme
One-button (runner, flappy, rhythm) Tap anywhere (whole screen is the button)
Lane / swipe (runner, match-3, 2048) Swipe (threshold ~30 px, decide on direction at release or once past threshold)
Aim + shoot, drag puzzles, slingshot Drag on the object itself
Top-down / twin-stick / platformer Floating joystick left half + 1–2 buttons right side (assets/touch-controls.js)
Strategy, tower defense, cards, idle Tap to select, tap to act; long-press for info; pinch / two-finger drag for camera
Racing / ball rolling Left/right halves to steer, or tilt (DeviceOrientationEvent, needs a permission tap on iOS) as an option only

Fewer buttons wins. If it needs more than 3 buttons on touch, merge actions (auto-fire, context button, auto-jump on ledges).

Layout rules

Technical must-dos

canvas { touch-action: none; }                       /* no scroll, pinch-zoom or double-tap zoom on the game */
html, body { overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }

Drop-in controls

import { createTouchControls } from "./core/touch-controls.js";
const touch = createTouchControls(canvas, input, {
  stick: { side: "left", radius: 60 },
  buttons: [{ action: "jump", label: "A", x: -80, y: -90, r: 44 }, { action: "fire", label: "B", x: -180, y: -60, r: 38 }],
  toGame: (x, y) => screen.toGame(x, y),          // CSS px → game px
  size: () => ({ w: config.width, h: config.height }),
});
// update: const s = touch.stick;  player.move(s.x, s.y)       draw (last, over the HUD): touch.draw(ctx)

Negative x/y are measured from the right/bottom edge. The stick also presses left/right/up/down actions, so existing keyboard code works unchanged.

Test