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 8146967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:11:17+00:00 2026-06-06T14:11:17+00:00

I try having my high score set up where if the high score is

  • 0

I try having my high score set up where if the high score is surpassed it will show up in high score and I have it some what figured out but right now as soon as high score is surpassed it will take the same amount of high score points to go up one point. For example you get one point for each kill, if the high score is 7 points it will take 7 more kills to go up to 8 points on the high score board. The score resets itself again as soon as you get the high score and takes the same amount of points in the highscore to go up once. Hope it makes sense.

here is the code

.h file

 int _score;
    int _oldScore;
   CCLabelTTF *_scoreLabel;
    @property (nonatomic, assign) CCLabelTTF *scoreLabel;

.m file

     _score = [[NSUserDefaults standardUserDefaults] integerForKey:@"score"];           


     _oldScore = -1;
     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];     



    if (_score > _oldScore) {

   _oldScore = _score;

    [_scoreLabel setString:[NSString stringWithFormat:@"score%d", _score]];

    [[NSUserDefaults standardUserDefaults] setInteger:_oldScore forKey:@"score"];

   [[NSUserDefaults standardUserDefaults] synchronize];          


      _score = 0;         

}

  }

Now I know the _score = 0; rested the board but it keep resetting as soon as you get the high score. Another example is if you have 12 points on high score board it will take 24 points worth of killing to go up to 13points on the high score.

One more thing if i take out _score=0; the score will keep stacking but won’t start over.

  • 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-06T14:11:19+00:00Added an answer on June 6, 2026 at 2:11 pm

    I don’t understand these lines:

     _score = [[NSUserDefaults standardUserDefaults] integerForKey:@"score"];           
     _oldScore = -1;
    

    should not [[NSUserDefaults standardUserDefaults] integerForKey:@"score"] be the old score?
    and why do you set _oldScore to be -1?

    maybe I am missing something…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just created an iPhone app and am having friends try it out, but
I am having some luck when i try appending some text to an existing
i am having this problem try to use the cocos2d CCScrollLayer I have added
ok it seems like a simple problem, but i am having problem I have
I'm having difficulty figuring out how to make the jump from a Scala high-order
Compact description I'm having a problem to find out what's wrong, for some obscure
Is there a way to set work offline in TFS without having to try
I'm having some problems trying to figure out how to insert an integer using
Having decided to try AForge for video and imaging stuff, I tried to implement
I try to limit resultset in size without having to change each SQL statement

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.