Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8208067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:12:56+00:00 2026-06-07T09:12:56+00:00

The high score isn’t staying on screen at all so the big problem is

  • 0

The high score isn’t staying on screen at all so the big problem is what do I do so the score will stay on screen until it is surpassed and will update score like a high score.

I have taken advice from another user couple days ago that made it seem simple ,but when I tried to do it didn’t work out. I tried pretty much all the different types of combinations and no beans. So looks like I need someones help pointing out the error.

init

 _oldScore = [[NSUserDefaults standardUserDefaults] integerForKey:@"score"]; 
 CGSize winSize = [[CCDirector sharedDirector] winSize];
    self.scoreLabel = [CCLabelTTF labelWithString:@"" dimensions:CGSizeMake(100, 50) alignment:UITextAlignmentRight fontName:@"Marker Felt" fontSize:32];
    _scoreLabel.position = ccp(winSize.width - _scoreLabel.contentSize.width, _scoreLabel.contentSize.height);
    _scoreLabel.color = ccc3(255,0,0);
    [self addChild:_scoreLabel z:1];     

implementation

 if (_score > _oldScore) {
      [[NSUserDefaults standardUserDefaults] setInteger:_score forKey:@"score"];          
       [_scoreLabel setString:[NSString stringWithFormat:@"score%d", _score]];

So far it works great, and everything but the oldscore won’t stay on the screen. I want the player to know what the high score is.
The user said make a new nsuserdefaults with a different key to store old score. So that way old score with the highest score will stay on screen.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T09:12:57+00:00Added an answer on June 7, 2026 at 9:12 am

    // To save score in preference

    int highScore  = yourGameScore;
    [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInt:highScore] forKey:@"score"];
    [[NSUserDefaults standardUserDefaults] synchronize];
    

    // To get saved value from  preference

    highScore = [[[NSUserDefaults standardUserDefaults] objectForKey:@"score"] intValue ];
    

    //To set score value to ur cocos2d label

    [_scoreLabel setString:[NSString stringWithFormat:@"%d", _oldScore]];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this isn't a direct technical problem but this seems like an ideal
I'm trying to create a level select / high-score screen before launching a game.
I'd like to show a player's high score in context with other players' high
Say I have a high score table structured like name score name score ....
I'm specifically trying to create a global high score list and something like this
I try having my high score set up where if the high score is
I want to save an high-score for local use only. A single int, that
I have the following used to create a dummy high score table if if
I have created a game where the user can upload their high score and
I'm wanting a more secure way to store high scores and power ups like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.