NickyNick321
NickyNick321

Reputation: 223

How to display score in different scene

I'm making a game and I have a function that calculates the score and displays it on the screen. When the game ends it transitions into a new scene, (game over screen). I was wondering what method I can use to display my score on the second scene after it transitions. My code is:

var score = 0
var scoreLabel = SKLabelNode()

func updateScore() {

    score++
    scoreLabel.text = String(score)
}

Upvotes: 0

Views: 167

Answers (1)

Seth Rodgers
Seth Rodgers

Reputation: 69

When initializing the scene that you are going to change to, you can pass the value. You will need to make an int for the score in the next scene, and can say nextScene.score = score

Upvotes: 1

Related Questions