<legend id='E4Dlp'><style id='E4Dlp'><dir id='E4Dlp'><q id='E4Dlp'></q></dir></style></legend>

      <small id='E4Dlp'></small><noframes id='E4Dlp'>

        <bdo id='E4Dlp'></bdo><ul id='E4Dlp'></ul>

    1. <i id='E4Dlp'><tr id='E4Dlp'><dt id='E4Dlp'><q id='E4Dlp'><span id='E4Dlp'><b id='E4Dlp'><form id='E4Dlp'><ins id='E4Dlp'></ins><ul id='E4Dlp'></ul><sub id='E4Dlp'></sub></form><legend id='E4Dlp'></legend><bdo id='E4Dlp'><pre id='E4Dlp'><center id='E4Dlp'></center></pre></bdo></b><th id='E4Dlp'></th></span></q></dt></tr></i><div id='E4Dlp'><tfoot id='E4Dlp'></tfoot><dl id='E4Dlp'><fieldset id='E4Dlp'></fieldset></dl></div>

      <tfoot id='E4Dlp'></tfoot>
    2. Cocos2D 与 UIKit 的集成

      时间:2024-04-14

      <tfoot id='NjEWD'></tfoot>

            <tbody id='NjEWD'></tbody>
        1. <legend id='NjEWD'><style id='NjEWD'><dir id='NjEWD'><q id='NjEWD'></q></dir></style></legend>
        2. <small id='NjEWD'></small><noframes id='NjEWD'>

          • <bdo id='NjEWD'></bdo><ul id='NjEWD'></ul>

                <i id='NjEWD'><tr id='NjEWD'><dt id='NjEWD'><q id='NjEWD'><span id='NjEWD'><b id='NjEWD'><form id='NjEWD'><ins id='NjEWD'></ins><ul id='NjEWD'></ul><sub id='NjEWD'></sub></form><legend id='NjEWD'></legend><bdo id='NjEWD'><pre id='NjEWD'><center id='NjEWD'></center></pre></bdo></b><th id='NjEWD'></th></span></q></dt></tr></i><div id='NjEWD'><tfoot id='NjEWD'></tfoot><dl id='NjEWD'><fieldset id='NjEWD'></fieldset></dl></div>
                本文介绍了Cocos2D 与 UIKit 的集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我环顾四周,我看到的关于如何将 cocos2d 与 UIKit 集成的材料很少(注意:不是相反).我的意思是……例如……在 UIView 中添加 cocos sprite 动画,该动画放置在拆分视图控制器中(作为子视图).我该怎么做!?

                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!?

                我想从 UISplitView 项目模板或 UITabBar 项目模板开始.

                I want to start with a UISplitView project template or the UITabBar project template.

                附言我做 iPhone 开发已经有一段时间了,但是对于 cocos2d 框架我是个菜鸟.

                p.s. I've been doing iPhone development for a while now, but i'm a noob when it comes to cocos2d framework.

                推荐答案

                在 Cocos2d 中有一个名为 AttachDemo 的 demo,它将一个 Cocos2d 的 director 附加到一个 UIView.如果你检查调用的方法 -(void)runCocos2d.

                There's a demo in Cocos2d called AttachDemo, where it attaches a Cocos2d director to a UIView. If you check the method called -(void)runCocos2d.

                如果您查看它的代码,它会执行以下操作:

                If you look at its code, it does the following:

                -(void) runCocos2d
                {
                    if( state == kStateEnd ) {
                
                        EAGLView *glview = [EAGLView viewWithFrame:CGRectMake(0, 0, 250,350)];
                        [mainView addSubview:glview];
                
                        CCDirector *director = [CCDirector sharedDirector];
                        [director setOpenGLView:glview];
                
                        CCScene *scene = [CCScene node];
                        id node = [LayerExample node];
                        [scene addChild: node];
                
                        [director runWithScene:scene];
                
                        state = kStateRun;
                    }
                    else {
                        NSLog(@"End the view before running it");
                    }
                }
                

                如您所见,您需要创建一个 EAGLView,将一个导向器附加到它,然后将该视图简单地添加到视图层次结构中.

                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.

                这篇关于Cocos2D 与 UIKit 的集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:在 Cocos2d 中使用自定义字体 下一篇:我应该继承 CCSprite、CCNode 还是 NSObject?

                相关文章

                • <bdo id='tSaSo'></bdo><ul id='tSaSo'></ul>
              • <small id='tSaSo'></small><noframes id='tSaSo'>

                  <tfoot id='tSaSo'></tfoot>

                  1. <legend id='tSaSo'><style id='tSaSo'><dir id='tSaSo'><q id='tSaSo'></q></dir></style></legend>
                    <i id='tSaSo'><tr id='tSaSo'><dt id='tSaSo'><q id='tSaSo'><span id='tSaSo'><b id='tSaSo'><form id='tSaSo'><ins id='tSaSo'></ins><ul id='tSaSo'></ul><sub id='tSaSo'></sub></form><legend id='tSaSo'></legend><bdo id='tSaSo'><pre id='tSaSo'><center id='tSaSo'></center></pre></bdo></b><th id='tSaSo'></th></span></q></dt></tr></i><div id='tSaSo'><tfoot id='tSaSo'></tfoot><dl id='tSaSo'><fieldset id='tSaSo'></fieldset></dl></div>