I am creating SKShapeNodes in my program using this:
let points = [CGPoint(x: x, y: y), CGPoint(x: x2, y: y2)]
let line = SKShapeNode(points: &points, count: points.count)
The problem that I am having is that whenever I add a physicsBody to the line, the physicsBody is not aligned with the line. I realise that the issue is because the line's position is always CGPoint(x: 0, y: 0) so the physicsBody is always in the centre of the screen regardless of where the line is. Here is my code for creating the physicsBody:
line.physicsBody = SKPhysicsBody(rectangleOf: (line.frame.size))
If anyone knows how to align the physicsBody to the line, then please reply with your solution. Thanks!