body : Phaser.Physics.Arcade.Body | Phaser.Physics.P2.Body | Phaser.Physics.Ninja.Body | null
body
is the Game Objects physics body. Once a Game Object is enabled for physics you access all associated
properties and methods via it.
By default Game Objects won't add themselves to any physics system and their body
property will be null
.
To enable this Game Object for physics you need to call game.physics.enable(object, system)
where object
is this object
and system
is the Physics system you are using. If none is given it defaults to Phaser.Physics.Arcade
.
You can alternatively call game.physics.arcade.enable(object)
, or add this Game Object to a physics enabled Group.
Important: Enabling a Game Object for P2 or Ninja physics will automatically set its anchor
property to 0.5,
so the physics body is centered on the Game Object.
If you need a different result then adjust or re-create the Body shape offsets manually or reset the anchor after enabling physics.
Type
- Inherited From
- Source code: gameobjects/components/PhysicsBody.js (Line 91)
Please login to continue.