In my game, I want a game over label to appear when the screen is touched during the red light animation. The red light animation is on when the green light animation is off. I want the game screen to pause and the game over label to appear when the player touches the screen during the red light animation. I have this so far, but the app crashes when I try to run it.
Error Message:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Attemped to add a SKNode which already has a parent: name:'(null)' text:'Game Over! Tap to Play Again' fontName:'Helvetica' position:{1024, 768}'
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
/* Called when a touch begins */
if gameOverLabel.parent == nil
{
self.addChild(gameOverLabel)
}
println(score)
scoreLabel.text = "\(score)"
}
removeFromParentat some point. - Matthias BauchgameOverLabel? - rakeshbs