I am making my first game with SpriteKit and the physical bodies of enemy aliens (subclass SKSpriteNode), which I used:
self.physicsBody = SKPhysicsBody(circleOfRadius: self.size.width/2)
this worked as most aliens are round in shape. However, if I had ellipses or square aliens, what would be the best method for designing their physical bodies? I tried this for a square shape:
let squarePath = UIBezierPath(rect: CGRect(x: -64, y: -64, width: 128, height: 128))
self.physicsBody = SKPhysicsBody(polygonFromPath: squarePath.CGPath)
but I don’t know if this is the most effective, nor do I know how to accurately create ellipses. Any suggestions would be great!
source
share