Yon*_*kee 1 sprite-kit skspritenode sknode swift
for child in platformGroupNode.children {
CGPoint p = [child.superview convertPoint:child.center toNode:self.view ]
println(p)
}
Run Code Online (Sandbox Code Playgroud)
但是我不确定如何与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")
}
}
Run Code Online (Sandbox Code Playgroud)
您快到了,需要使用的是:
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.
Run Code Online (Sandbox Code Playgroud)
或等效的将是:
let positionInScene = platformGroupNode.convertPoint(child.position, toNode: self)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1747 次 |
| 最近记录: |