Skip to content

Mobile ​

The same game runs on phones — Player mounts touch controls instead of pointer-lock, and two helpers handle the screen itself.

Touch controls ​

When TOUCH_ENABLED is true (coarse pointer, ontouchstart, or ?touch in the URL), the player gets a MobileController: a left-side stick to walk, swipe anywhere else to look, and a jump button. The stick and button carry data-testid="stick-left" / "jump-btn" for e2e suites.

Add ?touch to any URL to develop the touch UI with a mouse; pass new Player({ camera, forceTouch: true }) to force it per-instance.

Landscape ​

A first-person world held upright is a sliver of view with crowded controls. From @maomi/sge/orientation:

ts
import { mountOrientationPrompt } from '@maomi/sge/orientation';
const dispose = mountOrientationPrompt(el);   // overlay: "Rotate your device"

On phones in portrait it overlays a rotate prompt; where the browser allows it (screen.orientation.lock() needs fullscreen — Chromium on Android), the prompt offers a button that flips the device for the player. Safari has no lock on any platform, so there the prompt simply asks.

Fullscreen ​

ts
import { mountFullscreenButton } from '@maomi/sge/fullscreen';
const dispose = mountFullscreenButton(el);    // ⛶ button, top-right

Uses the Fullscreen API and hides itself where the API is missing rather than showing a dead control. Entering fullscreen also attempts the landscape lock — on Android the two compose into "tap ⛶, world rotates".

Both helpers return a dispose function; call it when the game unmounts (or wrap it in a Cleanup entity).