I am developing a cocos2d game in ios.
This is the code for app delegate :
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.homeViewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
self.window.rootViewController = self.homeViewController;
[self.window makeKeyAndVisible];
In this I am making the ViewController class the rootViewController.
And I am presenting GameOptionsViewController class from HomeViewController class.
From GameOptionsViewController I am calling the method in app delegate to add the game scene.
-(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]];
}
Now when i want to hide the game scene, i use the code:
[[CCDirector sharedDirector] stopAnimation];
[[CCDirector sharedDirector].openGLView setHidden:YES];
The game scene is hidden, but the previous view, i.e GameOptionsViewController does not show up.
What I am doing wrong??.. Please advice..
here you set the RootViewController with viewController like that..
as it just set your
GameOptionsViewControllerclass object as a rootViewController..For Ex.
i hope this help you…