Mobile Controls
RPGJS ships a CanvasEngine mobile overlay throughwithMobile(). It renders a
virtual joystick and action buttons over the game canvas, and forwards touches to
the same controls used by keyboard and gamepad input.
Enable Mobile Controls
AddwithMobile() to your client modules:
Configure the Overlay
Useenabled: "always" while testing from a desktop browser:
| Option | Description |
|---|---|
id | GUI id. Defaults to mobile-gui. |
enabled | "auto", "always", "never", or a predicate. Defaults to "auto". |
layout | Positions the overlay. Use joystickSide, margin, buttonsMargin, joystickMargin, and gap to tune placement. |
components | Replaces the default CanvasEngine joystick or button components. |
joystick | Set to false to hide it, or pass colors, scale, and movement settings. outerScale and innerScale are available when using custom joystick sprites. |
buttons.action | Shows the A button and triggers the action control. |
buttons.back | Shows the B button and triggers the back control. |
buttons.dash | Shows the D button and triggers the dash control. |
Customize Components
The default overlay is built with CanvasEngine components. You can replace the joystick, individual buttons, or both. Custom components receive the same control props as the default component plusdefaultProps, so they can wrap CanvasEngine
Joystick and Button without reimplementing RPGJS input behavior.
joystick or a button
option. For larger visual changes, prefer components and wrap the default
props inside your .ce component.
Runtime Behavior
Mobile controls are client-side input helpers. In standalone mode and MMORPG mode they send the same movement and action inputs as keyboard/gamepad controls; they do not create gameplay authority on the client. The virtual joystick uses CanvasEngine’sJoystick component for input. RPGJS
movement is cardinal, so diagonal joystick positions are resolved to the nearest
single RPGJS movement control before being repeated.