1681-engine / index / TargetLock
Class: TargetLock<T> ​
Defined in: src/input/TargetLock.ts:87
The lock as state: which body is held, picked by a drag or the nearest, let go when it is gone or too far.
Type Parameters ​
| Type Parameter | Default type |
|---|---|
T extends LockBody | LockBody |
Constructors ​
Constructor ​
new TargetLock<T>(bodies, options?): TargetLock<T>;Defined in: src/input/TargetLock.ts:93
Parameters ​
| Parameter | Type |
|---|---|
bodies | () => readonly T[] |
options | TargetLockOptions |
Returns ​
TargetLock<T>
Accessors ​
locked ​
Get Signature ​
get locked(): number | null;Defined in: src/input/TargetLock.ts:103
The id held, without checking it still stands (use current for that).
Returns ​
number | null
Methods ​
clear() ​
clear(): void;Defined in: src/input/TargetLock.ts:127
Returns ​
void
current() ​
current(from): T | null;Defined in: src/input/TargetLock.ts:121
The held body if it still holds; a lock that no longer does is dropped.
Parameters ​
| Parameter | Type |
|---|---|
from | Point |
Returns ​
T | null
pick() ​
pick(from, dir): number | null;Defined in: src/input/TargetLock.ts:108
A drag in dir from from: locks what it points at; pointing at nothing keeps the old lock.
Parameters ​
| Parameter | Type |
|---|---|
from | Point |
dir | Point |
Returns ​
number | null
pickNearest() ​
pickNearest(from): number | null;Defined in: src/input/TargetLock.ts:115
Locks the nearest body, every call, whatever was held.
Parameters ​
| Parameter | Type |
|---|---|
from | Point |
Returns ​
number | null