Domanda

I am having a problem with my cocos2d game that supports retina display. Everything used to work fine but now i am working on an update. In this update i have only added 3 new images (also in hd). I am using texture atlases made with zwoptex. the png's generated are gameart.png and gameart-hd.png. I am loading the files using this code:

 CCSpriteFrameCache* frameCache = [CCSpriteFrameCache sharedSpriteFrameCache];
    [frameCache addSpriteFramesWithFile:@"gameart.plist"];

when getting any sprite i am using spriteWithFrameName: method. Everything used to work fine before (Even on iPhone 4) but now i am getting the following error only on iPhone 4:

cocos2d: CCSpriteFrameCache: Frame 'tilei.png' not found
*** Assertion failure in -[BoardTile initWithSpriteFrame:]

the file tilei is available in both gameart.png and gameart-hd.png (tilei.png and tilei-hd.png) and the plist files. i rechecked it a thousand times. what could be going wrong? notice that the error is not showing the -hd suffix even though its only occurring while running on iPhone 4.

È stato utile?

Soluzione

You don't need the suffix of -hd for the sprites inside the hd spritesheet.

It looks like you have:

  • sd-spritesheet
    • image1.png
    • image2.png
    • etc.
  • hd-spritesheet
    • image1-hd.png
    • image2-hd.png
    • etc.

You need:

  • sd-spritesheet
    • image1.png
    • image2.png
    • etc.
  • hd-spritesheet
    • image1.png
    • image2.png
    • etc.

Altri suggerimenti

Maybe you have seen this page, but here is a link to building cocos2d retina apps. You might have seen it but it might be useful for those who want to build iPhone Cocos2d Retina Apps, and are new to cocos2d, http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:how_to_develop_retinadisplay_games_in_cocos2d.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top