Search code examples
sprite-kitparentintersection

SpriteKit: Using intersection by various parents impossible?


It is easy to use intersection by the same parents, like so:

 if a.frame.intersects(b.frame) {
         print ("yes!")
 } else {
         print ("no!")
 }

My problem is that nodes have different parents. How could I get the same result here? Could someone help?


Solution

  • you need to convert frame from given child nodes to its common parent. Maybe this can helps you https://developer.apple.com/documentation/spritekit/sknode/converting_coordinate_spaces.