Phaser API Documentation

enable(object, [bodyType])


Adds an Arcade Physics Body to a Game Object, an array of Game Objects, or the children of a Group.

The difference between this and the enableBody method is that you can pass arrays or Groups to this method.

You can specify if the bodies are to be Dynamic or Static. A dynamic body can move via velocity and acceleration. A static body remains fixed in place and as such is able to use an optimized search tree, making it ideal for static elements such as level objects. You can still collide and overlap with static bodies.

Normally, rather than calling this method directly, you'd use the helper methods available in the Arcade Physics Factory, such as:

this.physics.add.image(x, y, textureKey);
this.physics.add.sprite(x, y, textureKey);

Calling factory methods encapsulates the creation of a Game Object and the creation of its body at the same time. If you are creating custom classes then you can pass them to this method to have their bodies created.


name type arguments description
object Phaser.GameObjects.GameObject | Array.<Phaser.GameObjects.GameObject> | Phaser.GameObjects.Group | Array.<Phaser.GameObjects.Group>

The object, or objects, on which to create the bodies.

bodyType number <optional>

The type of Body to create. Either DYNAMIC_BODY or STATIC_BODY.

Since: 3.0.0