ios6 - sprite sheet not working for retina display -
i have create sprite sheet non retina display , working fine on simulator.. have used code
-(void)addsprites{ [[ccspriteframecache sharedspriteframecache] addspriteframeswithfile:@"image.plist"]; ccspritebatchnode *spritesheet = [ccspritebatchnode batchnodewithfile:@"image.png"]; [self addchild:spritesheet]; // load frames of our animation nsmutablearray *walkanimframes = [nsmutablearray array]; for(int = 1; < 5; i++) { [walkanimframes addobject:[[ccspriteframecache sharedspriteframecache] spriteframebyname:[nsstring stringwithformat:@"image%d.png", i]]]; } ccanimation *walkanim = [ccanimation animationwithspriteframes:walkanimframes delay:0.20f]; // create sprite 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 device have created sprite sheet retina image double size , image named image@2x.. created plist myplist@2xplist , image file imagefile@2x.png
i mean there 4 files
for non retina display.
1) imagefile.png(sprite sheet)
2) myplist.plist
for retina display.
1) imagefile@2x.png(sprite sheet) plist key name every image image@2x.png
2) myplist@2x.plist
but above code not working code. m doing wrong or missing somthing? app crash on device error message
ccspriteframecache: frame 'image1.png' not found 2013-05-03 16:19:49.764 *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '*** -[__nsarraym insertobject:atindex:]: object cannot nil' but above code working fine on simulator
by default cocos2d use -hd postfix not "@2x". , file names inside sprite sheet need same without "-hd" or @2x. main sprite sheet file name need postfix "-hd".
myplist-hd.plist
Comments
Post a Comment