Pinning the board in chapter 11

Hi!

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 in advance!

I found this post that solved it:

Thanks to darkknightmalta!

2 Likes

Thanks mate! Just what i was looking for.

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.

Oh my god! Thanks, I thought i’m plain stupid

The bug still in the book.

Please update Chapter 10, Challenge 1

Seesaw: Texture ice, Name seesaw, Position (518, 440), Body Type Bounding rectangle, Category Mask 2, Collision Mask 11

to

Seesaw: Texture ice, Name seesaw, Position (518, 440), Body Type Bounding rectangle, Category Mask 2, Collision Mask 3