Phaser API Documentation

  Version: 
containsPoint(body, x, y)

Description:

Checks if the vertices of the given body, or an array of bodies, contains the given point, or not.

You can pass in either a single body, or an array of bodies to be checked. This method will return true if any of the bodies in the array contain the point. See the intersectPoint method if you need to get a list of intersecting bodies.

The point should be transformed into the Matter World coordinate system in advance. This happens by default with Input Pointers, but if you wish to use points from another system you may need to transform them before passing them.

Parameters:

name type description
body Phaser.Types.Physics.Matter.MatterBody | Array.<Phaser.Types.Physics.Matter.MatterBody>

The body, or an array of bodies, to check against the point.

x number

The horizontal coordinate of the point.

y number

The vertical coordinate of the point.

Returns:
Description:

true if the point is within one of the bodies given, otherwise false.

Type:
  • boolean
Since: 3.22.0