Phaser API Documentation

  Version: 
intersectRect(x, y, width, height, [outside], [bodies])

Description:

Checks the given rectangular area to see if any vertices of the given bodies intersect with it. Or, if the outside parameter is set to true, it checks to see which bodies do not intersect with it.

If no bodies are provided it will search all bodies in the Matter World, including within Composites.

Parameters:

name type arguments Default description
x number

The horizontal coordinate of the top-left of the area.

y number

The vertical coordinate of the top-left of the area.

width number

The width of the area.

height number

The height of the area.

outside boolean <optional> false

If false it checks for vertices inside the area, if true it checks for vertices outside the area.

bodies Array.<Phaser.Types.Physics.Matter.MatterBody> <optional>

An array of bodies to check. If not provided it will search all bodies in the world.

Returns:
Description:

An array of bodies that intersect with the given area.

Since: 3.22.0