Phaser API Documentation

  Version: 
gameObject(gameObject, [options], [addToWorld])

Description:

Takes an existing Game Object and injects all of the Matter Components into it.

This enables you to use component methods such as setVelocity or isSensor directly from this Game Object.

You can also pass in either a Matter Body Configuration object, or a Matter Body instance to link with this Game Object.

Parameters:

name type arguments Default description
gameObject Phaser.GameObjects.GameObject

The Game Object to inject the Matter Components in to.

options MatterJS.Body | Phaser.Types.Physics.Matter.MatterBodyConfig <optional>

A Matter Body configuration object, or an instance of a Matter Body.

addToWorld boolean <optional> true

Add this Matter Body to the World?

Returns:
Description:

The Game Object that had the Matter Components injected into it.

Since: 3.3.0