Skip to main content

defaultTouchControls

@zylem/game-lib


@zylem/game-lib / input-ui / defaultTouchControls

Function: defaultTouchControls()

defaultTouchControls(player?, options?): GameInputConfig

Defined in: packages/game-lib/src/lib/input-ui/default-controls.ts:92

Builds a ready-to-use GameInputConfig that wires up themed virtual touch controls for a player. Internally composes useVirtualControls with theme-aware SVGs from svg-assets.ts.

On desktop runtimes the provider stays dormant (with the default enabled: 'auto'), so it's safe to add this to any game's input configuration unconditionally.

Parameters​

player?​

"p1" | "p3" | "p4" | "p2" | "p6" | "p5" | "p7" | "p8"

options?​

DefaultTouchControlsOptions = \{\}

Returns​

GameInputConfig

Example​

stage.setInputConfiguration(
defaultTouchControls('p1', {
theme: 'lagoon',
joysticks: 'left',
buttons: ['A', 'B'],
}),
);