将 SKLabelNode 子类化到当前场景,怎么样?

subclassed SKLabelNode to present scene, how?

我有一个 SKLabelNode 的子类,它被实例化了三四次,每次都有一个名称和一个目的地:

//

import SpriteKit

class MenuButton: SKLabelNode {

    var goesTo = SKScene()

    override init() {
        super.init()
        print("test... did this get called? WTF? HOW/WHY/WHERE?")
    }

    convenience init(text: String, color: SKColor, destination: SKScene){
        self.init()
        self.text = text
        self.color = color

        goesTo = destination
    }

    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        let nextScene = goesTo
       // .....?????????????????
       // HOW DO I GET THIS TO FIND ITS SCENE...
       // THEN ITS VIEW, THEN PRESENT this nextScene????

    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}

我不知道如何获得我需要调用场景更改的视图。

每个SKNode都有一个scene属性returns节点所在的场景

并且每个 SKScene 作为 view 属性,所以

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    let nextScene = goesTo

    self.scene?.view?.presentScene(nextScene)

}