开发者

how to pop a layer in cocos2d

please look the following picture

how to pop a layer in cocos2d

i want to do this function,when i click some button,it pop out a layer

my code is

-(id)init{
if (self = [super init]) {
    CCMenuItem *successbtn = [CCMenuItemImage itemFromNormalImage:@"success.png"
                                                     selectedImage:@"success.png"
                                                            target:self 
                                                          selector:@selector(successgame:)];
    CCMenu *ccMenu = [CCMenu menuWithItems:successbtn, nil];
ccMenu.position=ccp(950,700);
    [self addChild:ccMenu z:1 tag:2];
}
return self;
}

-(void)successgame:(id)sender开发者_如何学Python{
    //how can i write here?
}

so how can i write?


There is two possibilities. Either just add the button when you really want to show it and remove it from the Scenegraph as soon as it is not needed anymore.

Alternatively just make it invisible with the visible-property.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜