升级到Cocos2D 2.0后出现黑屏和乱码fps计数器

时间:2013-06-14 17:11:40

标签: cocos2d-iphone

我正在开发Cocos2D 1.0中的游戏(基于Learning Cocos2D中的教程),并按照官方指示here升级到Cocos2D 2.0,确保删除旧的cocos2d库并完全替换它用新的。

代码没有产生任何错误,但在显示Cocos2D启动图像后,它给了我一个带有乱码图像的黑屏,其中帧速率计数器曾经是。

Screenshot(图像保存为纵向,即使模拟器处于横向状态)

我不太确定在哪里寻找问题(这是我的第一个Cocos2D项目),所以我将从AppDelegate.m中的一些代码和一些相应的调试器输出开始。

代码:

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

// Init the window
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

CCDirector *director = [CCDirector sharedDirector];

// Init the View Controller
viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
viewController.wantsFullScreenLayout = YES;

//
// Create the CCGLView manually
//  1. Create a RGB565 format. Alternative: RGBA8
//  2. depth format of 0 bit. Use 16 or 24 bit for 3d effects, like CCPageTurnTransition
//
//
CCGLView *glView = [CCGLView viewWithFrame:[window bounds]
                               pixelFormat:kEAGLColorFormatRGB565   // kEAGLColorFormatRGBA8
                               depthFormat:0                        // GL_DEPTH_COMPONENT16_OES
                    ];

// attach the openglView to the director
[director setView:glView];
[director setAnimationInterval:1.0/60];
[director setDisplayStats:YES];


// make the OpenGLView a child of the view controller
[viewController setView:glView];

//Required in iOS6, recommended in 4 and 5
[window setRootViewController:viewController];

// make the View Controller a child of the main window, needed for iOS 4 and 5
[window addSubview: viewController.view];

[window makeKeyAndVisible];

// Default texture format for PNG/BMP/TIFF/JPEG/GIF images
// It can be RGBA8888, RGBA4444, RGB5_A1, RGB565
// You can change anytime.
[CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];


// Removes the startup flicker
//[self removeStartupFlicker];

// Run the intro Scene
[[CCDirector sharedDirector] pushScene: [Level1Scene node]];

return YES;
}

调试器:

2013-06-14 12:46:01.181 CocosGame[25610:207] cocos2d: cocos2d v2.0.0
2013-06-14 12:46:01.184 CocosGame[25610:207] cocos2d: Using Director Type:CCDirectorDisplayLink
2013-06-14 12:46:06.964 CocosGame[25610:207] cocos2d: OS version: 5.0 (0x05000000)
2013-06-14 12:46:06.965 CocosGame[25610:207] cocos2d: GL_VENDOR:   Apple Computer, Inc.
2013-06-14 12:46:06.966 CocosGame[25610:207] cocos2d: GL_RENDERER: Apple Software Renderer
2013-06-14 12:46:06.966 CocosGame[25610:207] cocos2d: GL_VERSION:  OpenGL ES 2.0 APPLE
2013-06-14 12:46:06.968 CocosGame[25610:207] cocos2d: GL_MAX_TEXTURE_SIZE: 4096
2013-06-14 12:46:06.968 CocosGame[25610:207] cocos2d: GL_MAX_TEXTURE_UNITS: 8
2013-06-14 12:46:06.969 CocosGame[25610:207] cocos2d: GL_MAX_SAMPLES: 4
2013-06-14 12:46:06.970 CocosGame[25610:207] cocos2d: GL supports PVRTC: YES
2013-06-14 12:46:06.970 CocosGame[25610:207] cocos2d: GL supports BGRA8888 textures: YES
2013-06-14 12:46:06.971 CocosGame[25610:207] cocos2d: GL supports NPOT textures: YES
2013-06-14 12:46:06.972 CocosGame[25610:207] cocos2d: GL supports discard_framebuffer: YES
2013-06-14 12:46:06.972 CocosGame[25610:207] cocos2d: GL supports shareable VAO: NO
2013-06-14 12:46:06.973 CocosGame[25610:207] cocos2d: compiled with Profiling Support: NO
[Switching to process 25610 thread 0x1e0f]
[Switching to process 25610 thread 0x207]
2013-06-14 12:50:38.990 CocosGame[25610:207] cocos2d: surface size: 480x320

感谢您提供的任何帮助!

1 个答案:

答案 0 :(得分:0)

我设法通过用cocos2d 2.0模板中的新版本替换我的AppDelegate.m,AppDelegate.h和main.m来解决这个问题。我从cocos2d 1.0模板构建了原始项目,并且该体系结构似乎已经改变了迁移指南未深入介绍的方式。

One Clean and Build,事情正在按计划进行。