I’m looking for the code for pinning the board in challenge1, chapter 11 of 2D iOS & tvOS Games by Tutorials. It doesn’t seem to be presented in the book.
The question has been asked before, according to a Google search. However, when clicking the link I was only returned to the starting page for these forums, not to the post itself. And when searching the forums, I find nothing.
Could someone please direct me to the other post, or show the code?
I tried with the code below, in GameScene, didMoveToView, placed at the end, but couldn’t get it to work properly:
// level 4
if let
seesawNode = childNodeWithName("seesaw"),
seesawBaseNode = childNodeWithName("seesawBase")
{
let seesawJoint = SKPhysicsJointPin.jointWithBodyA(seesawNode.physicsBody!, bodyB: seesawBaseNode.physicsBody!, anchor: seesawBaseNode.position)
physicsWorld.addJoint(seesawJoint)
}
Thanks, I was banging my head against the wall. What is interesting is that even with an incorrect collision mask, when I checked the Pinned option in the Physics Definition section from the Attributes Inspector, it worked.