更新时间:2023-02-01 20:00:20
要获得 SKNode
的视觉位置,您需要转换它的 .position
在其 .parent
的坐标系中到其 .scene
的坐标系:
To get an SKNode
's visual position, you'd want to convert its .position
in its .parent
's coordinate system to its .scene
's coordinate system:
CGPoint vPos = [node.parent convertPoint:node.position toNode:node.scene];
看起来您的第一次尝试 ([_board convertPoint:p toNode:self]
) 应该可以工作,只要:
It looks like the first attempt you made ([_board convertPoint:p toNode:self]
) should work, as long as:
p
是您在 _board
坐标系中查找的节点内的有效点.SKScene
调用该代码,以便 self
引用节点所在的场景.p
is a valid point inside the node you're looking for in _board
's coordinate system.SKScene
so that self
references the scene the node is in.