【问题标题】:'Application windows are expected to have a root view controller at the end of application launch' In Cocos 2d'应用程序窗口应该在应用程序启动结束时有一个根视图控制器' 在 Cocos 2d 中
【发布时间】:2016-01-21 06:43:37
【问题描述】:

我在运行 Cocos2d 项目时遇到此错误。 我是 Cocos2d 的新手,所以请帮忙解决这个错误。 这个我在 applicationDidFinishLaunching 中的代码。

self.notifyCenter = [NSNotificationCenter defaultCenter];
[notifyCenter addObserver:self selector:@selector(trackNotifications:) name:nil object:nil];

// Init the window
//window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// cocos2d will inherit these values
[window setUserInteractionEnabled:YES]; 
[window setMultipleTouchEnabled:YES];

// Try to use CADisplayLink director
// if it fails (SDK < 3.1) use the default director
if( ! [CCDirector setDirectorType:CCDirectorTypeDisplayLink] )
    [CCDirector setDirectorType:CCDirectorTypeDefault];

// Use RGBA_8888 buffers
// Default is: RGB_565 buffers
[[CCDirector sharedDirector] setPixelFormat:kPixelFormatRGBA8888];

// Create a depth buffer of 16 bits
// Enable it if you are going to use 3D transitions or 3d objects
//  [[CCDirector sharedDirector] setDepthBufferFormat:kDepthBuffer16];

// Default texture format for PNG/BMP/TIFF/JPEG/GIF images
// It can be RGBA8888, RGBA4444, RGB5_A1, RGB565
// You can change anytime.

[Mobclix startWithApplicationId:@"4708dd74-19a6-46c3-a926-81d71012f7bd"];

[CCTexture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_RGBA8888];

// before creating any layer, set the landscape mode
[[CCDirector sharedDirector] setDeviceOrientation:CCDeviceOrientationPortrait];
[[CCDirector sharedDirector] setAnimationInterval:1.0/60];
//[[CCDirector sharedDirector] setDisplayFPS:YES];

// create an openGL view inside a window
[[CCDirector sharedDirector] attachInView:window];  
[window makeKeyAndVisible];     

MainMenu *gs = [MainMenu node];
[[CCDirector sharedDirector] runWithScene:gs];

如果您知道并提前感谢您,请提供帮助

【问题讨论】:

  • 顺便说一句,是cocos2d,不是cocoa2d

标签: ios objective-c cocoa cocos2d-iphone


【解决方案1】:

具体说说错误:

'Application windows are expected to have a root view controller at the end of application launch'

听起来您的应用需要RootViewController

RootViewController *viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
[window setRootViewController:viewController];

【讨论】:

    猜你喜欢
    • 2012-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-23
    • 1970-01-01
    • 2015-12-16
    相关资源
    最近更新 更多