SpriteKit y SceneKit: ¿cómo pausar completamente un juego?
Logré pausar un juego de escena con este código:
override func touchesBegan(touches: NSSet!, withEvent event: UIEvent!) {
var touch:UITouch = touches.anyObject() as UITouch
pauseText.text = "Continuer"
pauseText.fontSize = 50
pauseText.position = CGPointMake(self.frame.size.width/2, self.frame.size.height/2)
/* bouton play/pause */
var locationPause: CGPoint = touch.locationInNode(self)
if self.nodeAtPoint(locationPause) == self.pause {
println("pause")
addChild(pauseText)
pause.removeFromParent()
paused = true
}
if self.nodeAtPoint(locationPause) == self.pauseText {
pauseText.removeFromParent()
paused = false
addChild(pause)
}
}
Pero tengo un problema. Todos los intervalos aleatorios del juego crean objetos y los muestran en la pantalla. Cuando detengo el juego, continúa creando objetos en segundo plano y cuando reanudo el juego, todos los objetos creados durante la pausa aparecen al mismo tiempo en la pantalla.
¿Cómo puedo arreglarlo?