1

我在 Cocos2D 1.0 中开发游戏(基于学习 Cocos2D 中的教程),并按照官方说明升级到 Cocos2D 2.0,确保删除旧的 cocos2d 库并将其完全替换为新库。

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

屏幕截图(图像保存为纵向,即使模拟器是横向的)

我不太确定在哪里寻找问题(这是我的第一个 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

谢谢你的尽心帮助!

4

1 回答 1

0

我设法通过用 cocos2d 2.0 模板中的新版本替换我的 AppDelegate.m、AppDelegate.h 和 main.m 来解决这个问题。我从 cocos2d 1.0 模板构建了原始项目,并且架构似乎发生了变化,迁移指南没有深入介绍。

One Clean and Build,一切正常。

于 2013-06-16T00:14:02.297 回答