iphone - Score is being over written cocos2d -


The high score is not at all on the screen, so the big problem is that what I will do to keep the score on the screen It does not get crossed and will update the score like a high score.

I have consulted another user two days ago, which seems simple, but when I tried to do this, I did not work. I tried all different types of combinations and some beans. It seems that I need help pointing at an error.

init

  _oldScore = [[NSUserDefaults standard user default] FullCorrect: @ "scores"]; CGSize winSize = [[CCCCetter Shared Director] winSize]; Self.scoreLabel = [CCLabelTTF LabelwithString: @ "" Dimension: CGSizeMake (100, 50) Alignment: UITX AlignmentRight: "Marker Feels" Font Size: 32]; _scoreLabel.position = CCP (winSize.width - _scoreLabel.contentSize.width, _scoreLabel.contentSize.height); _scoreLabel.color = ccc3 (255,0,0); [Self-linked: _scoreLabel z: 1];   

implementation

  if (_score & gt; _oldScore) {{NSUserDefaults standard user default] setInteger: _score forKey: @ "scores"]; [_scoreLabel setstring: [NSString stringWithFormat: @ "score% d", _score]];   

So far it works great, and everything but the old scan will not stay on the screen. I want the player to know what is the high score. The user made a new nsuserdefaults with a different key to store the old scores. Thus, the old score with the highest score will be on the screen.

// save the score in priority

  int highscore = YourGameScore; [[NSUserDefaults Standard User Defaults] Set Object: [NSNumber Number: High Score] for: @ "Score"]; [[NSUserDefaults Standard User Defaults] Synchronize];   

// To get saved value from preferred preference,

  highscore = [[[NSUserDefaults standard user default] objectforekey: @ "score"] Intavela];   

// To set the score value for the ur cocos2d label

  [_ scoreLabel setString: [NSString stringWithFormat: @ "% d", _oldScore ]];    

Comments