Reputation: 222
I am learning SpriteKit, looking the demo application, adventure, I find the SKNode wall have physicsbody, it seems the physicsbody is setup in the SKS file because I searched all the code and find nothing about wall physicsbody setting. all about the physicsbody of wall in code is here:
wallNode.physicsBody!.dynamic = false
wallNode.physicsBody!.categoryBitMask = ColliderType.Wall.rawValue
So I think the way to setup physicsBody of the SKNode is in the SKS file, but in SpriteKit editor, I can't change anyting about the physics body.
Upvotes: 1
Views: 659
Reputation: 3182
To change physics properties in the Editor, you need to follow this way:
Screenshot (how to find "Physics Definition" section):
Upvotes: 0
Reputation: 301
Yes it is in the SpriteKit scene editor for the sks file. Select the node and in the SKNode inspector towards the bottom there is a "Physics Definition" drop down. I had a hard time finding it also.
Upvotes: 3
Reputation: 974
You should look here: https://developer.apple.com/library/mac/documentation/SpriteKit/Reference/SKPhysicsBody_Ref/
To add physics to a node, create and configure an SKPhysicsBody object and then assign it to the physicsBody property of the SKNode object. A physics body must be associated with a node object before you apply forces or impulses to it.
You should modify your wall physicsBody depending on what you want. For example:
// Physics body size
bird.physicsBody = SKPhysicsBody(circleOfRadius: bird.size.height/2)
// Not dynamic
bird.physicsBody.dynamic = false
// Can not rotate
bird.physicsBody.allowsRotation = false
Upvotes: 0