Joint

Joint

new Joint(spriteA, spriteB, typeopt)

Using this Joint class directly is not recommended, but if it is used a GlueJoint will be created. It's better to use a specific joint class constructor: GlueJoint, DistanceJoint, WheelJoint, HingeJoint, SliderJoint, or RopeJoint. All other joint classes extend this class. Joint type can not be changed after a joint is created.
Source:
Parameters:
Name Type Attributes Description
spriteA Sprite
spriteB Sprite
type String <optional>

Classes

Joint

Members

collideConnected :Boolean

Set to true if you want the joint's sprites to collide with each other.
Default Value:
  • false
Source:
Type:
  • Boolean

damping :Number

Damping only effects joint's that have a springiness greater than 0. Damping is a 0-1 ratio describing how quickly the joint loses vibrational energy. 0.0 lets the joint continue to spring up and down very easily. 1.0 makes the joint lose vibrational energy immediately, making the joint completely rigid, regardless of its springiness.
Default Value:
  • 0.0
Source:
Type:
  • Number

draw :function

Function that draws the joint. Can be overridden by the user.
Source:
Type:
  • function

enableMotor :Boolean

Enable or disable the joint's motor. Disabling the motor is like putting a car in neutral.
Source:
Type:
  • Boolean

maxPower :Number

Max power is how the amount of torque a joint motor can exert around its axis of rotation.
Default Value:
  • 0
Source:
Type:
  • Number

offsetA :p5.Vector

Offset to the joint's anchorA position from the center of spriteA. Only distance and hinge joints have an offsetA.
Default Value:
  • {x: 0, y: 0}
Source:
Type:
  • p5.Vector

offsetB :p5.Vector

Offset to the joint's anchorB position from the center of spriteB. Only distance, hinge, and wheel joints have an offsetB.
Default Value:
  • {x: 0, y: 0}
Source:
Type:
  • p5.Vector

power :Number

Read only. The joint's current power, the amount of torque being applied on the joint's axis of rotation.
Default Value:
  • 0
Source:
Type:
  • Number

reactionForce

Read only. The joint's reaction force.
Source:

reactionTorque

Read only. The joint's reaction torque.
Source:

speed :Number

The current speed of the joint's motor.
Default Value:
  • 0
Source:
Type:
  • Number

springiness :Number

The springiness of the joint, a 0-1 ratio. 0.0 makes the joint completely rigid, and 1.0 turns the joint into a super loose spring, like a broken slinky that was overextended. Springiness is a user friendly wrapper around Box2D's spring frequency joint parameter. It's 0-1 ratio is piecewise mapped to the range of 30-0.2hz, except 0 remains 0. 0.0 -> 0hz (perfectly rigid) >0.0-0.1 -> 30hz-4hz (steel rod) 0.1-0.5 -> 4hz-2.5hz (tight spring) 0.5-0.8 -> 2.5hz-1hz (bouncy spring) 0.8-0.9 -> 1hz-0.5hz (slinky) 0.9-1.0 -> 0.5hz-0.2hz (bungee cord)
Default Value:
  • 0.0
Source:
Type:
  • Number

Methods

remove()

Removes the joint from the world and from each of the sprites' joints arrays.
Source: