Using the pinned attribute for physicalBody makes it easy to create complex sprites with multiple contact areas. Binding a physical body to a Node Parent:
The default value is NO. If YES, then the position of the node is fixed relative to its parent. The position of a node cannot be changed by actions or physical forces. Node can rotate freely around its position in response to collisions or other forces. If the parent node has a physical body, then the two physical bodies are treated as if they are connected to a pin connection.
Here is the main class of dogs, where the dog has a main body and head. Please note that I set allowsRotation = false so that the head could not move around the body.
import SpriteKit // for readability let mainSize = CGSize(width: 300, height: 300) let headSize = CGSize(width: 100, height: 100) class Dog : SKSpriteNode { let head = SKSpriteNode(color: SKColor.greenColor(), size: headSize) init() { super.init(texture: nil, color: SKColor.redColor(), size: mainSize) head.position = CGPoint(x: mainSize.width - headSize.width, y: 0) addChild(head) } // called after Dog has been added to the scene func configurePhysicsBody() { physicsBody = SKPhysicsBody(circleOfRadius: mainSize.width / 2) physicsBody.dynamic = true physicsBody.allowsRotation = false // set contactBitmask for main body head.physicsBody = SKPhysicsBody(circleOfRadius: headSize.width / 2) head.physicsBody.dynamic = true head.physicsBody.allowsRotation = false // The head is pinned to the parent node, so position is fixed relative to parent head.physicsBody.pinned = true // set contactBitmask for head } }

Jon
source share