我正在用 ios 开发一个 cocos2d 游戏。这是应用程序委托的代码:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.homeViewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
self.window.rootViewController = self.homeViewController;
[self.window makeKeyAndVisible];
在这方面,我正在使ViewController
课程成为rootViewController
. 我正在GameOptionsViewController
上课HomeViewController
上课。从GameOptionsViewController
我调用应用程序委托中的方法来添加游戏场景。
-(void)addGameScene
{
CCDirector *director = [CCDirector sharedDirector];
if( ! [CCDirector setDirectorType:kCCDirectorTypeDisplayLink] )
[CCDirector setDirectorType:kCCDirectorTypeMainLoop];
else {
[CCDirector setDirectorType:kCCDirectorTypeDisplayLink];
}
// Init the View Controller
viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
viewController.wantsFullScreenLayout = YES;
if(!glView)
glView = [[EAGLView alloc] initWithFrame:[window bounds]];
[director setOpenGLView:glView];
[director setOpenGLView:glView];
[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];
[viewController setView:glView];
[window setRootViewController:viewController];
[window addSubview: viewController.view];
[window makeKeyAndVisible];
[[CCDirector sharedDirector] runWithScene: [HelloWorldLayer scene]];
}
现在当我想隐藏游戏场景时,我使用代码:
[[CCDirector sharedDirector] stopAnimation];
[[CCDirector sharedDirector].openGLView setHidden:YES];
游戏场景被隐藏了,但是之前的视图,ieGameOptionsViewController
没有显示出来。我做错了什么???..请指教..