{"id":3286,"date":"2014-03-21T20:22:34","date_gmt":"2014-03-21T20:22:34","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/21\/sprite-sheet-not-working-for-retina-display-collection-of-common-programming-errors-2\/"},"modified":"2014-03-21T20:22:34","modified_gmt":"2014-03-21T20:22:34","slug":"sprite-sheet-not-working-for-retina-display-collection-of-common-programming-errors-2","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/21\/sprite-sheet-not-working-for-retina-display-collection-of-common-programming-errors-2\/","title":{"rendered":"sprite sheet not working for retina display-Collection of common programming errors"},"content":{"rendered":"<p>I have create a <code>sprite sheet<\/code> for <code>non retina display<\/code> and its working fine on simulator.. I have used the code<\/p>\n<pre><code> -(Void)addSprites{\n     [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@\"image.plist\"];\n\n    CCSpriteBatchNode *spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@\"image.png\"];\n    [self addChild:spriteSheet];\n\n \/\/ Load up the frames of our animation\n    NSMutableArray *walkAnimFrames = [NSMutableArray array];\n    for(int i = 1; i &lt; 5; i++) {\n        [walkAnimFrames addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@\"image%d.png\", i]]];\n    }\n\n    CCAnimation *walkAnim = [CCAnimation animationWithSpriteFrames:walkAnimFrames delay:0.20f];\n\/\/ Create a sprite for our bear\n\n    background = [CCSprite spriteWithSpriteFrameName:@\"image1.png\"];\n    background.position = ccp(280, 175);\n    self.walkAction = [CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:walkAnim]];\n    [spriteSheet addChild:background];  \n}\n -(void)startAnimation{\n    [background runAction:_walkAction];\n<\/code><\/pre>\n<p>}<\/p>\n<p>And for for device i have created sprite sheet with retina image with double size and image named like <code>image@2x..<\/code> the created <code>plist<\/code> is <code>myplist@2xplist<\/code> and image file is <code>imagefile@2x.png<\/code><\/p>\n<p>I mean there are 4 files<\/p>\n<p><strong>for non retina display.<\/strong><\/p>\n<p>1) <code>imagefile.png(sprite sheet)<\/code><\/p>\n<p>2) <code>myPlist.plist<\/code><\/p>\n<p><strong>for Retina display.<\/strong><\/p>\n<p>1) <code>imagefile@2x.png(sprite sheet)<\/code> the plist key name for every image is also like image@2x.png<\/p>\n<p>2) <code>myPlist@2x.plist<\/code><\/p>\n<p>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<\/p>\n<pre><code> CCSpriteFrameCache: Frame 'image1.png' not found\n2013-05-03 16:19:49.764  *** Terminating app due to uncaught exception \n'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object    cannot be nil'\n<\/code><\/pre>\n<p>but the above code is <code>working fine on simulator<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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:@&#8221;image.plist&#8221;]; CCSpriteBatchNode *spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@&#8221;image.png&#8221;]; [self addChild:spriteSheet]; \/\/ Load up the frames of our animation NSMutableArray *walkAnimFrames = [NSMutableArray array]; for(int i = 1; i &lt; 5; i++) { [walkAnimFrames [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3286","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3286","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3286"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3286\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}