iOS Developer Library

Developer

SpriteKit Framework Reference SKPhysicsJointLimit Class Reference

Options
Deployment Target:

On This Page
Language:

SKPhysicsJointLimit

An SKPhysicsJointLimit object imposes a maximum distance between two physics bodies, as if they were connected by a rope.

Inheritance


Conforms To


Import Statement


Swift

import SpriteKit

Objective-C

@import SpriteKit;

Availability


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

    Declaration

    Swift

    class func jointWithBodyA(_ bodyA: SKPhysicsBody!, bodyB bodyB: SKPhysicsBody!, anchorA anchorA: CGPoint, anchorB anchorB: CGPoint) -> SKPhysicsJointLimit!

    Objective-C

    + (SKPhysicsJointLimit *)jointWithBodyA:(SKPhysicsBody *)bodyA bodyB:(SKPhysicsBody *)bodyB anchorA:(CGPoint)anchorA anchorB:(CGPoint)anchorB

    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.

    anchorA

    A connection point on the first body in the scene’s coordinate system.

    anchorB

    A connection point on the second body in the scene’s coordinate system.

    Return Value

    A new limit 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.

  • maxLength maxLength Property

    The maximum distance allowed between the two physics bodies connected by the limit joint.

    Declaration

    Swift

    var maxLength: CGFloat

    Objective-C

    @property(nonatomic) CGFloat maxLength

    Import Statement

    Objective-C

    @import SpriteKit;

    Swift

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.