我发现如果你想在 Sprite Kit 中使用物理,你必须在世界坐标中指定 anchor 。假设您有一个大节点树,这里有一辆汽车,那里有一个轮子。您只知道它们在父节点中的坐标。您想要在汽车和车轮之间定义一个 Spring 接头,但您必须告诉 Sprite Kit 场景坐标空间中的 anchor 。
那么你如何将汽车上的 Spring anchor 和车轮中心的 Spring anchor 转换为世界坐标?
UIKit 中有convertPoint:toWindow:
等转换方法。
你如何在 Sprite Kit 中做到这一点?
最佳答案
您应该能够使用 SKNode convertPoint:toNode :.
[wheelNode convertPoint:CGPointMake(0,0) toNode:carNode];
[carNode convertPoint:CGPointMake(0,0) toNode:treeNode];
类似的东西......
关于ios - 如何将一个 SKNode 的坐标转换为另一个 SKNode?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20746299/