3

I am a Cocos2d game developer. I am developing a game using retina display images.

I have created texture files with and without HD suffix using zwoptex.

I have added those zwoptex plist texture files in app-delegate like [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"Background.plist"]; I have enabled the retina display to YES [director enableRetinaDisplay:YES];.

I have used the png files from the plist wherever i want using ccsprite *background = [CCSprite spriteWithSpriteFrameName:@"sample.png"];.

All those png files which I have included are high resolution images with both sizes 960*640 and 480 * 320. But in no reason the images look blurry and fuzzy when i run the game in simulator or iPhone. Anyone please help me to solve this issue …..

(The following image was posted as an example in a comment.)

enter image description here

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
Blisskarthik
  • 1,246
  • 8
  • 20
  • Possibly relevant? http://stackoverflow.com/questions/7462023/cocos2d-retina-support-not-working-anymore – andrewdotnich Jul 06 '12 at 04:20
  • It's not relevant to my question.I have created spritesheets using the same guideline given in the post. I can view the retina display images but it look fuzzy and blurry . It doesn't exhibit the original image resolution whenever i run the game in simulator or in iphone. When the retina display enabled is set to yes or no it display only the blurry image as output. – Blisskarthik Jul 06 '12 at 04:43
  • make sure in debugger that your sprite size in pixels is that you want. i mean that it has, for example, 200x100 size in points and 400x200 in pixels if you use retina device. – Morion Jul 06 '12 at 08:00

2 Answers2

1

cocos2d applies anti-aliasing to sprites by default. You need to turn that off:

[background.texture setAliasTexParameters];

hope this helps.

KDaker
  • 5,899
  • 5
  • 31
  • 44
  • Thanks for your response. I used it but it results the same. Is there any other solution to solve this issue – Blisskarthik Jul 06 '12 at 05:26
  • Is this happening only on retina display? – KDaker Jul 06 '12 at 06:35
  • It only shows blurry images whether retina display is set to yes or no. – Blisskarthik Jul 06 '12 at 07:31
  • i understand, but i mean only on a retina DEVICE? what about a 3gs (normal screen) – KDaker Jul 06 '12 at 07:33
  • Yes when i run in retina device it looks the same blurry images. When i run in ipad which does not support retina display means it shows the same result. – Blisskarthik Jul 06 '12 at 07:38
  • strange, well are you using the `-hd` suffix only on the spritesheet png? i once made the obvious mistake of putting the suffix on each frame name in zwoptex and had similar results like you.... can you post screenshots of how the blurry they are on retina and the iPad? – KDaker Jul 06 '12 at 07:42
  • Yes very strange. I have worked many projects using retina display but this one is looking odd. Yes i have added -hd suffix for only spritesheet png. I have not added -hd suffix for all the png in the spritesheet. Please check this link http://screencast.com/t/vqQSpWcMmg2s where i have added the screenshot of my project. Look how horrible it is – Blisskarthik Jul 06 '12 at 08:05
  • ok so looking at the picture it seems like you have issues with the colors, not blurring.. perhaps if you change the [pixel format](http://www.cocos2d-iphone.org/archives/61).. [see this](http://www.cocos2d-iphone.org/forum/topic/11038) as well .. other than that i really have no idea! – KDaker Jul 06 '12 at 09:38
  • 1
    Hi dude i solved this problem by adding [CCTexture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_RGBA8888];. By setting the pixel format to 4444 to 8888 all those blurry issues is solved and thank you very much for your support – Blisskarthik Jul 06 '12 at 19:32
1

The screenshot you posted (I took the liberty of adding it to your question) shows that it was taken from the iPhone Simulator and not the iPhone (Retina) Simulator. Therefore it will not use the HD images.

With the iPhone Simulator running go to the Hardware -> Device menu and select iPhone (Retina) as the device. Then restart your app.

Note also that the iPhone Simulator will only render the game with a color depth of 16-Bit, regardless of settings in cocos2d or your Mac. The iOS Simulator renderer is limited to 16-Bit rendering for performance reasons (it only uses software rendering, no hardware acceleration). Only by looking at the game on an actual device can you make judgement calls about image quality.

To test whether the game is actually loading the HD assets or for some reason just loads the SD images, try running it without the SD images. If the game tries to load the SD images it will cause an error. If not, it is loading the HD images and the "blur issue" has a different cause. You could also log which files are loaded by adding a NSLog statement to the CCFileUtil class method fullPathFromRelativePath which performs the file name changes to load -hd images whenever possible.

You'll find that even miniscule amount of scaling or rotation applied to a sprite may have it look blurred, so check if you happen to do that. Any change in blend modes (using ccBlendFunc) could also cause blurred images. Also check that your images are fully opaque (opacity == 255).

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
  • Thanks for your help dude ... I overcome the problem using [CCTexture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_RGBA8888];. It cleared all those blurry issues . Once again thanks for giving me guidance. – Blisskarthik Jul 06 '12 at 19:13