I'm developing a game with SpriteKit that can be paused during execution and can be resumed.
But I have a problem with applicationDidEnterBackground
when the home button is pressed while the game is paused because when I resume the game the entities start moving immediately even though the game was paused before.
I cannot find a way to implement applicationDidEnterBackground
and other related method in AppDelegate
since there is no connection between that and my GameScene.swift
I'm actually pausing the entities with the code
entitiesLayerNode.paused = true
gameState = .GamePaused
EDIT:
I want to explicitly pause the entitiesLayerNode
because I have other 'moving' nodes that I want to keep. To the problem is that with the suggestion given below that method pauses everything! I just need to pause that layer.
I think that problem is that I cannot access the entitiesLayerNode
from the View Controller.
I generally use the snippet
let mainScene = scene as GameScene
mainScene.entitiesLayerNode.pause = true
But Xcode gives me an error that scene
is an unresolved identifier.