Box2D. Box2dPrismaticJoint

Box2D Prismatic Joint

  • Provides one degree of freedom: translation along an axis fixed in objectA
  • Relative rotation is prevented
  • You can use a joint limit to restrict the range of motion
  • You can use a joint motor to drive the motion or to model joint friction

Constructor

new Box2dPrismaticJoint(objectA, objectB, anchor, worldAxis, collideopt)

Create a prismatic joint

Parameters:
NameTypeAttributesDefaultDescription
objectABox2dObject
objectBBox2dObject
anchorVector2
worldAxisVector2
collideboolean<optional>
false

Extends

  • Box2dJoint

Methods

enableLimit(enableopt)

Enable/disable the joint limit

Parameters:
NameTypeAttributesDefaultDescription
enableboolean<optional>
true

enableMotor(enableopt)

Enable/disable the joint motor

Parameters:
NameTypeAttributesDefaultDescription
enableboolean<optional>
true

getJointSpeed() → {number}

Get the current joint translation speed

Returns:
Type: 
number

getJointTranslation() → {number}

Get the current joint translation

Returns:
Type: 
number

getLocalAnchorA() → {Vector2}

Get the local anchor point relative to objectA's origin

Returns:
Type: 
Vector2

getLocalAnchorB() → {Vector2}

Get the local anchor point relative to objectB's origin

Returns:
Type: 
Vector2

getLocalAxisA() → {Vector2}

Get the local joint axis relative to bodyA

Returns:
Type: 
Vector2

getLowerLimit() → {number}

Get the lower joint limit

Returns:
Type: 
number

getMaxMotorForce() → {number}

Get the maximum motor force

Returns:
Type: 
number

getMotorForce(time) → {number}

Get the motor force given a time step

Parameters:
NameTypeDescription
timenumber
Returns:
Type: 
number

getMotorSpeed() → {number}

Get the motor speed

Returns:
Type: 
number

getReferenceAngle() → {number}

Get the reference angle

Returns:
Type: 
number

getUpperLimit() → {number}

Get the upper joint limit

Returns:
Type: 
number

isLimitEnabled() → {boolean}

Is the joint limit enabled?

Returns:
Type: 
boolean

isMotorEnabled() → {boolean}

Is the motor enabled?

Returns:
Type: 
boolean

setLimits(min, max)

Set the joint limits

Parameters:
NameTypeDescription
minnumber
maxnumber

setMaxMotorForce(force)

Set the maximum motor force

Parameters:
NameTypeDescription
forcenumber

setMotorSpeed(speed)

Set the motor speed

Parameters:
NameTypeDescription
speednumber