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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:17:18+00:00 2026-06-05T15:17:18+00:00

I am unsure on which approach will give me a better performance: I have

  • 0

I am unsure on which approach will give me a better performance:

I have a GameScene class in which I tend to allocate a objects and then add them as childs to the class with a tag. This approach is used in many examples I studied but I am not sure if it is the best when I need to frequently access to child objects (e.g. update a score label in the GameScene). In those cases I am wondering if it would be a better approach in terms of performance to declare a pointer to those frequently used object and use it to access the object instead of getting the child by tag.

Is it more efficient to use getChildByTag or accessing those objects via their pointer?

As example I provide a label that I frequently update during the game, e.g. it could be the score label:

@interface GameScene : CCLayer 
{
    CCLabelTTF *frequentlyUsedLabel;
}

//Implementation

-(id) initWithId:(int)sceneId
{
    if ((self = [super init]))
    {
        //..code
        frequentlyUsedLabel = [CCLabelTTF labelWithString:@"Hearths:" fontName:@"Arial" fontSize:20];
        [self addChild:frequentlyUsedLabel]; 
        }
}
  • 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-05T15:17:19+00:00Added an answer on June 5, 2026 at 3:17 pm
    1. Write code that is easy to maintain.
    2. Anything worth optimizing is worth measuring.

    Time how long it takes to render a frame using both methods. Ask yourself if it matters.

    The extra memory overhead is a little more difficult to measure (in particular, Cocos2D might be using a clever allocator that is more efficient if your CCLayer subclass doesn’t declare any extra ivars). My take is that 4 bytes is the amount of memory used by a single pixel.

    With UIKit, I personally find it much easier to use ivars than to worry about tag uniqueness (especially when reusing code in different apps or using a view in multiple places). This is especially the case with ARC, since you no longer have to worry about getters/setters/retain/release.

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

Sidebar

Related Questions

I'm new to MVC and am unsure about proper design. I have class objects
I am unsure about which monitoring framework to use. Currently I am looking at
I'm currently redesigning a old application of mine. I'm unsure in which form to
All considerations about when to use which aside, I am still unsure about pointer
Unsure about static variables. import java.io.File; public class Logger { public static final File
I have a question about implementing OnClickListeners for developing with the ADT. I'm unsure
I have a piece of javascript executing on a jetty server which is sending
I am creating an object server-side which is to have all of the data
I have an area which gets populated with about 100 records from a php
I have a scenario which is as follows:- A form containing 2 grids. The

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.