开发者

how to pop a layer in cocos2d

开发者 https://www.devze.com 2023-04-07 13:10 出处:网络
please look the following picture i want to do this function,when i click some button,it pop out a layer

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

精彩评论

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

关注公众号