Appearance
Class: InputState
The Input resource. Read it with res.get(Input): axis (x: right−left, y: up−down, length ≤ 1), down('jump'), pressed('jump'), released('jump'), value('fire'), and pointer.
pressed/released are true for exactly one fixed step when read in Fixed, and for exactly one frame when read elsewhere, however many fixed steps a frame runs.
Constructors
Constructor
ts
new InputState(): InputState;Returns
InputState
Properties
axis
ts
readonly axis: object;Move axis from left/right/up/down (or the left stick). Unit length at most.
x
ts
x: number = 0;y
ts
y: number = 0;pointer
ts
readonly pointer: object;Pointer in canvas pixels and normalized device coords (y up), plus deltas this frame.
x
ts
x: number = 0;y
ts
y: number = 0;ndcX
ts
ndcX: number = 0;ndcY
ts
ndcY: number = 0;dx
ts
dx: number = 0;dy
ts
dy: number = 0;wheel
ts
wheel: number = 0;down
ts
down: boolean = false;values
ts
values: Map<string, number>;downSet
ts
downSet: Set<string>;framePressed
ts
framePressed: Set<string>;frameReleased
ts
frameReleased: Set<string>;fixedPressed
ts
fixedPressed: Set<string>;fixedReleased
ts
fixedReleased: Set<string>;inFixed
ts
inFixed: () => boolean;Returns
boolean
Methods
down()
ts
down(action): boolean;True while the action is held.
Parameters
| Parameter | Type |
|---|---|
action | string |
Returns
boolean
pressed()
ts
pressed(action): boolean;True on the step (in Fixed) or frame (elsewhere) the action went down.
Parameters
| Parameter | Type |
|---|---|
action | string |
Returns
boolean
released()
ts
released(action): boolean;True on the step (in Fixed) or frame (elsewhere) the action went up.
Parameters
| Parameter | Type |
|---|---|
action | string |
Returns
boolean
value()
ts
value(action): number;Analog value 0..1 (triggers, stick directions); 0 or 1 for keys.
Parameters
| Parameter | Type |
|---|---|
action | string |
Returns
number
toJSON()
ts
toJSON(): object;Returns
object
axis
ts
axis: object;axis.x
ts
x: number = 0;axis.y
ts
y: number = 0;down
ts
down: string[];