I'm using Sprite Kit (iOS), but whenever I try to add a SKPhysicsJointLimit
to the physicsWorld
, the app crashes with EXC_BAD_ACCESS (code=1, address=0xc0)
. Other joint types work fine, which is what's confusing me. Here's an example of what crashes:
var node1 = SKSpriteNode(color: SKColor.blueColor(), size: CGSize(width: 50, height: 50))
node1.physicsBody = SKPhysicsBody(rectangleOfSize: CGSize(width: 50, height: 50))
self.addChild(node1)
var node2 = SKSpriteNode(color: SKColor.blueColor(), size: CGSize(width: 50, height: 50))
node2.physicsBody = SKPhysicsBody(rectangleOfSize: CGSize(width: 50, height: 50))
self.addChild(node2)
var joint = SKPhysicsJointLimit()
joint.maxLength = 1000
joint.bodyA = node1.physicsBody
joint.bodyB = node2.physicsBody
self.physicsWorld.addJoint(joint)
When I replace SKPhysicsJointLimit()
with SKPhysicsJointFixed()
(and remove the line setting maxLength
) or some other joint type, the code works as expected.
I'm new to Sprite Kit, any ideas on how to solve this?