iOS Developer Library

Developer

SpriteKit Framework Reference SKPhysicsJointSliding Class Reference

Options
Deployment Target:

On This Page
Language:

SKPhysicsJointSliding

An SKPhysicsJointSliding object allows the anchor points of the two physics bodies to slide along a chosen axis. The joint can be configured to limit the distance that the two objects are allowed to slide along the axis.

Inheritance


Conforms To


Import Statement


Swift

import SpriteKit

Objective-C

@import SpriteKit;

Availability


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

    Declaration

    Swift

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

    Objective-C

    + (SKPhysicsJointSliding *)jointWithBodyA:(SKPhysicsBody *)bodyA bodyB:(SKPhysicsBody *)bodyB anchor:(CGPoint)anchor axis:(CGVector)axis

    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 anchor point for the connection in the scene’s coordinate system.

    axis

    A vector that defines the direction that the joint is allowed to slide.

    Return Value

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

  • A Boolean value that indicates whether the sliding joint is restricted so that the objects may only slide a finite distance from the initial anchor point.

    Declaration

    Swift

    var shouldEnableLimits: Bool

    Objective-C

    @property(nonatomic) BOOL shouldEnableLimits

    Discussion

    The default value is NOfalse. If YEStrue, then the lowerDistanceLimit and upperDistanceLimit properties are used to limit the distance of the sliding joint.

    Import Statement

    Objective-C

    @import SpriteKit;

    Swift

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

  • The smallest distance allowed for the sliding joint.

    Declaration

    Swift

    var lowerDistanceLimit: CGFloat

    Objective-C

    @property(nonatomic) CGFloat lowerDistanceLimit

    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 distance allowed for the sliding joint.

    Declaration

    Swift

    var upperDistanceLimit: CGFloat

    Objective-C

    @property(nonatomic) CGFloat upperDistanceLimit

    Discussion

    The default value is 0.0.

    Import Statement

    Objective-C

    @import SpriteKit;

    Swift

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.