Im trying to pass my Score from GameScene to GameOverScene
.
I just want to set the text of the label in the GameOverScene
with my variable Score that I passed to it.
I am using this:
SKView *spriteView = (SKView *) self.view;
SKScene *currentScene = [spriteView scene];
GameOverScene *gameOverScene = [GameOverScene sceneWithSize:self.frame.size];
[gameOverScene.userData setObject:[currentScene.userData objectForKey:@"score"] forKey:@"score"];
[self.view presentScene:gameOverScene transition:[SKTransition doorsCloseHorizontalWithDuration:1]]; // animation
How do I access the score variable now in my GameOverScene?
Thanks for any answers.
EDIT:
Okay I have a variable int Score; . How do I connect the objectForKey@"score"
to this variable?
EDIT2:
[score setText:[NSString stringWithFormat:@"Score: %@", [self.userData valueForKey:@"score"]]];
With that I get Score: (null)