如何在游戏中创建中断画面?
在游戏中,我发现如果 iPhone 玩游戏期间出现中断,就会出现某种弹出视图(上面有用于暂停、保存和退出的按钮)。
1)如何创建它并在代码中调用它?
我已经在网络、文档、论坛等上搜索了几周,但仍然找不到解决方案。我能找到的只是一些接近的东西 - 教程展示了如何实现第二个视图,该视图是通过按主视图上的按钮来调用的,但这不是我需要的。
2)这种观点叫什么?我确信它不叫启动屏幕。它被称为“中断屏幕、暂停屏幕还是设置屏幕?
3)以下方法只能在 UIViewController 类中实现,以使用按钮调出第二个视图(这不是我想要的),并且我的游戏正在使用自定义的 UIView 和它无法调用该方法。
-(void)goToSecondView{
[自我呈现ModalViewController:第二个ViewController动画:是];
}
)我得到了使用@protocol的建议,但它对我来说有点难以理解。有一些简单的方法可以做到这一点吗?
In games, I see there are some kind of popup view will appear (on which have buttons for pausing, saving and quitting) if there is an interruption during game play in iphone.
1) How to create it and invoke such in code?
I have been searching for weeks on web, the documentation, forum, etc and still couldn't find the solution. All I can find are only something close - Tutorials show how to implement a 2nd view which is invoked by pressing a button on main view but that is not what I need.
2) What does that kind of view is called? For sure I know it is not called splash, opening screen. Is it called "interrupt screen, pausing screen or setting screen?
3) The following method can only be implemented in UIViewController class to bring up the 2nd view using a button (that is not what I want) and my game is using customized UIView and it can't invoke the method.
-(void)goToSecondView{
[self presentModalViewController:secondViewController animated:YES];
}
4) I got an advice using @protocol but it is a bit advanced for me to understand. Is there some easy way to do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无论您如何称呼此类屏幕,您都应该执行以下操作:
UIView
。-addSubview:
来呈现它。 (可选)使用UIView
动画方法将其动画到位。Regardless of what you call such a screen, you should do this:
UIView
that you want to show, either programmatically or by loading it from a NIB file.-addSubview:
. Optionally, animate it into position with theUIView
animation methods.