2
votes

I have a multiplatform iOS/Android game that I programmed in Cocos2d-x. I have only one set of images to use (I'm only after high res devices) that get scaled according to the device's resolution. For example all images are for the iPad but if you are using a Galaxy S then the image locations and scaling are affected by GalaxyS_screenWidth/iPadscreenWidth.

This works fine for all Android devices and on iPad, iPad2 and old iPhones, but with Retina iPhone there is a problem. On the iPhone 4 all my images look extremely pixelated, a result from the images being scaled to iPhone non-retina resolution then scaled back up to fill the screen.

I tried enabling Retina Mode and the images are half of their intended size (maybe due to the usage of get winsize() which uses points) and scaling manually causes other sorts of problems. I tried playing with a lot of options and attributes but to no avail, so what should I do now?

EDIT: This is not only a graphics issue, as text gets automatically scaled down then up and appears pixelated.

EDIT 2: Fonts are bitmaps so my bad. But I don't want to use retina as all images are already retina by default. All of my images are set up for the iPad so for iPhone 4 I just scale them down a bit. This works with Android phones.

For example I have an image, depending on screen resolution obtained through getwinsize():

If current resolution width is 1024 then image stays the same. If current resolution width is 900 then image gets scaled by 900/1024, no problem. If device is iPhone 4 resolution width is 480, so image gets scaled by 480/1024, then cocos2d-x automatically scales the resulting image by 2 thus the pixelation. I tried using getwinsizeinpixels, I tried multiplying the screen size, I tried many things but nothing worked out of the box unless I am to redo many of my code.

So the question is, how can I just let the damn engine treat the iPhone 4 as an Android phone with resolution of 960x640?

3
What have you named your retina versions of the graphics?Nick Bull
There aren't any, there is only one set of graphics as stated in my question. The problem isn't situated in only the graphics, as text is also scaled down then up which results in massive pixelation.user1235155
You have to include retina versions. How else do you expect it to be able to show high resolution versions without pixelation? Your fonts are also probably being generated from bitmap fonts rather than system fonts in which case you also require retina versions of those.Nick Bull
My bad about the fonts, all images already are retina by default, read Edit 2 please.user1235155

3 Answers

1
votes

If you want Retina resolution images to look like Retina resolution images, then those images need to be in Retina resolution (960x480).

If you first scale down the image to 480x320 and then upscale it on the device, it will of course look blurred. You can't magically make the Retina pixels appear from a lower resolution image by scaling it up.

1
votes

SI couldn't get to the bottom of it so I employed a hack. I enabled Retina Display then I scaled everything x2 through code except for the text. Sounds stupid, but it worked, and pixelation is gone. Thanks everyone who spent time trying to help me.

0
votes

I tried enabling Retina Mode and the images are half of their intended size

when you enable retina support, cocos2d gets images by appending @"-hd" to their provided filenames. Such images are meant to be double the "visual" size (in iOS terms, pixels vs. points), so that they can be sort of scaled down to make full use of device resolution.

If you have a look at the CCDirectorIOS class, you will find there a couple of methods dealing with this, especially those dealing with the scalingFactor. I don't know what kind of changes you should do to make it work, but if you step into those methods and look at the value of various objects, you might find a way to modify cocos2D default behavior for your specific case.

If this seems to complicated, one thing you could try is changing the CC_RETINA_DISPLAY_FILENAME_SUFFIX so that cocos2d will not look for specially-named files for the retina iPhone, but just use the normal ones.

For example all images are for the iPad but if you are using a Galaxy S then the image locations and scaling are affected by GalaxyS_screenWidth/iPadscreenWidth.

Another thing you might try is not using winSize, but winSizeInPixels, so that when you scale down, you down do it down to the point resolution, but just to the pixel resolution (which is double the point resolution).

Hope this helps.