cocos2d 自定义对话框,带有是/否选项
截至目前,我只能这样做:
`UIAlertView* dialog = [[UIAlertView alloc] init];
[dialog setDelegate:self];
[dialog setTitle:@"New Game"];
[dialog setMessage:@"Are you sure you want to start a new game? This will overwrite your current game."];
[dialog addButtonWithTitle:@"Yes"];
[dialog addButtonWithTitle:@"No"];
[dialog show];
[dialog release];
...
- (void) alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex==0) {
gametype = 1;
[[CCDirector sharedDirector] replaceScene:[CCTransitionCrossFade transitionWithDuration:1 scene:[GameScene node]]];
}
}
`
糟糕的是,该对话框确实没有与应用程序的整个主题融为一体。
有没有办法可以自定义或创建出现的对话框?
我听说自定义 UIAlertView 一直存在很大争议,甚至被应用商店拒绝。我认为我不应该采用这种方法。您有我可以使用的建议/代码吗?
PS:我有一个对话框图像和是/否按钮已经完成。
As of now, I can only do:
`UIAlertView* dialog = [[UIAlertView alloc] init];
[dialog setDelegate:self];
[dialog setTitle:@"New Game"];
[dialog setMessage:@"Are you sure you want to start a new game? This will overwrite your current game."];
[dialog addButtonWithTitle:@"Yes"];
[dialog addButtonWithTitle:@"No"];
[dialog show];
[dialog release];
...
- (void) alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex==0) {
gametype = 1;
[[CCDirector sharedDirector] replaceScene:[CCTransitionCrossFade transitionWithDuration:1 scene:[GameScene node]]];
}
}
`
The bad thing is that the dialog box really does not mix in with the whole theme of the application.
Is there a way I can customize or create a dialogue box that appears?
I've heard that customizing UIAlertView has been very controversial to the point of being rejected form the app store. I don't think I should go with this method. Do you have any suggestions/code I can use?
PS: I have a dialogue box image and yes/no buttons already done.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您已经有一个对话框和“是/否”按钮,那么我只需将对话框添加到精灵图层中,并将“是/否”按钮覆盖为 CCMenuItemImage。然后,您可以让“否”按钮隐藏菜单和对话框的可见性,让“是”按钮替换场景。
然后,在 noSelector 方法中,您可以隐藏对话框,而在 yesSelector 中,只需替换场景。
If you already have a dialog box and YES/NO buttons, then I would just add the dialog box the the layer a sprite with the YES/NO buttons overlaid as CCMenuItemImage(s). Then you can have the no button just hide the visibility of the menu and the dialog box and the yes button replace the scene.
Then in your noSelector method you can just hide the dialog box and in your yesSelector just replace the scene.