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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:07:50+00:00 2026-05-31T01:07:50+00:00

This is pretty simple question, but I’m having really hard time with it. I

  • 0

This is pretty simple question, but I’m having really hard time with it.

I have made a method which takes int variable. With it, it would need to use it to do action with CCSprite.

For example I call it with this: [_hud hideThisActionLed:2]; and it should then hide CCSprite named actionLed2.

I can’t pass the actual CCSprite to the method, because I call it from another class which don’t have access to that particular sprite.

I can make the sprite name with this: [NSString stringWithFormat:@"actionLed%d", actionLedNumber], but can’t come up with a way to use that to point to that specified CCSprite.

Here’s how I declared the sprites in hud class:

actionLed1 = [CCSprite spriteWithFrameName:@"actionLed1.png" setScale:TRUE resetAnchor:TRUE];
[actionLed1 setOpacity:0];
[self addChild: actionLed1 z:11 tag:1];

That x4 for all 4 leds.

  • 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-05-31T01:07:51+00:00Added an answer on May 31, 2026 at 1:07 am

    This depends on how can access the different leds.

    If they are properties inside your class, then you can access them like this:

    NSString *actionLedName = [NSString stringWithFormat:@"actionLed%d", actionLedNumber];
    CCSprite *actionLed = [self valueForKey:actionLedName];
    

    If they are stored in an array, then you can access them like this:

    CCSprite *actionLed = [self.actionLeds objectAtIndex:actionLedNumber];
    

    If you have set up a tag for each actionLed when adding it, then you can access them like this:

    CCSprite *actionLed = [self getChildByTag:actionLedNumber];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think this is a pretty simple question but I'm having trouble finding the
This is a pretty simple question really, but let's say I'm creating a model
This seems like a pretty simple question, but I have not managed to find
This might be a pretty simple question, but if there really is a difference,
This might be a pretty simple question but I'm a Crystal Reports newbie...I have
This is a pretty simple question, but I have been unable to find anyway
Pretty simple question but I'm having a rough morning it seems. I have the
Pretty simple question this time around. I have an application that communicates with another
This is a pretty simple question but I'm somewhat stumped. I am capturing sections
I'm pretty sure this is a simple question in regards to formatting but here's

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.