~1 min read

Physics overlap (pickups)

Walk into stars to collect them — the canonical "overlap as trigger" pattern with score tracking.

Pickup with overlap Phaser 4 · sandboxed

Notes

  • Click the playground to give it keyboard focus first.
  • overlap vs. collider: overlap fires a callback when bounding boxes intersect without separating them — perfect for pickups, triggers, hitboxes. collider separates the bodies and stops them interpenetrating — for walls, floors, enemies.
  • Group convenience: a single overlap(player, coinsGroup, cb) covers every coin in the group. No per-coin wiring.
  • coin.destroy() removes the coin from the scene and the group; subsequent overlap checks skip it automatically.
  • See Arcade Physics for groups, dynamic vs. static bodies, tunneling pitfalls, and debug rendering.