Phaser API Documentation

  Version: 
<static> SeparateX(body1, body2, overlapOnly, bias)

Description:

Separates two overlapping bodies on the X-axis (horizontally).

Separation involves moving two overlapping bodies so they don't overlap anymore and adjusting their velocities based on their mass. This is a core part of collision detection.

The bodies won't be separated if there is no horizontal overlap between them, if they are static, or if either one uses custom logic for its separation.

Parameters:

name type description
body1 Phaser.Physics.Arcade.Body

The first Body to separate.

body2 Phaser.Physics.Arcade.Body

The second Body to separate.

overlapOnly boolean

If true, the bodies will only have their overlap data set and no separation will take place.

bias number

A value to add to the delta value during overlap checking. Used to prevent sprite tunneling.

Returns:
Description:

true if the two bodies overlap vertically, otherwise false.

Type:
  • boolean
Examples:
Since: 3.0.0