Select child 的 child 在 swift 3

Select child's child in swift 3

我想 select 一个 child 的 child 像这样:

var button = childNode(withName: "button") as! SKSpriteNode

SKSpriteNode"alert"里面有SKSpriteNode"button"

选择 child 时使用 childNode(withName: "button"),即 shorthand 因为 self.childNode(withName: "button") 自己是 class 你所在的(或场景)。要调用 object 的 child,请使用...

let alert = self.childNode(withName: "alert") as! SKSpriteNode
var button = alert.childNode(withName: "button") as! SKSpriteNode