Phaser API Documentation

  Version: 
setGameObject(gameObject, [enable])

Description:

Assign this Body to a new Game Object.

Removes this body from the Physics World, assigns to the new Game Object, calls setSize and then adds this body back into the World again, setting it enabled, unless the enable argument is set to false.

If this body already has a Game Object, then it will remove itself from that Game Object first.

Only if the given gameObject has a body property will this Body be assigned to it.

Parameters:

name type arguments Default description
gameObject Phaser.GameObjects.GameObject

The Game Object this Body belongs to.

enable boolean <optional> true

Automatically enable this Body for physics.

Returns:
Description:

This Body object.

Since: 3.60.0