-
(void)startView
{
if (sManManViewController)
{
CCLOG(“ManManViewController had been created!”);
return;
}//主window
UIWindow* window = [UIApplication sharedApplication].delegate.window;cocos2d::Application *app = cocos2d::Application::getInstance();
app->initGLContextAttrs();
cocos2d::GLViewImpl::convertAttrs();// Add the view controller’s view to the window and display.
//window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
CCEAGLView eaglView = [CCEAGLView viewWithFrame: [window bounds]
pixelFormat: (NSString)cocos2d::GLViewImpl::_pixelFormat
depthFormat: cocos2d::GLViewImpl::_depthFormat
preserveBackbuffer: NO
sharegroup: nil
multiSampling: NO
numberOfSamples: 0 ];[eaglView setMultipleTouchEnabled:YES];
// Use RootViewController manage CCEAGLView
sManManViewController = [[ManManViewController alloc] initWithNibName:nil bundle:nil];
sManManViewController.wantsFullScreenLayout = YES;
sManManViewController.view = eaglView;FImagePicker::getInstance()->setViewController(sManManViewController);
FEaseSdkManager::getInstance()->setViewController(sManManViewController);
QrCodeScanning::getInstance()->setViewController(sManManViewController);// Set RootViewController to window
// if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
// {
// // warning: addSubView doesn’t work on iOS6
// [window addSubview: viewController.view];
// }
// else
// {
// // use this method on ios6
// [window setRootViewController:viewController];
// }[window addSubview: sManManViewController.view];
// [window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES];
// IMPORTANT: Setting the GLView should be done after creating the RootViewController
cocos2d::GLView *glview = cocos2d::GLViewImpl::createWithEAGLView(eaglView);
cocos2d::Director::getInstance()->setOpenGLView(glview);app->run();
//创建ManManAppController
sManManAppController = [[ManManAppController alloc] init];
} -
(void)endView
{
if (sManManViewController)
{
cocos2d::Director::getInstance()->end();
cocos2d::Application::getInstance()->stop();[sManManViewController.view removeFromSuperview]; [sManManViewController release]; sManManViewController = nil; [sManManAppController release]; sManManAppController = nil;
}
}
我调用startView进入cocos,然后再调用endView退出,接着在调用startView进入的话会报错CCRenderer.cpp restoreRenderState 170,有没有大牛给解决下问题?