0

i'm working with cocos2d on iPad and i'm using ccviewcontroller class to help integrate UIKit and cocos2d. I've set up a storyboard and have an initial view controller and i'm using this code to set up the CCGLView:

CCGLView *glView = [CCGLView viewWithFrame:[[[UIApplication sharedApplication] keyWindow] bounds]
                                   pixelFormat:kEAGLColorFormatRGB565
                                   depthFormat:0
                            preserveBackbuffer:NO
                                    sharegroup:nil
                                 multiSampling:NO
                               numberOfSamples:0]; 

but for some reason the keyWindow bounds returns 0 and the keyWindow is nil. I'm not sure why this is happening. I have the project using storyboards and have an initial view controller set so i'm kinda stumped. Any help would be great! Thanks!

4

2 回答 2

1

使用情节提要,您需要应用程序委托上的窗口属性,并且启动机制会为您创建和设置该对象。

于 2013-10-14T18:34:58.587 回答
0

用这个和 njoy 替换你的代码。

UIWindow *keyWindow = [[[UIApplication sharedApplication] delegate] window];
于 2015-10-03T17:36:21.317 回答