How to pause or stop a game with a set of sprites when a user enters the background or receives a call

When a user enters a background (double-click button) or receives a call, the game continues in the background. Consequently, the score increases as they continue to play. I need to know how to pause or stop the game when they enter the background or receive a call. My app is in Quick 3, Xcode 8.

+4
source share
3 answers

In AppDelegate.swift, Xcode sets the method by default applicationWillResignActive. This is what you should see if you have not edited or deleted the method:

func applicationWillResignActive(_ application: UIApplication) {
    // ...
}

From the Xcode template ...

, . (, SMS-) . , . .

, , , , . , .

, !

+1

, . / gamescene. , AppDelegate:

class GameScene: SKScene {

  static var sharedInstance = GameScene()

  override func didMove(to view: SKView) {
    sharedInstance = self
  }
}

AppDelegate :

GameScene.sharedInstance.isPaused = true // or false
+1

applicationWillResignActive:

, OpenGL ES. . .

( ), , . , . , .

, , , . AppDelegate. GameScene (, node , , ...)

. , . , , .

0

Source: https://habr.com/ru/post/1684411/


All Articles