Game Development Reference
In-Depth Information
Listing 15-7 . Setting Up the Director in AppDelegate.m
- (BOOL)application:(UIApplication *)application ←
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
self.viewController = [[ViewController alloc] ←
initWithNibName:@"ViewController_iPhone" bundle:nil];
} else {
self.viewController = [[ViewController alloc] ←
initWithNibName:@"ViewController_iPad" bundle:nil];
}
// initialize cocos2d director
CCDirectorIOS* director = (CCDirectorIOS*)[CCDirector sharedDirector];
director.wantsFullScreenLayout = NO;
director.projection = kCCDirectorProjection2D;
director.animationInterval = 1.0 / 60.0;
director.displayStats = YES;
[director enableRetinaDisplay:YES];
// find the CCGLView in the xib view
NSArray* subviews = self.viewController.view.subviews;
for (int i = 0; i < subviews.count; i++)
{
UIView* subview = [subviews objectAtIndex:i];
if ([subview isKindOfClass:[CCGLView class]])
{
director.view = (CCGLView*)subview;
break;
}
}
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
 
Search Nedrilad ::




Custom Search