我想选择这样一个孩子的孩子:
var button = childNode(withName: "button") as! SKSpriteNode
在SKSpriteNode
“警报内”有SKSpriteNode
“按钮”
答案 0 :(得分:1)
在选择孩子时使用childNode(withName: "button")
,这是self.childNode(withName: "button")
自我的简写,无论你在哪个班级(或场景)。要调用对象的子项,请使用...
let alert = self.childNode(withName: "alert") as! SKSpriteNode
var button = alert.childNode(withName: "button") as! SKSpriteNode