How can you create a bounding box that collides with a circular shape, being this triangular?
How can you create a bounding box that collides with a circular shape, being this triangular?
You need to use one of the polygonal type
let polygonalSpaceShip = SKSpriteNode(texture: spaceShipTexture)
let path = CGMutablePath()
path.addLines(between: [CGPoint(x: 0, y: 0), CGPoint(x: 50, y: 50), CGPoint(x: 0, y: 50),
CGPoint(x: 0, y: 0)]) //son 4 porqué el ultimo vuelve al origen
Example of SKPhysicsBody
Although depending on your sprite you can try using the alpha channel
let texturedSpaceShip = SKSpriteNode(texture: spaceShipTexture)
texturedSpaceShip.physicsBody = SKPhysicsBody(texture: spaceShipTexture,
size: CGSize(width: circularSpaceShip.size.width,
height: circularSpaceShip.size.height))