Reputation: 18139
I used the Zwoptex Flash version to generate:
I have checked the files and everything seems to be there alright.
In my game, first I added the .plist file to the cache:
[[CCSpriteFrameCache sharedSpriteFrameCache]addSpriteFramesWithFile:@"ParticleAnimations.plist"];
And then I created my CCSpriteBatchNode:
spriteBatch = [CCSpriteBatchNode batchNodeWithFile:@"ParticleAnimations.png"];
[self addChild:spriteBatch z:0];
And finally create my CCSprite, with the filename of an image found in my textures:
CCSprite *particle = [CCSprite spriteWithSpriteFrameName:@"Particle1.png"];
[spriteBatch addChild:particle z:0];
Now, I run this on the simulator (iPhone), and it runs just fine. Then, I change the Hardware option and set it to "iPhone (retina)", which transforms the simulator on a 960x640 screen. But then, my gane crashes. Within the log, here are these entries:
cocos2d: CCSpriteFrameCache: Trying to use file 'ParticleAnimations.png' as texture
cocos2d: CCSpriteFrameCache: Frame 'Particle1.png' not found
Which I don't quite understand. First of all, why is it using ParticleAnimations.png instead of ParticleAnimations-hd.png, since it is in Retina Display mode? And, of course, why is it looking for Particle1.png instead of Particle1-hd.png?
Upvotes: 3
Views: 3364
Reputation: 7136
To begin have you think to uncomment these lines into you 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");
It'll enable Cocos2d to use the -hd files.
Then your sprite names must be exacty the same into your spritesheets. Just the plist and texture files must have the "-hd" suffix. For example if you have sprites named toto.png, titi.png, tata.png into your spritesheets named mysp it should look like that:
// Normal
- mysp.png
- mysp.plist
|- toto.png
|- titi.png
|- tata.png
// Retina
- mysp-hd.png
- mysp-hd.plist
|- toto.png
|- titi.png
|- tata.png
For more information, you should refer to the official documentation here: RetinaDisplay in cocos2d
I hope it'll help you!
Upvotes: 11