for child in platformGroupNode.children {
CGPoint p = [child.superview convertPoint:child.center toNode:self.view ]
println(p)
}
但我不确定如何在SKSpriteNode
儿童和SKNode
家长处使用此功能。
我也试过这个没有运气
for child in platformGroupNode.children {
var pos = child.position
var viewPos = convertPoint(pos, toNode: self.parent!)
if viewPos.x < 0 {
println("Out of screen")
}
}
答案 0 :(得分:5)
你快到了,你需要使用的是:
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)