Iphone 带有是/否选项的cocos2d自定义对话框

Iphone 带有是/否选项的cocos2d自定义对话框,iphone,objective-c,cocos2d-iphone,uialertview,Iphone,Objective C,Cocos2d Iphone,Uialertview,到目前为止,我只能做到: `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 addButtonW

到目前为止,我只能做到:

`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:我已经有了一个对话框图像和是/否按钮。

如果您已经有了一个对话框和是/否按钮,那么我只需将对话框添加到图层a精灵中,是/否按钮叠加为CCMenuItemImage。然后,可以使用“否”按钮隐藏菜单和对话框的可见性,并使用“是”按钮替换场景

dialogBox = [CCSprite spriteWithFile:@"dialogBox.png"];
CCMenuItemImage *yesButton = [CCMenuItemImage itemFromNormalImage:@"yes.png" selectedImage:@"yes.png" target:self selector:@selector(yesSelector)]
CCMenuItemImage *noButton = [CCMenuItemImage itemFromNormalImage:@"no.png" selectedImage:@"no.png" target:self selector:@selector(noSelector)]

然后,在noSelector方法中,您可以只隐藏对话框,在yesSelector中,只替换场景。

您的意思是只将其添加为一个层吗?嗯,我以前没试过。。。我该怎么做?@kazuo检查编辑以开始…您可以将其添加为图层或精灵,只需将对话框添加为精灵可能会更容易。接下来的问题是:这样做时,对话框后面的其他内容是否仍然可以单击?我希望其他所有东西都被遮住并禁用,以便将全部注意力集中在盒子上。:)@如果你想要的话,最好只添加一层。你可以只添加一个灰色的CCLayerColor,并带有一点不透明度。我假设您正在为按钮使用菜单项,这样您就可以将那里的touchEnabled属性设置为与[Main menu setIsTouchEnabled:no]类似;
dialogBox = [CCSprite spriteWithFile:@"dialogBox.png"];
CCMenuItemImage *yesButton = [CCMenuItemImage itemFromNormalImage:@"yes.png" selectedImage:@"yes.png" target:self selector:@selector(yesSelector)]
CCMenuItemImage *noButton = [CCMenuItemImage itemFromNormalImage:@"no.png" selectedImage:@"no.png" target:self selector:@selector(noSelector)]