Skip to content

Instantly share code, notes, and snippets.

@samme
Last active August 31, 2017 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samme/cbb81dd19f564dcfe2232761e575063d to your computer and use it in GitHub Desktop.
Save samme/cbb81dd19f564dcfe2232761e575063d to your computer and use it in GitHub Desktop.
Phaser sprite vs. sprite collision

Results of collide(sprite1, sprite2) or overlap(sprite1, sprite2).

Body 1 Body 2 collide overlap embedded touching.none overlapX/Y separation¹ acceleration¹
sprite.exists=false false false
enable=false false false
checkCollision.none=true false false
immovable=true true true false ≠ 0 no no
moves=false true true false ≠ 0 yes no²
bounce³ is 0 true true false ≠ 0 yes no
delta⁴ is 0 delta⁴ is 0 true true true ≠ 0 no no
[overlap > maxOverlap⁵] true false ≠ 0
[overlap > maxOverlap⁵] false 0 no no
[all other cases] true true false ≠ 0 yes yes
  1. Separation and acceleration happen only via collide. Separation means Body 1 is moved outside Body 2. Acceleration means Body 1‘s velocity changes.
  2. The body‘s velocity does change but there is no movement while body.moves=false.
  3. body.bounce.x or body.bounce.y
  4. body.deltaX() or body.deltaY()
  5. maxOverlap is the sum of the two Bodies’ absolute deltas and OVERLAP_BIAS.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment