Apple Game Frameworks and Technologies: Collision Detection, PhysicsBody alignment

Title: Apple Game Frameworks and Technologies: Collision Detection page 84

Hi everyone,

In the code, I changed the coordinates of the foreground node in the image assets to be lower down on the screen. I did this by editing the y coordinate of the foreground node to as follows;

foreground.position = CGPoint(x: 0, y: frame.minY - frame.maxY / 8)

I’m not too sure to as to how to make a new SKPhysicsBody for this node so that it is the same shape as the foreground node and not offset. I’ve tried putting in this;

foreground.physicsBody = SKPhysicsBody(rectangleOf: self.size, center: CGPoint(x: 0, y: self.yScale / 8))

Solved.