b2DistanceJoint(native)
A distance joint constrains two points on two bodies to remain at a fixed distance from each other.
Example
this.bodyA = this.world.createBody(shape, #dynamic/*type of body*/, 1/*density*/, 1/*friction*/, 1/*bounce*/, 50/*x*/, 20/*y*/); this.bodyB = this.world.createBody(shape, #dynamic/*type of body*/, 1/*density*/, 1/*friction*/, 1/*bounce*/, 50/*x*/, 20/*y*/); var def = { dampingRatio: 0.5; //from 0 to 1 }; var (xa, ya) = this.bodyA.getWorldCenter(); var (xb, yb) = this.bodyB.getWorldCenter(); this.joint = this.world.createDistanceJoint(this.bodyA, this.bodyB, xa, ya, xb, yb, def);
Properties
-
dampingRatio : Float
Damping ratio.
-
frequencyHz : Float
Frequency in Hz.
-
length : Float
The natural length. Manipulating the length can lead to non-physical behavior when the frequency is zero.