我正在迈出第一步cocos2d-iphone.
我在用:
CCSpriteFrameCache *frameCache = [CCSpriteFrameCache sharedSpriteFrameCache];
[frameCache addSpriteFramesWithFile:@"textures.plist"];
Run Code Online (Sandbox Code Playgroud)
使用我的zwoptex文件.有了这个集合,我正在CCSprites使用frameCache这样的创建:
[CCSprite spriteWithSpriteFrameName:@"filename.png"];
Run Code Online (Sandbox Code Playgroud)
到现在为止还挺好.现在我正在创建自己的粒子系统,我需要设置纹理.我想从zwoptex读取是有意义的,但我找不到办法做到这一点.我还检查了示例,他们做了类似的事情:
emitter.texture = [[CCTextureCache sharedTextureCache] addImage: @"fire.pvr"];
Run Code Online (Sandbox Code Playgroud)
所以我的问题是:
[[CCTextureCache sharedTextureCache] addImage: @"file"];呢?这是因为它没有被添加两次?编辑:我刚刚在cocos2d的论坛上发布了这个.
我的cocos2d游戏支持视网膜显示有问题.一切都习以为常,但现在我正在进行更新.在此更新中,我只添加了3个新图像(也在高清版本中).我使用的是用zwoptex制作的纹理图册.生成的png是gameart.png和gameart-hd.png.我正在使用以下代码加载文件:
CCSpriteFrameCache* frameCache = [CCSpriteFrameCache sharedSpriteFrameCache];
[frameCache addSpriteFramesWithFile:@"gameart.plist"];
Run Code Online (Sandbox Code Playgroud)
当得到任何精灵我正在使用spriteWithFrameName:方法.以前一切都工作得很好(即使在iPhone 4上),但现在我只在iPhone 4上收到以下错误:
cocos2d: CCSpriteFrameCache: Frame 'tilei.png' not found
*** Assertion failure in -[BoardTile initWithSpriteFrame:]
Run Code Online (Sandbox Code Playgroud)
gameart.png和gameart-hd.png(tilei.png和tilei-hd.png)以及plist文件中都有文件tilei.我重新检查了一千次.怎么可能出错?请注意,错误未显示-hd后缀,即使它仅在iPhone 4上运行时出现.