CCPhysicsJoint Class Reference
| Inherits from | NSObject |
| Declared in | CCPhysicsJoint.h |
Overview
CCPhysicsJoints hold two CCPhysicsBodies together in some way like a joint between bones or a hinge on a door. Joints work in a fairly automatic fashion. They are active from the moment they are created. When you are done with a joint you invalidate it in order to disable it. Joints cannot be reactivated once they are invalidated.
Tasks
Creating a CCPhysicsJoint Object
-
+ connectedPivotJointWithBodyA:bodyB:anchorA: -
+ connectedDistanceJointWithBodyA:bodyB:anchorA:anchorB: -
+ connectedDistanceJointWithBodyA:bodyB:anchorA:anchorB:minDistance:maxDistance: -
+ connectedSpringJointWithBodyA:bodyB:anchorA:anchorB:restLength:stiffness:damping: -
+ connectedRotarySpringJointWithBodyA:bodyB:restAngle:stifness:damping: -
+ connectedMotorJointWithBodyA:bodyB:rate: -
+ connectedRotaryLimitJointWithBodyA:bodyB:min:max: -
+ connectedRatchetJointWithBodyA:bodyB:phase:ratchet:
Accessing Physics Joint Attributes
-
bodyAproperty -
bodyBproperty -
maxForceproperty -
collideBodiesproperty -
impulseproperty -
breakingForceproperty -
validproperty -
– invalidate
Properties
bodyA
The first body this joint is attached to.
@property (nonatomic, readonly) CCPhysicsBody *bodyADeclared In
CCPhysicsJoint.hbodyB
The second body this joint is attached to.
@property (nonatomic, readonly) CCPhysicsBody *bodyBDeclared In
CCPhysicsJoint.hbreakingForce
Maximum force that can be applied before the joint disables itself. Defaults to INFINITY To avoid problems with solver accuracy, make sure that this value is lower than CCPhysicsJoint.maxForce.
@property (nonatomic, assign) CGFloat breakingForceDeclared In
CCPhysicsJoint.hcollideBodies
Whether or not the connected bodies are allowed to collide with each other. Defaults to YES.
@property (nonatomic, assign) BOOL collideBodiesDeclared In
CCPhysicsJoint.himpulse
Depending on the joint, either the magnitude of the linear or angular impulse that this joint applied on the previous fixed time step.
@property (nonatomic, readonly) CGFloat impulseDeclared In
CCPhysicsJoint.hClass Methods
connectedDistanceJointWithBodyA:bodyB:anchorA:anchorB:
Creates and returns a pivot joint between the two bodies and keeps the distance of the two anchor points constant. The anchor points are specified in the coordinates of the node that the bodies are attached to. The distance between the anchor points will be calculated when the joint first becomes active.
+ (CCPhysicsJoint *)connectedDistanceJointWithBodyA:(CCPhysicsBody *)bodyA bodyB:(CCPhysicsBody *)bodyB anchorA:(CGPoint)anchorA anchorB:(CGPoint)anchorBParameters
- bodyA
Body A.
- bodyB
Body B.
- anchorA
Anchor point A.
- anchorB
Anchor point B.
Return Value
The CCPhysicsJoint Object.
Declared In
CCPhysicsJoint.hconnectedDistanceJointWithBodyA:bodyB:anchorA:anchorB:minDistance:maxDistance:
Creates and returns a pivot joint between the two bodies and keeps the distance of the two anchor points within the range. The anchor points are specified in the coordinates of the node that the bodies are attached to.
+ (CCPhysicsJoint *)connectedDistanceJointWithBodyA:(CCPhysicsBody *)bodyA bodyB:(CCPhysicsBody *)bodyB anchorA:(CGPoint)anchorA anchorB:(CGPoint)anchorB minDistance:(CGFloat)min maxDistance:(CGFloat)maxParameters
- bodyA
Body A.
- bodyB
Body B.
- anchorA
Anchor point A.
- anchorB
Anchor point B.
- min
The minimum distance to allow between the anchor points.
- max
The maximum distance to allow between the anchor points.
Return Value
The CCPhysicsJoint Object.
Declared In
CCPhysicsJoint.hconnectedMotorJointWithBodyA:bodyB:rate:
Creates and returns a Motor joint between the two bodies. No anchor points are specified as this joint can be used in conjunction with a pivot joint to make a motor around a pivot point.
+ (CCPhysicsJoint *)connectedMotorJointWithBodyA:(CCPhysicsBody *)bodyA bodyB:(CCPhysicsBody *)bodyB rate:(CGFloat)rateParameters
- bodyA
Body A.
- bodyB
Body B.
- rate
Rate at which the rotate relative to each other. Negative values to reverse direction.
Return Value
The CCPhysicsJoint Object.
Declared In
CCPhysicsJoint.hconnectedPivotJointWithBodyA:bodyB:anchorA:
Creates and returns a pivot joint object between the two bodies specified. The pivot point is specified in the coordinates of the node that bodyA is attached to.
+ (CCPhysicsJoint *)connectedPivotJointWithBodyA:(CCPhysicsBody *)bodyA bodyB:(CCPhysicsBody *)bodyB anchorA:(CGPoint)anchorAParameters
- bodyA
Body A.
- bodyB
Body B.
- anchorA
Anchor point A.
Return Value
The CCPhysicsJoint Object.
Declared In
CCPhysicsJoint.hconnectedRatchetJointWithBodyA:bodyB:phase:ratchet:
Creates and returns ratchet jointwhereby the angle of rotation between too bodies can go forwards smoothely, but the backwards motion is clipped at ‘ratchet’ intervals. No anchor points are specified as this joint can be used in conjunction with a pivot joint to ratchet its range of motion.
+ (CCPhysicsJoint *)connectedRatchetJointWithBodyA:(CCPhysicsBody *)bodyA bodyB:(CCPhysicsBody *)bodyB phase:(CGFloat)phase ratchet:(CGFloat)ratchetParameters
- bodyA
Body A.
- bodyB
Body B.
- phase
Phase angle in Radians [0, 2 PI] describing where within the rathet interval the joint is located.
- ratchet
Ratchet interval angle in radians.
Return Value
The CCPhysicsJoint Object.
Declared In
CCPhysicsJoint.hconnectedRotaryLimitJointWithBodyA:bodyB:min:max:
Creates and returns joint whereby the angle of rotation between too bodies is limited. No anchor points are specified as this joint can be used in conjunction with a pivot joint to make the pivots range of motion limited.
+ (CCPhysicsJoint *)connectedRotaryLimitJointWithBodyA:(CCPhysicsBody *)bodyA bodyB:(CCPhysicsBody *)bodyB min:(CGFloat)min max:(CGFloat)maxParameters
- bodyA
Body A.
- bodyB
Body B.
- min
Minimum angle in radians.
- max
Maximum angle in radians.
Return Value
The CCPhysicsJoint Object.
Declared In
CCPhysicsJoint.hconnectedRotarySpringJointWithBodyA:bodyB:restAngle:stifness:damping:
Creates and returns a rotary spring joint between the two bodies. No anchor points are specified as this joint can be used in conjunction with a pivot joint to make a springing pivot joint.
+ (CCPhysicsJoint *)connectedRotarySpringJointWithBodyA:(CCPhysicsBody *)bodyA bodyB:(CCPhysicsBody *)bodyB restAngle:(CGFloat)restAngle stifness:(CGFloat)stiffness damping:(CGFloat)dampingParameters
- bodyA
Body A.
- bodyB
Body B.
- restAngle
Rest angle.
- stiffness
Spring stiffness.
- damping
Sprin damping.
Return Value
The CCPhysicsJoint Object.
Declared In
CCPhysicsJoint.hconnectedSpringJointWithBodyA:bodyB:anchorA:anchorB:restLength:stiffness:damping:
Creates and returns a spring joint between the two bodies at the specified anchor points. The anchor points are specicied in the coordinates of the node that he bodies are attached to.
+ (CCPhysicsJoint *)connectedSpringJointWithBodyA:(CCPhysicsBody *)bodyA bodyB:(CCPhysicsBody *)bodyB anchorA:(CGPoint)anchorA anchorB:(CGPoint)anchorB restLength:(CGFloat)restLength stiffness:(CGFloat)stiffness damping:(CGFloat)dampingParameters
- bodyA
Body A.
- bodyB
Body B.
- anchorA
Anchor point A.
- anchorB
Anchor point B.
- restLength
Rest Length.
- stiffness
Spring stiffness.
- damping
Sprin damping.
Return Value
The CCPhysicsJoint Object.
Declared In
CCPhysicsJoint.h