将 Cocos2D 与 UIKit 集成
我环顾四周,发现关于如何将 cocos2d 与 UIKit 集成的材料非常少(注意:不是相反)。我的意思是...例如...在 UIView 中添加 cocos sprite 动画,该动画放置在分割视图控制器内(作为子视图)。我怎样才能做到这一点!
我想从 UISplitView 项目模板或 UITabBar 项目模板开始。
ps 我从事 iPhone 开发已经有一段时间了,但对于 cocos2d 框架我还是个菜鸟。
I've looked around, and i've seen very little material on how to integrate cocos2d with UIKit (note: not the other way around). What i mean is... for example... adding a cocos sprite animation inside a UIView, which is placed inside a split-view controller (as a subview). How can i do that!?
I want to start with a UISplitView project template or the UITabBar project template.
p.s. I've been doing iPhone development for a while now, but i'm a noob when it comes to cocos2d framework.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Cocos2d 中有一个名为
AttachDemo
的演示,它将 Cocos2d 控制器附加到UIView
。如果您检查名为-(void)runCocos2d
的方法。如果您查看其代码,您会发现它执行以下操作:
如您所见,您需要创建一个 EAGLView,为其附加一个控制器,然后只需将该视图添加到视图层次结构中即可。
There's a demo in Cocos2d called
AttachDemo
, where it attaches a Cocos2d director to aUIView
. If you check the method called-(void)runCocos2d
.If you look at its code, it does the following:
As you can see, you need to create a
EAGLView
, attach a director to it, and then simply add that view to the view hierarchy.这是 @pgb 所指的演示的链接,
Here is the link of the demo @pgb is referring to, http://code.google.com/p/cocos2d-iphone/source/browse/trunk/tests/attachDemo/attachDemo.m?r=1682