SpriteKit:各种父母不可能使用交集?

问题描述 投票:0回答:1

由同一个父母很容易使用交叉点,如下所示:

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

我的问题是节点有不同的父节点。我怎么能在这里得到相同的结果?有人可以帮忙吗?

sprite-kit parent intersection
1个回答
0
投票

您需要将帧从给定的子节点转换为其公共父节点。也许这可以帮助你https://developer.apple.com/documentation/spritekit/sknode/converting_coordinate_spaces

© www.soinside.com 2019 - 2024. All rights reserved.