Reputation: 407
In my program, I need to check if two non-dynamic nodes contact or contain each other on update to remove one. I am aware that you cannot test for contact when both nodes are not dynamic. These local variable nodes are created within a method so I have to use the node's .name property to check them with each other. Is there a way to test for contact or if they contain each other on update?
Upvotes: 0
Views: 111
Reputation: 8134
Yes.
Each node has a frame which is a CGRect
. There are various methods that are callable on a CGRect such as intersects
and contains
which will tell you if two CGRects overlap or if one contains the other:
https://developer.apple.com/documentation/coregraphics/cgrect/1454747-intersects
https://developer.apple.com/documentation/coregraphics/cgrect/1454186-contains
Upvotes: 1