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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:56:15+00:00 2026-05-31T20:56:15+00:00

Once again I need your Help, am thanking you as every time you helped

  • 0

Once again I need your Help, am thanking you as every time you helped me.

I am developing Game in iPhone using ‘COCOS2D’ framework and ‘OBJECTIVE-C’. In my game there is Ten(10) Levels. The LEVEL Label is created and defined in a class ( i:e HudLayer.h, HudLayer.m ) and I am removing LABEL in another class (i:e GameScene.m ), In the game I am using ccLabelBMFont for creating LEVEL label.

Now the Problem is when I am Removing LEVEL label (i:e Level 1) and placing new LEVEL label (i:e Level 2), the code is not removing “Level 1” and placing “Level 2” on the previous LEVEL label (i:e Level 1 ).

Below is my Code for the above same issue, please tell where I am going Wrong :

**Code of HudLayer.h**

#import "Foundation/Foundation.h"
#import "cocos2d.h"
#import "GameScene.h"

@interface HudLayer : CCLayer { 
    CCLabelBMFont * level;
}

@property (nonatomic,retain) CCLabelBMFont * level;
@end

Now code for “HudLayer.m” where I am synthethising and using ‘level’:

#import "HudLayer.h" 
      #import "GameScene.h"

    @implementation HudLayer 

    @synthesize level;
       level = [CCLabelTTF labelWithString:[NSString stringWithFormat:@"Level 1",level] fontName:@"Marker Felt" fontSize:12];
       [level setAnchorPoint:ccp(1,0.5)];
       [level setPosition:ccp(250,470)]; 
       [level setColor:ccORANGE]; 
       [self addChild:level];
     }
     return self;
     }
     - (void) dealloc {
       [super dealloc];
       [lives release];
     } 

    @end

*HERE IS MY CODE FOR "GameScene.h"*

#import "cocos2d.h"
#import "HudLayer.h"
typedef enum {
    Level1, 
    Level2,
    Level3,
    Level4,
    Level5, 
    Level6,
    Level7, 
    Level8,
    Level9, 
    Level10,
} LevelType;

@interface GameLayer : CCLayer
{
int level;
BOOL ifLevel2Started;
    BOOL ifLevel3Started;
    BOOL ifLevel4Started;
    BOOL ifLevel5Started;
    BOOL ifLevel6Started;
    BOOL ifLevel7Started;
    BOOL ifLevel8Started;
    BOOL ifLevel9Started;
    BOOL ifLevel10Started;
}
@property (assign,readwrite) int level;
@end

AND FINALLY I WANT TO REMOVE THE LEVEL label 1 From HudLayer Class and palce new Label with Name “Level 2” on the basis of Score points:

        #import "GameScene.h"
        #import "HudLayer.h"
        @implementation GameLayer
        @synthesize level;

        @synthesize levelType = _levelType;
        if (self.levelType ==  Level1) {
                [self LevelFeatures];
                ifLevel2Started = FALSE;
            }

            if (self.levelType ==  Level2) {
                [self LevelFeatures1];
                ifLevel3Started = FALSE;
            }

            if (self.levelType ==  Level3) {
                [self LevelFeatures2];
                ifLevel4Started = FALSE;
            }

    -(void)LevelFeatures
    {
        HudLayer * hl = (HudLayer *)[self getChildByTag:KHudLayer]; // * HERE I AM DOING MY MAIN STEP, HERE AM CREATING OBJECT OF **"HudLayer" class** *

        hl.level = [CCLabelTTF labelWithString:[NSString stringWithFormat:@"Level 2"]  fontName:@"Marker Felt" fontSize:12];
//**HERE AM SETTING NEW Label FOR LEVEL.**
}

I AM FINDING PROBLEM ONLY ON THE ABOVE LINE OF CODE FOR WHICH I WROTE SO BIG QUERY, SO THAT YOU CAN UNDERSTAND MY PROBLEM EXACTLY.

WHAT I SHOULD WRITE/CODE OVER HERE SO THAT PREVIOUS LABEL COMPLETELY REMOVE AND NEW ONE PLACE OVER IT. (i:e No Overloading of Label happen).


  • 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-31T20:56:16+00:00Added an answer on May 31, 2026 at 8:56 pm

    hmmm , there is a chunk of code missing at the start of your implementation snippet, but I would venture this (with minimal change to your current setup) :

     -(void)LevelFeatures {
         HudLayer * hl = (HudLayer *)[self getChildByTag:KHudLayer];
         [hl removeChild:h1.level cleanup:YES];
         hl.level=[CCLabelTTF labelWithString:[NSString stringWithFormat:@"Level 2"] 
                                     fontName:@"Marker Felt" 
                                     fontSize:12];
         [hl addChild:hl.level];
    }
    

    I am not certain why you are retaining level in HudLayer, but just adding as a child to any CCNode descendant will retain it for you. Also, with this kind of code i tend to use tags to regain access to children I add to a CCNode descendant.

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

Sidebar

Related Questions

once again, i need your help to my kernel module. I have implemented an
I need your help once again, guys i'm struggling with a css dropdown menu
I need your expertise once again. I have a java class that searches a
OK, once again I need help. I have managed to pass a variable in
This time, I need your help in something related to php. My users script
I received some great help here the other day and hope once again I
I need to convert our existing iPhone 3-D action game code to run on
once again I've got a question. Since I am using Google Web Toolkit (GWT)
Once again one of those: Is there an easier built-in way of doing things
Once again a very beginner-ish question, but here I go: I would like to

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.