SKPhysicsJoint Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/SpriteKit.framework
Availability
Available in iOS 7.0 and later.
Companion guide
Declared in
SKPhysicsJoint.h

Overview

An SKPhysicsJoint object connects two physics bodies together so that they are simulated together by the physics world. You never instantiate objects of this class directly; instead, you instantiate one of the subclasses that defines the kind of joint you want to make. This class implements the common properties of the joint classes provided by Sprite Kit.

Table 1 describes the kinds of joints you can create in Sprite Kit.

Table 1  Joint classes implemented in Sprite Kit

Class Name

Description

SKPhysicsJointFixed

A fixed joint fuses the two bodies together at a reference point. Fixed joints are useful for creating complex shapes that can be broken apart later.

SKPhysicsJointSliding

A sliding joint allows the two bodies to slide along a chosen axis.

SKPhysicsJointSpring

A spring joint connects the two bodies with a spring whose length is the initial distance between the two bodies.

SKPhysicsJointLimit

A limit joint imposes a maximum distance between the two bodies, as if they were connected by a rope.

SKPhysicsJointPin

A pin joint allows the two bodies to independently rotate around the anchor point as if pinned together.

To use a physics joint, you follow these steps:

  1. Create two physics bodies.

  2. Attach the physics bodies to a pair of SKNode objects in the scene.

  3. Create a joint object using one of the subclasses listed in Table 1.

  4. If necessary, configure the joint object’s properties.

  5. Add the joint to the scene by calling the scene SKPhysicsWorld object’s addJoint: method.

Tasks

Inspecting Joint Properties

Properties

bodyA

The first body connected by the joint.

@property(retain, nonatomic) SKPhysicsBody *bodyA
Availability
  • Available in iOS 7.0 and later.
Declared In
SKPhysicsJoint.h

bodyB

The second body connected by the joint.

@property(retain, nonatomic) SKPhysicsBody *bodyB
Availability
  • Available in iOS 7.0 and later.
Declared In
SKPhysicsJoint.h