如何在cocos2d中弹出图层
请看下面的图片
我想要执行此功能,当我单击某个按钮时,它会弹出一个 层
我的代码
-(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{
//how can i write here?
}
是这样的我该怎么写?
please look the following picture
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{
//how can i write here?
}
so how can i write?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有两种可能性。要么在您真正想要显示按钮时添加该按钮,然后在不再需要时立即将其从场景图中删除。
或者,只需使用visible-property使其不可见。
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.