我正在使用 Cocos2D 2.0 为 iPad 开发。
我有这些行:
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"atlas.plist"];
CCSpriteBatchNode *batchNode = [CCSpriteBatchNode batchNodeWithFile:@"atlas.png"];
[self addChild:batchNode];
CCSprite *mySprite = [CCSprite spriteWithFrameName:@"white.png"];
它因此错误而惨遭失败:
Cocos2d: CCSpriteFrameCache: Frame 'white.png' not found * Assertion failure in -[CCSprite initWithSpriteFrame:], /Users/myUser/Documents/MyApp/MyApp/libs/cocos2d/CCSprite.m:212**
我已经使用 TexturePacker 生成了 plist。TexturePacker 创建了 4 个文件:atlas-ipadhd.plis、atlas-ipadhd.png、atlas.plist 和 atlas.png。
white-ipadhd.png 是 2x2 白色图片。white.png 是 1x1 白色图片。
这是atlas-ipadhd的内容
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>frames</key>
<dict>
<key>white-ipadhd.png</key>
<dict>
<key>frame</key>
<string>{{162,2},{2,2}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{2,2}}</string>
<key>sourceSize</key>
<string>{2,2}</string>
</dict>
<key>bgNormal-ipadhd.png</key>
<dict>
<key>frame</key>
<string>{{2,2},{348,78}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{348,78}}</string>
<key>sourceSize</key>
<string>{348,78}</string>
</dict>
<key>bgPressed-ipadhd.png</key>
<dict>
<key>frame</key>
<string>{{82,2},{348,78}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{348,78}}</string>
<key>sourceSize</key>
<string>{348,78}</string>
</dict>
</dict>
<key>metadata</key>
<dict>
<key>format</key>
<integer>2</integer>
<key>realTextureFileName</key>
<string>atlas-ipadhd.png</string>
<key>size</key>
<string>{256,512}</string>
<key>smartupdate</key>
<string>$TexturePacker:SmartUpdate:f709325b7d140d102cd10dd90ef475b0$</string>
<key>textureFileName</key>
<string>atlas-ipadhd.png</string>
</dict>
</dict>
</plist>
这是 atlas.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>frames</key>
<dict>
<key>white.png</key>
<dict>
<key>frame</key>
<string>{{84,2},{1,1}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{1,1}}</string>
<key>sourceSize</key>
<string>{1,1}</string>
</dict>
<key>bgNormal.png</key>
<dict>
<key>frame</key>
<string>{{2,2},{174,39}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{174,39}}</string>
<key>sourceSize</key>
<string>{174,39}</string>
</dict>
<key>bgPressed.png</key>
<dict>
<key>frame</key>
<string>{{43,2},{174,39}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<true/>
<key>sourceColorRect</key>
<string>{{0,0},{174,39}}</string>
<key>sourceSize</key>
<string>{174,39}</string>
</dict>
</dict>
<key>metadata</key>
<dict>
<key>format</key>
<integer>2</integer>
<key>realTextureFileName</key>
<string>atlas.png</string>
<key>size</key>
<string>{128,256}</string>
<key>smartupdate</key>
<string>$TexturePacker:SmartUpdate:c3c8dd4637d116b049a6b55c8ad175d0$</string>
<key>textureFileName</key>
<string>atlas.png</string>
</dict>
</dict>
</plist>
这是 atlas-ipadhd.png 和 atlas.png
看了几个小时后,我找不到这些文件有什么问题……但它仍然会发生灾难性的崩溃。
任何线索?谢谢。