如何在游戏中创建中断画面?

发布于 2024-10-06 19:40:54 字数 521 浏览 3 评论 0原文

在游戏中,我发现如果 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猫弦 2024-10-13 19:40:54

无论您如何称呼此类屏幕,您都应该执行以下操作:

  1. 在 Stack Overflow 上接受您之前问题的一些答案。
  2. 暂停你的游戏。
  3. 通过编程方式或从 NIB 文件加载来创建您想要显示的 UIView
  4. 通过调用 -addSubview: 来呈现它。 (可选)使用 UIView 动画方法将其动画到位。

Regardless of what you call such a screen, you should do this:

  1. Accept some of the answers to your previous questions here on Stack Overflow.
  2. Pause your game.
  3. Create a UIView that you want to show, either programmatically or by loading it from a NIB file.
  4. Present it by calling -addSubview:. Optionally, animate it into position with the UIView animation methods.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文