我是cocos 2d游戏开发的新手,开发了一个游戏,我需要多次从视图控制器重新加载场景。为此,我删除场景并再次运行。场景加载2次或更多次但发生白屏并在控制台中显示错误“OpenGL错误0x0506 in - [EAGLView swapBuffers]”。
这是我添加场景的代码 -
if ([[CCDirector sharedDirector] runningScene] == NULL)
{
if( ! [CCDirector setDirectorType:kCCDirectorTypeDisplayLink] )
[CCDirector setDirectorType:kCCDirectorTypeDefault];
CCDirector *director = [CCDirector sharedDirector];
glView = [EAGLView viewWithFrame:[window bounds]
pixelFormat:kEAGLColorFormatRGBA8
depthFormat:GL_DEPTH_COMPONENT24_OES
preserveBackbuffer:NO
sharegroup:nil
multiSampling:YES
numberOfSamples:4];
[director setOpenGLView:glView];
[director setDeviceOrientation:kCCDeviceOrientationPortrait];
[director setAnimationInterval:1.0/60];
[window addSubview:glView];
[[CCDirector sharedDirector] runWithScene: [HelloWorldLayer node]];
}
和删除场景的代码 -
[[CCDirector sharedDirector].openGLView removeFromSuperview];
[[CCDirector sharedDirector] stopAnimation];
[[CCDirector sharedDirector] end];
[[CCDirector sharedDirector] release];
请帮助我,我不知道问题出在哪里。 谢谢。
答案 0 :(得分:0)
有两点需要注意: