在 OpenGL ES 视图和 UIKit 视图控制器之间切换
这是我的问题。
我正在使用 OpenGL ES 在 iPhone 上开发游戏。我开始使用 Xcode 模板 OpenGL ES 应用程序进行开发,并使用一个 EAGLView 等。
我的菜单视图和游戏视图使用相同的 OGL 视图,但现在我想添加分数排名,因此我需要一个键盘和一个文本字段来写入名称,以及一些标签或表格视图来显示排名。
更新:嗯,我认为最好的解决方案是将我当前的 glView 与另一个 UIKit 视图一起使用,我将在其中放置分数排名并进行切换。
我有 Apress 的书Beginning iPhone Development,并且我遵循有关多个视图的章节。我注意到在两个 UIViewController 之间切换,但是当我要在游戏中进行更改时... glView 不是 UIViewController,它是 UIView,所以我迷路了。
谁能帮我解决这个问题吗? :-(
非常感谢。
this is my question.
I'm developing a game on iPhone with OpenGL ES. I began my development using the Xcode template OpenGL ES Application, with one EAGLView, etc.
My menu view and game view use the same OGL view but now I want to add score ranking so I need a keyboard and a text field to write name, and some labels or a table view to show ranking.
UPDATE: well, I think that the best solution is to have my current glView with another UIKit View where I will put the score ranking and do the switching.
I have the Apress book Beginning iPhone Development and I follow the chapter about multiple views. I take the point of switching between two UIViewController but when I'm going to make changes in my game... glView is not a UIViewController, it's a UIView, so I'm lost.
Can anyone help me with this? :-(
Thank you very much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
嗯,我想我解决了这个问题,所以我把解决方案分享给你。
我从书中的多个视图示例开始:三个 xib(主窗口和我们切换的两个视图)、应用程序。 delegate,每个视图有两个视图控制器和一个在视图之间切换的根视图控制器。
我将 EAGLView 类和渲染器添加到该项目中,并将 EAGLView 上的 initWithCoder 方法更改为 initWithFrame:
然后,在我的根视图控制器中,当我点击按钮时,我添加了一个 IBAction:
就这样。非常简单而且效果很好。也许它需要一些优化,但这是一个很好的起点。
所以,我现在可以做我的分数排名了:D
Well, I think I solved the problem, so I share the solution with you.
I started from the multiple views example from the book: three xib (main window and two views we switch), the app. delegate, two view controller for each view and a root view controller which switch between our views.
I added the EAGLView class and renderer to this project and changed the initWithCoder method on EAGLView to initWithFrame:
Then, in my root view controller I have added an IBAction when I tap a button:
And that's all. Very simple and it works well. Maybe it needs some optimization but this is a good start point.
So, I can make now my score ranking :D
您只需将普通视图控制器推到 OpenGL 视图(控制器)顶部即可显示分数排名对话框。例如使用
presentModalViewController:animated:
。You can simply push a normal viewcontroller on top of the OpenGL view(controller) to show a dialog for the score ranking. For example with
presentModalViewController:animated:
.