2011-08-24 60 views
3

CCSpriteBatchNode我用Zwoptex Flash版本生成:使用Zwoptex与Cocos2D中对视网膜显示

  • 与-HD后缀(双尺寸图片).png文件纹理文件
  • .png文件纹理文件,而不 - hd后缀(正常大小的图像)
  • 带-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屏幕上转换模拟器。但是,然后,我的基因崩溃。在日志,这里有这些项:

的cocos2d:CCSpriteFrameCache:尝试使用文件 'ParticleAnimations.png' 纹理

的cocos2d:CCSpriteFrameCache:框架 'Particle1.png' 未找到

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

回答

11

要开始有你想取消注释这些行到您的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到您的spritesheets 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 

欲了解更多信息,您应该参考这里的官方文档:RetinaDisplay in cocos2d

我希望它能帮助你!

+1

“那么你的精灵名字必须与你的精灵图片一模一样” - 保存我的屁股,谢谢! –