The pack
pointer
function pointer(): Pack<{ pointer: PointerApi }, {}, { pointer: PointerData }, { pointer?: PointerSpec }>
The pointer pack: per-object pointer handlers over the kernel's pointer list and the roster's picking.
Headless-safe — with no pointers it simply does nothing.
Types
PointerApi
interface PointerApi
game.pointer.
over(id?: number): Handle | null— The object under a pointer right now, or null.idpicks a specific pointer; the default is the first.captured(id?: number): Handle | null— The object a press captured, or null.release(id?: number): void— Drop a capture without a release — a scene change, an object killed mid-drag.readonly count: number— How many objects carry handlers.add(h: Handle, spec: PointerSpec): void— Give an object handlers after it has spawned. The spawn spec'spointerkey is the usual way; this is for an object a PACK spawned — a text, a widget — and for switching a plain object on later.remove(h: Handle): void— Take an object's handlers away. It stops being picked at all.
PointerAttach
interface PointerAttach
What the pack puts in the registry under ('pointer', 'pointer'), so another PACK can make the objects it spawns interactive without importing this one.
name: string— The registry name:'pointer'.add(h: Handle, spec: PointerSpec): void— Give an object handlers (or replace the ones it has).remove(h: Handle): void— Take its handlers away.
PointerData
interface PointerData extends PointerSpec
Per-object state the pack keeps.
over: boolean— True while a pointer is over this object. Read it for a hover look.held: boolean— True while this object holds a press.
PointerEvent2d
interface PointerEvent2d
What a pointer carries into a handler.
target: Handle— The object the event is about.x: number— World x of the pointer.y: number— World y of the pointer.dx: number— Movement since the last step, world units.dy: number— Movement since the last step, world units.startX: number— Where the press began, world units.startY: number— Where the press began, world units.id: number— The pointer's id, so a multi-touch game can tell two fingers apart.button: number— Which button: 0 left, 1 middle, 2 right.kind: 'mouse' | 'touch' | 'pen'— Mouse, touch or pen.
PointerSpec
interface PointerSpec
The handlers an object may carry. Assign any of them; all are optional and all are live.
onOver?: (e: PointerEvent2d) => void— A pointer entered this object.onOut?: (e: PointerEvent2d) => void— A pointer left it.onDown?: (e: PointerEvent2d) => void— A press landed on it — and CAPTURED it until the release.onUp?: (e: PointerEvent2d) => void— The captured press was released, wherever the pointer had got to.onTap?: (e: PointerEvent2d) => void— Released ON this object, without having moved far: a click.onDrag?: (e: PointerEvent2d) => void— Moved while captured — every step, whether or not the pointer is still over the object.dragThreshold?: number— Distance from the press before dragging starts, world units. Default 0. Once started, dragging continues until release.tapSlop?: number— How far a press may move and still count as a tap, world units. Default 6.enabled?: boolean— Take part at all. Default true — set false to switch an object off without removing its handlers.


