如何在 iPhone 的 Cocos2d 层上显示 UIAlertView?
我的游戏中有一个层面。游戏结束时,我想向用户显示用于重新启动或退出游戏的 UIAlertView。但它不起作用。我还获得了委托 UIAlertViewDelegate 到图层。
有什么解决方案吗?
我的代码如下,
-(void)gameFinished{
[[UIApplication sharedApplication] setIdleTimerDisabled:NO];
[self unschedule:@selector(checkForCollision)];
[self unschedule:@selector(dropObject)];
[self stopBackgroundMusic];
[self startNewForegroundMusic:@"GameOver" ofType:@"caf"];
[self playForegroundMusic];
[[Director sharedDirector] pause];
UIAlertView *view=[[UIAlertView alloc] initWithTitle:@"Game Finished" message:@"Want to play again?" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes"];
[view show];
[view release];
}
I have a layer in my game. At finishing of game I want to show user an UIAlertView for restarting or quitting the game. But it is not working. I am also given the delegate UIAlertViewDelegate to layer.
Any Solutions?
My Code follows,
-(void)gameFinished{
[[UIApplication sharedApplication] setIdleTimerDisabled:NO];
[self unschedule:@selector(checkForCollision)];
[self unschedule:@selector(dropObject)];
[self stopBackgroundMusic];
[self startNewForegroundMusic:@"GameOver" ofType:@"caf"];
[self playForegroundMusic];
[[Director sharedDirector] pause];
UIAlertView *view=[[UIAlertView alloc] initWithTitle:@"Game Finished" message:@"Want to play again?" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes"];
[view show];
[view release];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的代码是否崩溃,或者只是不显示?
您在这行中确实有一个小错误,
应该
注意:最后一个参数是变量参数,因此应该以 Nil 终止。
Does your code crash, or does it just not display?
You do have a slight error in the line
This should be
note: the last parameter is variable argument, and thus should be Nil terminated.
尝试在导演暂停之前显示警报视图,这可能会起作用。
Try to show the alertview before the director is pause it may work..