Input · interface

AnalogAction

Move, look: a direction rather than a state.

Explained in Moving things.

interface AnalogAction
import type { AnalogAction } from '@driftengine/core';

In depth

The reason this cannot be a button-only design. A stick is not a key, and a game that treated one as four keys would throw away the magnitude the player is actually controlling.

Key directions follow the stick's convention, which is the specification's: up is negative. The alternative was to flip one of them, and an engine that silently disagrees with the API it wraps is one a consumer cannot reason about.

Properties

NameTypeDescription
stickreadonly'left' | 'right'
upreadonlyoptionalstring | readonly string[]One code or several, per direction.
More

Several, because DigitalAction above takes several and a player does not care which kind of action they are rebinding. A game binding both KeyW and ArrowUp to forward — which is the ordinary thing to do — could express that for jump and not for movement, and the asymmetry was the whole of the gap: the alternative was two analog actions merged by hand at the call site, which is the engine handing back a job it already does.

downreadonlyoptionalstring | readonly string[]
leftreadonlyoptionalstring | readonly string[]