Swift multiple level scenes

前端 未结 1 1861
被撕碎了的回忆
被撕碎了的回忆 2021-01-16 12:11

I am trying to work on a new game project where I will include multiple levels. I was reading this question (Sprite Kit - Defining the variables for multiple scenes) about t

相关标签:
1条回答
  • 2021-01-16 13:03

    You can override functions of baseScene in level1Scene, you just need to make sure you call the super version of the method. Here are a few examples, in your level1Scene class:

    override func didMoveToView(view: SKView) {
        super.didMoveToView(view) // Calls `didMoveToView` of `baseScene`.
    
        // Additional setup needed for `level1Scene`...
    } 
    
    override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
        super.touchesBegan(touches, withEvent: event) // Calls `touchesBegan` of `baseScene`.
    
        // Additional stuff you want to do in `level1Scene`...
    }
    
    0 讨论(0)
提交回复
热议问题