Phaser AE

Per-object pointer handlers

Free packv3.0.0-32DLogic

Over, out, down, up, tap and drag handlers on the objects that want them, with the capture rule that makes a drag survive the pointer leaving the object. It is the pointer bookkeeping every game otherwise writes for itself, and usually gets subtly wrong, done once.

This is a Free pack. Every phaser.io account can use it in their games.

Released October 14, 2026 · updated October 19, 2026

Per-object pointer handlers: a screenshot of its demo
A note about these graphics

Expansion packs don't come with graphics. This screenshot is one way of drawing what the pack does, made for its demo: none of the sprites, tiles or backgrounds in it are in the pack.

That's by design. A pack is a game's logic, mechanics and effects, and it works with whatever art you give it. Some packs draw effects, backdrops or 3D scenes of their own, but none carries a game's sprites.

So the look is yours. Make the art on phaser.io, bring your own, or let your agent draw it in code: the same pack can look like anything.

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. id picks 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's pointer key 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.