Phaser API Documentation

  Version: 
getMatterBodies([bodies])

Description:

Takes an array and returns a new array made from all of the Matter Bodies found in the original array.

For example, passing in Matter Game Objects, such as a bunch of Matter Sprites, to this method, would return an array containing all of their native Matter Body objects.

If the bodies argument is falsey, it will return all bodies in the world.

Parameters:

name type arguments description
bodies array <optional>

An array of objects to extract the bodies from. If falsey, it will return all bodies in the world.

Returns:
Description:

An array of native Matter Body objects.

Type:
  • Array.<MatterJS.BodyType>
Since: 3.22.0