Cocos2D 2.0 in Uikit ( OpenGL ) issue



我遇到了一个大问题,我找不到任何解决方案,所以这就是为什么我寻求帮助。

我正在做一个包含多个小应用程序的项目,其中大多数是在UIKit中制作的,大多数是在openGL ES 1.0/1.1(不确定)的帮助下制作的。我必须开发一些需要碰撞检测和动画的游戏,所以我认为cocos2d可以很好地解决这个问题。

我设法导入cocos2d 2.0并使其功能,从菜单中选择游戏将启动导演和cocos2d场景,当我想退出它时,我调用[_director end],它会回到菜单,这也是在openGL ES中制作的。

问题是,有时,它发生大多是随机的,我得到一个0x500 GL错误在导演端调用,导致菜单变成白色,但仍然响应触摸。

这是我试图解决这个问题的第三天。以下是我的尝试:由于cocos2d 2.0使用的是open GL ES 2.0,而我的菜单是GL ES 1.0,我认为两者之间存在冲突,所以我使用了cocos2d 1。X,但这会带来更多问题,而且当cocos2d场景出现在屏幕上时,菜单的glview会暂停。

  • 我也得到这些错误当我启用cocos2d_debug每次cocos2d启动。

    cocos2d:表面尺寸:0x0

    cocos2d: make complete framebuffer object失败0x0

我真的尝试了所有我能在网上找到的东西。

下面是我用来运行/关闭cocos2d的代码

// start cocos2d
    _director = (CCDirectorIOS*)[CCDirector sharedDirector];
    CCGLView *glView = [CCGLView viewWithFrame:CGRectMake(0, 0, 320, 480)
                                     pixelFormat:kEAGLColorFormatRGBA8
                                     depthFormat:0 /* GL_DEPTH_COMPONENT24_OES */               
                              preserveBackbuffer:NO                                             
                                      sharegroup:nil                                                
                                   multiSampling:NO                                         
                                 numberOfSamples:0
   [_director setView:glView];
   [_director setDelegate:self];
   [[_delegate glViewAccess] addSubview:glView]; // the glviewacces is the app menu select view

//stop cocos2d
   [_director end];
   // this call restarts the app menu select view update and draw functions and 
   // releases the current instance of the object used to start cocos2d, 
   // releasing the cocos2d scene as well
   [_delegate unloadApplication]; 

首先,不要混合OpenGL v1.1和2.0代码。小猫死去。

第二,不要调用[director end] -真的没有必要每次都完全关闭cocos2d,而是简单地运行stopAnimationstartAnimation来暂停和恢复cocos2d。调用end并没有经过很好的测试,如果你这样做了,可能会出现许多问题。

如果这不能解决问题,发布你如何设置&在你的应用程序中关闭cocos2d以获得更多帮助

最新更新