~1 min read

Collision response

Click anywhere to drop a physics ball — they collide with each other and the world bounds.

Collision response Phaser 4 · sandboxed

Notes

  • A physics group with collideWorldBounds keeps every member inside the canvas.
  • physics.add.collider(group, group) makes group members collide with each other — the second pass over the group is what gives you ball-on-ball bouncing.
  • setCircle(radius) switches the body from the default rectangular AABB to a circle. Phaser’s Arcade defaults to rectangles even for round sprites.
  • Pointer events fire on the iframe — pointer.x / pointer.y are already in canvas coordinates.
  • See Arcade Physics for groups, colliders, overlaps, and the rest.