iOS Developer Library

Developer

SpriteKit Framework Reference SKPhysicsJointSpring Class Reference

Options
Deployment Target:

On This Page
Language:

SKPhysicsJointSpring

An SKPhysicsJointSpring object simulates connecting two physics bodies together with a spring. The farther the two objects move from each other, the more force is applied to bring the two bodies back together.

Inheritance


Conforms To


Import Statement


import SpriteKit @import SpriteKit;

Availability


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

    Declaration

    Swift

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

    Objective-C

    + (SKPhysicsJointSpring *)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

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

    anchorB

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

    Return Value

    A new spring joint.

    Discussion

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

    Import Statement

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

  • damping damping Property

    A constant that defines how the spring’s motion should be damped due to the forces of friction.

    Declaration

    Swift

    var damping: CGFloat

    Objective-C

    @property(nonatomic) CGFloat damping

    Discussion

    The default value is 0.0.

    Import Statement

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

  • frequency frequency Property

    A constant that defines the frequency characteristics of the spring.

    Declaration

    Swift

    var frequency: CGFloat

    Objective-C

    @property(nonatomic) CGFloat frequency

    Discussion

    The default value is 0.0.

    Import Statement

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.