I had the following problem when I tried to encode a clone of unstable birds in Xcode 6 beta 7 using Swift and SpriteKit.
After I added a physics property to SKSpriteNode, I cannot change the physics property directly, for example, I cannot do the following:
bird = SKSpriteNode(texture: birdTexture1) bird.position = CGPoint(x: self.frame.size.width / 2.8, y: CGRectGetMidY(self.frame)) bird.runAction(flight) bird.physicsBody = SKPhysicsBody(circleOfRadius: bird.size.height/2) bird.physicsBody.dynamic = true bird.physicsBody.allowsRotation = false
The Xcode assembly fails with errors in two lines, where I add dynamic and allows Rotation values โโin PhysicsBody, the only way I can do this is to do the following:
bird.physicsBody?.dynamic = true bird.physicsBody?.allowsRotation = false
The question is that body physics is optional with '?' Typically, this complicates the performance of certain operations when trying to manipulate the physics of birds, which I wanted to add, for example, rotation during movement.
Any suggestion on how to avoid / fix the need to flag the PhysicsBody property as optional? ('PhysicsBody?)
Thanks!

(source: tinygrab.com )

(source: tinygrab.com )
source share