voxolith

Actions<B *extends* [`Bindings`](/docs/engine/api/input/type-aliases/Bindings/) = [`Bindings`](/docs/engine/api/input/type-aliases/Bindings/)>

Named game controls over an input, from makeActions. Values are read live from the input; edges (pressed, released) follow its update().

Defined in: engine/src/input/actions.ts:56

Type Parameters

Type ParameterDefault type
B extends BindingsBindings

Methods

bind()

bind(name: keyof B & string, binding: Binding): void;

Defined in: engine/src/input/actions.ts:68

Replace one action's binding (the binding is copied).

Parameters

ParameterType
namekeyof B & string
bindingBinding

Returns

void


bindings()

bindings(): B;

Defined in: engine/src/input/actions.ts:70

The current bindings as plain JSON, for saving a player's rebinding.

Returns

B


down()

down(name: keyof B & string): boolean;

Defined in: engine/src/input/actions.ts:58

Held (a button), or pushed past half-way (an axis, either direction).

Parameters

ParameterType
namekeyof B & string

Returns

boolean


keys()

keys(): string[];

Defined in: engine/src/input/actions.ts:74

Every key code any action uses.

Returns

string[]


load()

load(saved: Partial<Record<string, Binding>>): void;

Defined in: engine/src/input/actions.ts:72

Restore saved bindings; unknown names are ignored, missing ones keep their defaults.

Parameters

ParameterType
savedPartial<Record<string, Binding>>

Returns

void


pressed()

pressed(name: keyof B & string): boolean;

Defined in: engine/src/input/actions.ts:60

Went down / up since the previous input.update().

Parameters

ParameterType
namekeyof B & string

Returns

boolean


released()

released(name: keyof B & string): boolean;

Defined in: engine/src/input/actions.ts:62

A source went up since the previous input.update() and the action is no longer down.

Parameters

ParameterType
namekeyof B & string

Returns

boolean


value()

value(name: keyof B & string): number;

Defined in: engine/src/input/actions.ts:64

-1..1 for axes, 0..1 for buttons.

Parameters

ParameterType
namekeyof B & string

Returns

number


vector()

vector(x: keyof B & string, y: keyof B & string): [number, number];

Defined in: engine/src/input/actions.ts:66

Two axes as a vector, clamped to the unit circle so diagonals are not faster.

Parameters

ParameterType
xkeyof B & string
ykeyof B & string

Returns

[number, number]

On this page