【发布时间】:2012-04-02 05:22:35
【问题描述】:
过去 3 天我一直在尝试从 Cocos2D 1.1.0-pre->2.0rc0a 升级,但这是迄今为止我在制作应用程序时遇到的最困难的任务。所以它在 Cocos2D 1.1 中运行良好,我的图像已加载,一切正常,等等......现在在 2.0rc0a 中它只是进入黑屏但我的所有方法都被调用了!
这里有一些关于我正在使用的代码、设备、日志等的信息......
Xcode 版本
1. Xcode version: 4.3.2
测试设备
2. A) Devices: iPhone 4S - 5.0.1 (doesn't work)
B) iPad 3 - 5.1 (doesn't work)
C) iPhone 5.1 simulator (doesn't work)
D) iPad 5.1 simulator (doesn't work)
我的代码
我有一个包含 CCGLView 的 UIViewController 类。然后我有一个 CCLayer 类,它是实际游戏的一切。 CCLayer 类中的代码很好,因为它适用于 Cocos2D 1.1.0-pre,所以我将发布 UIViewController 类的代码:
- (void)viewDidLoad {
[super viewDidLoad];
// Create an CCGLView with a RGB565 color buffer, and a depth buffer of 0-bits
CCGLView *glView = [CCGLView viewWithFrame:[self.view bounds]
pixelFormat:kEAGLColorFormatRGB565 //kEAGLColorFormatRGBA8
depthFormat:0 //GL_DEPTH_COMPONENT24_OES
preserveBackbuffer:NO
sharegroup:nil
multiSampling:NO
numberOfSamples:0];
director_ = (CCDirectorIOS*) [CCDirector sharedDirector];
director_.wantsFullScreenLayout = YES;
[director_ setDisplayStats:YES];
[director_ setAnimationInterval:1.0/60];
[director_ setView:glView];
[director_ setDelegate:self];
[director_ setProjection:kCCDirectorProjection2D];
[director_ setDepthTest:FALSE];
if(![director_ enableRetinaDisplay:YES])
CCLOG(@"Retina Display Not supported");
[CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];
[CCFileUtils setiPhoneRetinaDisplaySuffix:@"@2x"];
[CCFileUtils setiPadSuffix:@"-72"];
[CCFileUtils setiPadRetinaDisplaySuffix:@"@2x~ipad"];
[CCTexture2D PVRImagesHavePremultipliedAlpha:YES];
[director_ pushScene:[CCSceneGame scene]];
}
然后我的 CCLayer 类中有这个基本的 CCScene 方法:
+(CCScene *) scene
{
CCScene *scene = [CCScene node];
CCSceneGame *layer = [CCSceneGame node];
[scene addChild:layer];
return scene;
}
大部分代码也是直接从模板项目复制而来的。我也有在 .h 中声明的代表。
控制台输出
这是我在 5.0.1 iPhone 4S 上测试的控制台:
2012-03-31 17:14:54.484 App[56089:707] cocos2d: OS version: 5.0.1 (0x05000100)
2012-03-31 17:14:54.485 App[56089:707] cocos2d: GL_VENDOR: Imagination Technologies
2012-03-31 17:14:54.486 App[56089:707] cocos2d: GL_RENDERER: PowerVR SGX 543
2012-03-31 17:14:54.486 App[56089:707] cocos2d: GL_VERSION: OpenGL ES 2.0 IMGSGX543-63.14.2
2012-03-31 17:14:54.488 App[56089:707] cocos2d: GL_MAX_TEXTURE_SIZE: 4096
2012-03-31 17:14:54.488 App[56089:707] cocos2d: GL_MAX_TEXTURE_UNITS: 8
2012-03-31 17:14:54.489 App[56089:707] cocos2d: GL_MAX_SAMPLES: 4
2012-03-31 17:14:54.489 App[56089:707] cocos2d: GL supports PVRTC: YES
2012-03-31 17:14:54.490 App[56089:707] cocos2d: GL supports BGRA8888 textures: YES
2012-03-31 17:14:54.490 App[56089:707] cocos2d: GL supports NPOT textures: YES
2012-03-31 17:14:54.491 App[56089:707] cocos2d: GL supports discard_framebuffer: YES
2012-03-31 17:14:54.491 App[56089:707] cocos2d: compiled with Profiling Support: NO
2012-03-31 17:14:54.492 App[56089:707] cocos2d: cocos2d v2.0.0-rc0
2012-03-31 17:14:54.493 App[56089:707] cocos2d: Using Director Type:CCDirectorDisplayLink
2012-03-31 17:14:54.745 App[56089:707] cocos2d: CCTexture2D: Using RGBA888 texture since image has no alpha
2012-03-31 17:14:54.891 App[56089:707] cocos2d: CCTexture2D. Can't create Texture. cgImage is nil
2012-03-31 17:14:54.892 App[56089:707] cocos2d: Couldn't add image:particleTexture.png in CCTextureCache
2012-03-31 17:14:54.999 App[56089:707] cocos2d: animation started with frame interval: 60.00
其他几点
- 我的应用是除了这个视图之外的所有 UIKit
- 我通过执行 [self addSubview:]; 显示 CCGLView 所在的 UIViewController;如果这有什么不同
- 我已经成功导入 Cocos2D 到没有红色文件、没有警告、没有错误、没有弃用的 API 等...
- 我的图像已被修改,因此它具有我在代码中将 CCFileUtils 更改为的后缀。所以它是:@2x、-72 和 @2x~ipad
- 我还检查了界面生成器是否发生了任何奇怪的事情,但没有
如果有人知道发生了什么,请告诉我!!!
谢谢!
【问题讨论】:
标签: objective-c ios cocos2d-iphone