【发布时间】:2012-05-03 03:01:53
【问题描述】:
全部。
我将我的图片“Icon2222.png”添加到我的项目中,并将图片名称从“grossini.png”(原始)更改为“Icon2222.png”,
但是当我运行该项目时,它因名为 NSInternalInconsistencyException 的异常而崩溃,并提示我“无法创建纹理。UIImage 为 nil”。
我在哪里做错了?我只是换了一张图片。
提前致谢。
2012-05-03 14:59:10.480 ActionManagerTest[3215:f803] cocos2d: cocos2d v1.0.1
2012-05-03 14:59:10.481 ActionManagerTest[3215:f803] cocos2d:使用导演类型:CCDirectorDisplayLink
2012-05-03 14:59:10.529 ActionManagerTest[3215:f803] cocos2d:操作系统版本:5.0 (0x05000000)
2012-05-03 14:59:10.529 ActionManagerTest[3215:f803] cocos2d: GL_VENDOR: Apple Computer, Inc.
2012-05-03 14:59:10.530 ActionManagerTest[3215:f803] cocos2d: GL_RENDERER: Apple Software Renderer
2012-05-03 14:59:10.531 ActionManagerTest[3215:f803] cocos2d: GL_VERSION: OpenGL ES-CM 1.1 APPLE
2012-05-03 14:59:10.531 ActionManagerTest[3215:f803] cocos2d: GL_MAX_TEXTURE_SIZE: 4096
2012-05-03 14:59:10.532 ActionManagerTest[3215:f803] cocos2d: GL_MAX_MODELVIEW_STACK_DEPTH: 16
2012-05-03 14:59:10.532 ActionManagerTest[3215:f803] cocos2d: GL_MAX_SAMPLES: 4
2012-05-03 14:59:10.533 ActionManagerTest[3215:f803] cocos2d: GL 支持 PVRTC: YES
2012-05-03 14:59:10.533 ActionManagerTest[3215:f803] cocos2d:GL 支持 BGRA8888 纹理:是
2012-05-03 14:59:10.534 ActionManagerTest[3215:f803] cocos2d:GL 支持 NPOT 纹理:是
2012-05-03 14:59:10.535 ActionManagerTest[3215:f803] cocos2d: GL 支持discard_framebuffer: YES
2012-05-03 14:59:10.535 ActionManagerTest[3215:f803] cocos2d:编译时支持 NPOT:否
2012-05-03 14:59:10.536 ActionManagerTest[3215:f803] cocos2d:在 TextureAtlas 中使用 VBO 支持编译:是
2012-05-03 14:59:10.536 ActionManagerTest[3215:f803] cocos2d:在 CCNode 中使用仿射矩阵变换编译:是
2012-05-03 14:59:10.537 ActionManagerTest[3215:f803] cocos2d:使用分析支持编译:否
2012-05-03 14:59:10.549 ActionManagerTest[3215:f803] 不支持视网膜显示
2012-05-03 14:59:10.550 ActionManagerTest[3215:f803] cocos2d: CCTexture2D。无法创建纹理。 UIImage 为零
2012-05-03 14:59:10.551 ActionManagerTest[3215:f803] cocos2d:解除分配 [切换到进程3215线程0x12f0b]
2012-05-03 14:59:10.551 ActionManagerTest[3215:f803] cocos2d:无法在 CCTextureCache 中添加图片:Icon2222.png
2012-05-03 14:59:10.559 ActionManagerTest[3215:f803] cocos2d: 解除分配
2012-05-03 14:59:10.559 ActionManagerTest[3215:f803] * -[CCLayer addChild:],/Users/qusean/Downloads/cocos2d-iphone-1.0 中的断言失败。 1/cocos2d/CCNode.m:413
2012-05-03 14:59:10.561 ActionManagerTest[3215:f803] * 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“参数必须为非零”
* 首先抛出调用栈: (0x17de052 0x14ddd0a 0x1786a78 0x1e92db 0xb300 0x4546 0x4adb0e 0x4ae8a6 0x4bd743 0x4be1f8 0x4b1aa9 0x1ed4fa9 0x17b21c5 0x1717022 0x171590a 0x1714db4 0x1714ccb 0x4ae2a7 0x4afa9b 0x2581 0x2505 0x1) 终止称为抛出异常
这是我的代码:
1
CCSprite *child = [CCSprite spriteWithFile:@"Icon2222.png"];
[child setPosition:ccp(200,200)];
[layer addChild:child];
2
CGSize winSize = [[CCDirector sharedDirector] winSize];
CCSprite *player = [CCSprite spriteWithFile:@"Icon2222.png"
rect:CGRectMake(0, 0, 27, 40)];
player.position = ccp(player.contentSize.width/2, winSize.height/2);
[layer addChild:player];
他们都崩溃了。
【问题讨论】:
-
不要做假设,阅读控制台日志。这是一个不同的图像,没有找到。提示:它以“图标”开头。
-
我用另一张图片再试了一次,但还是失败了,这就是为什么名称不同的原因,“image1.png”和“Icon2222.png”,但它们都不起作用。
标签: cocos2d-iphone