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

  • Home
  • SEARCH
  • 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 187655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:51:43+00:00 2026-05-11T15:51:43+00:00

I am trying to create a cool score counter in my iPhone game, where

  • 0

I am trying to create a cool score counter in my iPhone game, where I created the digits 0 to 9 in photoshop and I want to update the score every second.

What I am doing now is the following:

  • In my init I load all the digit sprites into an array, so that the array has 10 items.

  • I created a method which breaks down the current score (eg. 2000) into single digits and gets the sprites from the array and after that adds them to a parent CocosNode* object.

  • Every second I get the parent CocosNode by it’s tag and replace it with the new parent object.

Currently I am already running into problems with this, because the score 2000 uses the 0-digit three times and I cannot re-use sprites.

- (CocosNode*) createScoreString:(int) score {     NSLog(@'Creating score string : %d', score);     NSString* scoreString = [NSString stringWithFormat:@'%d', score];      int xAxes = 0;     CocosNode* parentNode = [[Sprite alloc] init];     for (NSInteger index = 0; index < [scoreString length]; index++)     {         NSRange range;         range.length = 1;         range.location = index;          NSString* digit = [scoreString substringWithRange:range];          Sprite* digitSpriteOriginal = [self.digitArray objectAtIndex:[digit intValue]];         Sprite* digitSprite = [digitSpriteOriginal copy];         [digitSprite setPosition:cpv(xAxes, 0)];          xAxes += [digitSprite contentSize].width - 10;          [parentNode addChild:digitSprite];     }     return parentNode; } 

Am I handling this the right way within cocos2d or is there some standard functionality for this? Also, if this is correct, how can I ‘reuse’ the sprites?

  • 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. 2026-05-11T15:51:44+00:00Added an answer on May 11, 2026 at 3:51 pm

    I believe that you want to use the LabelAtlas class, you’ll only need to provide a compatible bitmap (like one the fps counter uses).

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

Sidebar

Related Questions

I'm trying to create a little unit test with gdb, for a embedded mcu
I'm trying to create a ListBox with a decently robust DataTemplate. The problem is,
I am trying to create some ajax with my website, click on navigation and
I'm playing around with NHibernate 3.0. So far things are pretty cool. I'm trying
OK, so I'm trying a to use a cool image loader/gallery I found here
I have been trying to figure out how to integrate a node.js app into
I'm trying to figure out the best way to share an instance of a
I've been doing some reading on how both the git merge and git rebase
Actually I'm using R + Python with RPY2 to manipulate data and ggplot to
This is how I'd like to write markup in say index.html.erb <%= page_for Super

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.