Once the game is over, we have to display GameOver! to the player and add a button so that the player can go back to the main menu.
In the GameOver
function, add a label called myLabel
after we called the function to stop all the actions:
let myLabel = SKLabelNode(fontNamed:"Chalkduster") myLabel.text = "GameOver!" myLabel.fontSize = 65 myLabel.position = CGPoint(x: viewSize.width * 0.5, y: viewSize.height * 0.65) self.addChild(myLabel)
We add the GameOver! text of font size 65
so that it is easily visible to the player and place it slightly above the center of the screen to make space for the main menu button that we will be adding next.