Note that there are some explanatory texts on larger screens.

plurals
  1. PORemoving ccLabelBMFONT And Placing New one at the same palce from another Class
    primarykey
    data
    text
    <p>Once again I need your Help, am thanking you as every time you helped me.</p> <p>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.</p> <p>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 <strong>not removing "Level 1"</strong> and placing "Level 2" on the previous LEVEL label (i:e Level 1 ).</p> <p><strong>Below is my Code for the above same issue, please tell where I am going Wrong :</strong></p> <pre><code>**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 </code></pre> <p><strong>Now code for "HudLayer.m" where I am synthethising and using 'level':</strong></p> <pre><code>#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 </code></pre> <p><em>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:</em></p> <pre><code> #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.** } </code></pre> <p><strong>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.</strong></p> <p>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).</p> <hr>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload