ho riuscito a mettere in pausa un gioco di scena con questo codice:Come mettere in pausa completamente un gioco? SpriteKit/SceneKit [SWIFT]
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)
}
}
Ma ho un problema. A intervalli casuali il gioco crea oggetti e li visualizza sullo schermo. Quando metto in pausa il gioco, continua a creare oggetti in background e quando riprendo il gioco tutti gli oggetti creati durante la pausa appaiono nello stesso tempo sullo schermo.
Come posso risolvere il problema?
Imposta scene.view.paused = vero o falso per mettere in pausa/riprendere la partita. – 0x141E
Grazie! Funziona ma l'etichetta pauseText non appare. Come posso fare? – Haox