2D 非 OpenGL 游戏:ViewControllers
我正在构建一个非常简单的 iOS 游戏,不需要任何 OpenGL
;我想坚持使用 Core Graphics &核心动画。
似乎我需要两种类型的 ViewController:用于在菜单屏幕(即设置、主菜单、级别选择等)之间导航的基本 VC,以及用于管理我所有 UIViews
和 <代码>CALayers。
管理/交换这些视图和视图的好方法是什么?风险投资公司要保持业绩吗?最好的做法是像传统的基于 UINavigationController
的应用程序那样拥有一个 VC 层次结构,并在我显示游戏 VC 时覆盖导航栏吗?或者,当我进入“游戏模式”时,我应该从堆栈中删除所有其他 ViewController,并将其设置为我的 window.rootViewController
属性吗?不断重置 window.rootViewController
有什么替代方案/缺点吗?
我的直觉告诉我后者在资源+性能方面更好,但似乎很严厉。任何建议+方向在这里将不胜感激。
谢谢
I'm building a very simple iOS game that doesn't require any OpenGL
; I'd like to stick with Core Graphics & Core Animation.
It seems as though I need two types of ViewControllers: Basic VCs for navigating between menu screens (ie. Settings, Main Menu, Level Select, etc.), and Gameplay VCs for managing all my UIViews
and CALayers
.
What's a good way to manage/exchange these Views & VCs to preserve performance? Is it best practice to have one hierarchy of VCs like a traditional UINavigationController
-based app, covering the NavBar when I'm displaying a Game VC? Or instead should I be removing all other ViewControllers from the stack when I enter "game mode", and setting it as my window.rootViewController
property? Any alternatives / downsides to continually resetting window.rootViewController
?
My gut tells me the latter is better on resources+performance, but it seems heavy handed. Any advice + direction here would be appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将 Game VC 设置为 rootViewController,并将游戏选择呈现为该控制器之上的模态视图控制器。您无需在应用程序开始时设置动画即可做到这一点。当用户完成设置后,关闭视图控制器。
You can probably make the Game VC the rootViewController, and present the game selection as modal view controller on top of that controller. You can do that without animating at the beginning of the application. When the user is done with the setup, dismiss the view controller.