全て。
私は自分の写真「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: OS バージョン: 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 ソフトウェア レンダラー
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 をサポートしています: はい
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 をサポートしています: はい
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] Retina ディスプレイはサポートされていません
2012-05-03 14:59:10.550 ActionManagerTest[3215:f803] cocos2d: CCTexture2D。テクスチャを作成できません。UIImageはゼロです
2012-05-03 14:59:10.551 ActionManagerTest[3215:f803] cocos2d: deallocing [プロセス 3215 スレッド 0x12f0b に切り替え]
2012-05-03 14:59:10.551 ActionManagerTest[3215:f803] cocos2d: CCTextureCache に image: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' が原因でアプリを終了しています。理由: '引数は非 nil でなければなりません'
* First throw call stack: (0x17de052 0x14ddd0a 0x1786a78 0x1e92db 0xb300 0x4546 0x4adb0e 0x4ae8a6 0x4bd743 0x4be1f8 0x4b1aa9 0x1ed4fa9 0x17b21c5 0x1717022 0x171590a 0x1714db4 0x1714ccb 0x4ae2a7 0x4afa9b 0x2581 0x2505 0x1) terminate called throwing an exception
これが私のコードです:
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];
両方とも墜落した。