SpriteKit and SceneKit – How to completely pause a game?

前端 未结 1 1400
予麋鹿
予麋鹿 2020-12-17 03:47

I succeeded to pause a scene game with this code:

override func touchesBegan(touches: NSSet!, withEvent event: UIEvent!) {

    var touch:UITouch = touches.         


        
相关标签:
1条回答
  • 2020-12-17 04:12

    You can't add the SKLabelNode (or anything else) to your scene while the SKView is paused. You will need to return to the run loop so your text is added before pausing the game. Here's one way to do that:

    // Add pause text or button to scene
    addChild(pauseText)
    let pauseAction = SKAction.run {
        self.view?.isPaused = true
    }
    self.run(pauseAction)
    
    0 讨论(0)
提交回复
热议问题