iOS Developer Library

Developer

SpriteKit Framework Reference SKPhysicsJointPin Class Reference

Options
Deployment Target:

On This Page
Language:

SKPhysicsJointPin

An SKPhysicsJointPin object allows two physics bodies to independently rotate around the anchor point as if pinned together. You can configure how far the two objects may rotate and the resistance to rotation.

Inheritance


Conforms To


Import Statement


Swift

import SpriteKit

Objective-C

@import SpriteKit;

Availability


Available in iOS 7.0 and later.
  • Creates a new pin joint.

    Declaration

    Swift

    class func jointWithBodyA(_ bodyA: SKPhysicsBody!, bodyB bodyB: SKPhysicsBody!, anchor anchor: CGPoint) -> SKPhysicsJointPin!

    Objective-C

    + (SKPhysicsJointPin *)jointWithBodyA:(SKPhysicsBody *)bodyA bodyB:(SKPhysicsBody *)bodyB anchor:(CGPoint)anchor

    Parameters

    bodyA

    The first body to connect. The body must be connected to a node that is already part of the scene’s node tree.

    bodyB

    The second body to connect. The body must be connected to a node that is already part of the scene’s node tree.

    anchor

    The connection point between the two bodies in the scene’s coordinate system.

    Return Value

    A new pin joint.

    Discussion

    You must add the joint to a physics world associated with the scene before it takes effect.

    Import Statement

    Objective-C

    @import SpriteKit;

    Swift

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

  • The speed, in radians per second, at which the physics bodies are driven around the pin joint.

    Declaration

    Swift

    var rotationSpeed: CGFloat

    Objective-C

    @property(nonatomic) CGFloat rotationSpeed

    Discussion

    The frictionTorque property limits the maximum amount of torque that can be applied to the physics bodies.

    Import Statement

    Objective-C

    @import SpriteKit;

    Swift

    import SpriteKit

    Availability

    Available in iOS 8.0 and later.

  • A Boolean value that indicates whether the pin joint’s rotation is limited to a specific range of values.

    Declaration

    Swift

    var shouldEnableLimits: Bool

    Objective-C

    @property(nonatomic) BOOL shouldEnableLimits

    Discussion

    The default value is NOfalse. If YEStrue, the lowerAngleLimit and upperAngleLimit properties are used to limit the angle of the pin joint.

    Import Statement

    Objective-C

    @import SpriteKit;

    Swift

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

  • The smallest angle allowed for the pin joint, in radians.

    Declaration

    Swift

    var lowerAngleLimit: CGFloat

    Objective-C

    @property(nonatomic) CGFloat lowerAngleLimit

    Discussion

    The default value is 0.0.

    Import Statement

    Objective-C

    @import SpriteKit;

    Swift

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

  • The largest angle allowed for the pin joint, in radians.

    Declaration

    Swift

    var upperAngleLimit: CGFloat

    Objective-C

    @property(nonatomic) CGFloat upperAngleLimit

    Discussion

    The default value is 0.0.

    Import Statement

    Objective-C

    @import SpriteKit;

    Swift

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

  • The resistance applied by the pin joint to spinning around the anchor point.

    Declaration

    Swift

    var frictionTorque: CGFloat

    Objective-C

    @property(nonatomic) CGFloat frictionTorque

    Discussion

    The range of values is from 0.0 to 1.0. The default value is 0.0. If a value greater than the default is specified, friction is applied to reduce the object’s angular velocity around the pin.

    Import Statement

    Objective-C

    @import SpriteKit;

    Swift

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.