Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I add a Joint to the Scene physicsWorld in SpriteKit

I'm trying to add a joint to the scene physicsWorld property, but I am getting a EXC_BAD_ACCESS. This is the code I'm using.

SKPhysicsJointFixed *fixedJoint = [SKPhysicsJointFixed jointWithBodyA:self.mousePoint.physicsBody bodyB: self.box.physicsBody anchor:touchPoint];

[self.physicsWorld addJoint:fixedJoint]; // Error happens here.

I'm calling it when a touch begins. Does anyone know whats going on?

like image 355
Jadar Avatar asked Jan 25 '14 16:01

Jadar


1 Answers

i encountered the same problem with you, the answer is very easy, just add the node to the scene before adding it to the physicsworld.

like image 155
JohnHanr Avatar answered Sep 28 '22 08:09

JohnHanr