0
votes

I have created a circle using SKShapeNode.

I then try to check if a second node intersects the SKShapeNode above.

However, I am getting intersects = true even when my second node is still outside of the circle itself.

Here is the code that I used to initialise the SKShapeNode:

let background = SKShapeNode(circleOfRadius = 330)
background.position = CGPoint(x: size.width * 0.5, y: size.height * 0.5)
background.fillColor = UIColor(red:0.57, green:0.57, blue:0.57, alpha:0.6)
background.strokeColor = .red//UIColor(red:0.57, green:0.57, blue:0.57, alpha:0.6)
addChild(background)
1
SKShapeNode is known to be buggy and have problems. You should avoid using it wherever possible. - TheValyreanGroup
what does "intersects = true" mean, you need to actually show this code - Knight0fDragon

1 Answers

0
votes

I assume you are using the SKNode().intersects method.

The Apple documentation says

The two nodes are considered to intersect if their frames intersect.

The frame is a bounding box around your circular SKShapeNode, which is why the intersects method returns true even though the node does not intersect the circle itself.