Reputation: 1472
I can set physics definition at GameScene.sks file:
But how can I change these physics definition parameters (body type, allows rotation, category mask,...) in code programmatically ?
Upvotes: 2
Views: 720
Reputation: 16827
This is real simple, just create a new instance of SKPhysicsBody with whatever type you want, set the properties the way you want it, and then assign a node.
See https://developer.apple.com/reference/spritekit/skphysicsbody for more details.
let physicsBody = SKPhysicsBody(....type)
physicsBody.(someSetting1)
physicsBody.(someSetting2)
physicsBody.(someSetting3)
node.physicsBody = physicsBody
Upvotes: 4