如何获得 child 精灵在视图中的位置

How to get a child sprite position in the view

我正在尝试根据答案 here and this

获取 child 精灵在视图中的位置
for child in platformGroupNode.children {
    CGPoint p = [child.superview convertPoint:child.center toNode:self.view ]
    println(p)
}

但是我不确定如何将它与 SKSpriteNode Children 和 SKNode Parents.

一起使用

我也试过,但没有成功

for child in platformGroupNode.children {
    var pos = child.position
    var viewPos = convertPoint(pos, toNode: self.parent!)
    if viewPos.x < 0 {
        println("Out of screen")
    }
}

大功告成,您需要使用的是:

let positionInScene = self.convertPoint(child.position, fromNode: platformGroupNode)
// self in this case is your SKScene, you don't need self here but, IMO, it 
// makes it easier to understand what's converting what.

或者等效的是:

let positionInScene = platformGroupNode.convertPoint(child.position, toNode: self)