how to close layer that showed in other layer in cocos2d-iphone

Posted by yegomo on Stack Overflow See other posts from Stack Overflow or by yegomo
Published on 2013-10-20T15:02:32Z Indexed on 2013/10/20 21:54 UTC
Read the original article Hit count: 187

Filed under:
|
|

I have one layer called alayer, and there is a button called abutton, when click the button, another layer called blayer will show in alayer, not replaceScene, please look at the following code,

alayer.m

-(void)abuttonclicked:(id)sender
{
  blayer *blayer = [blayer node];
  blayer.position = ccp(1,1);
  [self addChild:blayer];
}

blayer.m has a button called bbutton and string value called bstring, I want to click the b button, it will close blayer (remove blayer from alayer), and pass the string value bstring to alayer, please look at following code,

 -(void)bbuttonclicked:(id)sender
 {
  // how can do here to close its self(remove its self from alayer), and pass the bstring to alayer?
 }

thanks.

ps. I can use NSUserDefault to pass the string value, but I think it's a bad way to do this, is there another way to pass value?

© Stack Overflow or respective owner

Related posts about cocos2d-iphone

Related posts about cclayer