Cocos2d iphone 将Zwoptex与Cocos2d';视网膜显示器上的CCSpriteBatchNode

Cocos2d iphone 将Zwoptex与Cocos2d';视网膜显示器上的CCSpriteBatchNode,cocos2d-iphone,Cocos2d Iphone,我使用Zwoptex闪存版本生成: 带有-hd后缀的.png纹理文件(双尺寸图像) 不带-hd后缀的.png纹理文件(正常大小的图像) 后缀为-hd的.plist文件 后缀为-hd的.plist文件 我检查了文件,一切似乎都很好 在我的游戏中,首先我将.plist文件添加到缓存中: [[CCSpriteFrameCache sharedSpriteFrameCache]addSpriteFramesWithFile:@"ParticleAnimations.plist"]; 然后我创建了我

我使用Zwoptex闪存版本生成:

  • 带有-hd后缀的.png纹理文件(双尺寸图像)
  • 不带-hd后缀的.png纹理文件(正常大小的图像)
  • 后缀为-hd的.plist文件
  • 后缀为-hd的.plist文件
我检查了文件,一切似乎都很好

在我的游戏中,首先我将.plist文件添加到缓存中:

[[CCSpriteFrameCache sharedSpriteFrameCache]addSpriteFramesWithFile:@"ParticleAnimations.plist"];
然后我创建了我的CCSpriteBatchNode:

spriteBatch = [CCSpriteBatchNode batchNodeWithFile:@"ParticleAnimations.png"];
[self addChild:spriteBatch z:0];
最后使用“我的纹理”中的图像文件名创建我的CCSprite:

CCSprite *particle = [CCSprite spriteWithSpriteFrameName:@"Particle1.png"];
[spriteBatch addChild:particle z:0];
现在,我在模拟器(iPhone)上运行它,它运行得很好。 然后,我更改硬件选项并将其设置为“iPhone(视网膜)”,这将在960x640屏幕上转换模拟器。但后来,我的gane崩溃了。在日志中,有以下条目:

cocos2d:CCSpriteFrameCache:尝试将文件'ParticleAnimations.png'用作纹理

cocos2d:CCSpriteFrameCache:Frame'Particle1.png'未找到


我不太明白。首先,为什么它使用ParticleAnimations.png而不是ParticleAnimations-hd.png,因为它处于视网膜显示模式?当然,为什么要寻找Particle1.png而不是Particle1 hd.png?

首先,您是否考虑将这些行取消注释到appdelegate中:

// Enables High Res mode (Retina Display) on iPhone 4 and maintains low res on all other devices
    if( ! [director enableRetinaDisplay:YES] )
        CCLOG(@"Retina Display Not supported");
它将使Cocos2d能够使用-hd文件


那么你的精灵名字必须和你的精灵表上的名字完全一样。仅plist和纹理文件必须具有“-hd”后缀。例如,如果您将名为toto.png、titi.png、tata.png的精灵放入名为mysp的精灵表中,它应该如下所示:

// Normal
- mysp.png
- mysp.plist
  |- toto.png
  |- titi.png
  |- tata.png

// Retina
- mysp-hd.png
- mysp-hd.plist
  |- toto.png
  |- titi.png
  |- tata.png
有关更多信息,请参阅此处的官方文档:


我希望它能帮助你

“那么你的精灵名字在你的精灵表上一定是完全一样的”-救了我的命,谢谢!