These docs are for an outdated version of Phaser The documentation on this page is for Phaser 2.6.2. The latest release is 2.10.0.


Phaser.Physics.P2. DistanceConstraint

new DistanceConstraint(world, bodyA, bodyB, distance, localAnchorA, localAnchorB, maxForce)

A constraint that tries to keep the distance between two bodies constant.

Name Type Argument Default Description
world Phaser.Physics.P2

A reference to the P2 World.

bodyA p2.Body

First connected body.

bodyB p2.Body

Second connected body.

distance number

The distance to keep between the bodies.

localAnchorA Array <optional>

The anchor point for bodyA, defined locally in bodyA frame. Defaults to [0,0].

localAnchorB Array <optional>

The anchor point for bodyB, defined locally in bodyB frame. Defaults to [0,0].

maxForce object <optional>

Maximum force to apply.

Source code: physics/p2/DistanceConstraint.js (Line 20)

Public Properties

game : Phaser.Game

Local reference to game.

Source code: physics/p2/DistanceConstraint.js (Line 30)

world : Phaser.Physics.P2

Local reference to P2 World.

Source code: physics/p2/DistanceConstraint.js (Line 35)