1681-engine / index / Pointer
Class: Pointer ​
Defined in: src/core/Pointer.ts:14
The mouse over the game canvas. Presses count only when they start on the canvas (not on the React UI above it); moves are followed everywhere so aiming keeps working at the edge of a panel.
Constructors ​
Constructor ​
new Pointer(canvas): Pointer;Defined in: src/core/Pointer.ts:32
Parameters ​
| Parameter | Type |
|---|---|
canvas | HTMLCanvasElement |
Returns ​
Pointer
Properties ​
worldX ​
worldX: number = 0;Defined in: src/core/Pointer.ts:24
worldY ​
worldY: number = 0;Defined in: src/core/Pointer.ts:25
x ​
x: number = 0;Defined in: src/core/Pointer.ts:22
Screen position relative to the canvas, in CSS pixels.
y ​
y: number = 0;Defined in: src/core/Pointer.ts:23
ignorePress ​
static ignorePress: ((e) => boolean) | null = null;Defined in: src/core/Pointer.ts:19
A press this returns true for is not counted as a held button (e.g. Shift + right-click opening a context menu instead of firing what the right button is bound to). Unset, every press counts.
Accessors ​
locked ​
Get Signature ​
get locked(): boolean;Defined in: src/core/Pointer.ts:78
True while the canvas holds the pointer (lock).
Returns ​
boolean
Methods ​
destroy() ​
destroy(): void;Defined in: src/core/Pointer.ts:107
Returns ​
void
leftButtonDown() ​
leftButtonDown(): boolean;Defined in: src/core/Pointer.ts:69
Returns ​
boolean
lock() ​
lock(options?): Promise<boolean>;Defined in: src/core/Pointer.ts:86
Locks the pointer to the canvas for mouse-look: the cursor hides and takeMovement returns how far the mouse went. Call from a press or key handler (browsers allow it only in a gesture); resolves whether the lock holds.
Parameters ​
| Parameter | Type |
|---|---|
options | { raw?: boolean; } |
options.raw? | boolean |
Returns ​
Promise<boolean>
rightButtonDown() ​
rightButtonDown(): boolean;Defined in: src/core/Pointer.ts:73
Returns ​
boolean
takeMovement() ​
takeMovement(): object;Defined in: src/core/Pointer.ts:96
The mouse travel (CSS pixels) since the last call while locked, then zeroed; read it once per step.
Returns ​
object
x ​
x: number;y ​
y: number;unlock() ​
unlock(): void;Defined in: src/core/Pointer.ts:91
Returns ​
void
updateWorldPoint() ​
updateWorldPoint(cam): void;Defined in: src/core/Pointer.ts:102
Parameters ​
| Parameter | Type |
|---|---|
cam | Camera |
Returns ​
void