sprite sheet not working for retina display-Collection of common programming errors
I have create a sprite sheet
for non retina display
and its working fine on simulator.. I have used the code
-(Void)addSprites{
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"image.plist"];
CCSpriteBatchNode *spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"image.png"];
[self addChild:spriteSheet];
// Load up the frames of our animation
NSMutableArray *walkAnimFrames = [NSMutableArray array];
for(int i = 1; i < 5; i++) {
[walkAnimFrames addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"image%d.png", i]]];
}
CCAnimation *walkAnim = [CCAnimation animationWithSpriteFrames:walkAnimFrames delay:0.20f];
// Create a sprite for our bear
background = [CCSprite spriteWithSpriteFrameName:@"image1.png"];
background.position = ccp(280, 175);
self.walkAction = [CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:walkAnim]];
[spriteSheet addChild:background];
}
-(void)startAnimation{
[background runAction:_walkAction];
}
And for for device i have created sprite sheet with retina image with double size and image named like image@2x..
the created plist
is myplist@2xplist
and image file is [email protected]
I mean there are 4 files
for non retina display.
1) imagefile.png(sprite sheet)
2) myPlist.plist
for Retina display.
1) [email protected](sprite sheet)
the plist key name for every image is also like [email protected]
but the above code is not working for this code. m i doing something wrong or missing somthing? my app crash on device with error message
CCSpriteFrameCache: Frame 'image1.png' not found
2013-05-03 16:19:49.764 *** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
but the above code is working fine on simulator