Android Retina Mode?

Paste a picture may be better.

Hi,

I’ve created a changeset which enables the usage of “hd” images and fixes the display resolution problem on android
—> https://github.com/cocos2d/cocos2d-x/pull/538

(also tested on honeycomb devices, looks good)

I checked your code and I’m wondering where you set m_fScreenScaleFactor?
According to the changes setContentScaleFactor no longer does anything, thus m_fScreenScaleFactor cannot be changed.
And instead of “CC_CONTENT_SCALE_FACTOR() != 1.0f” should it be “CC_CONTENT_SCALE_FACTOR() > 1.0f”?
We would like to use HD images for content scale factors larger than 1, not for all others than 1. Think about if the content scale factor is less than 1. This means that the resolution of the device is even smaller than the designated dimension so the normal image is even more than necessary for the particular resolution, but you will actually use the HD version thanks to the “!=”.

m_fScreenScaleFactor is set in line 61 and describes the relation between the real display resolution and the values, you used for view->create(…)
This value should not changed. Otherwise your viewport would be bigger/smaller than the screen.

Yep, CC_CONTENT_SCALE_FACTOR() should be checked for > 1.0. In our game we’re using our own logic to decide, if we want to enable retina mode or not, so the scale factor was not lower than one.

Hi! Sorry if I’m bumping an old thread (I don’t think this is too old, though), but I have a question: Christian, I believe that your patch for adding HD support to cocos2dx was not included in the last release (cocos2d-1.0.1-x-0.11.0). Do you know if the patch could still work? I’m going to give it a try, just wanted to know if someone had the chance to test it in the current version…

Sure - we’re using the code in our game with the latest cocos2dx release and it still works fine.

Indeed, I’ve merged it today, it worked like a charm! :slight_smile: Thank you very much!

how about a feature letting android choose HD images when android has a higher resolution than let’s say 1.5factor of a specific width/height and scale all HD images by 0.5 factor to fit them in the 320x480 container…
because the sprites are more sharp than using the default resolution on HD screens.

Like already suggested:
~~>enableHDAssets;
~~>setGlobalScale(0.5);

or something.
Actually 0.5 scale is obsolete, since we only have 2 different resolutions x1 & x2. So it may happen automatically when enabling HD assets.

Hi~ Dear Wang:
We are facing the same situation here and we are using cocos2d-x v2.0.1, the solution we try to use is the 2nd laziest way you suggested, there is one thing I am confused, Do we still need add “~~hd" to all resources if we used 960*640 for iOS and Android? We tried to use normal name on iOS and enable Retina, it looks correct. The benefit is we could share same files both on Android and iOS no need to add "~~hd” for iOS, that saves lots of time, We are just concerning if it would lead any problem.

Thank you ! Big help

Walzer Wang wrote:

The auto-scale feature is only for android/win32/wophone, it cannot be used on iOS devices. You cannot set the view to 800x480 on iOS.
In your situation, you had to make resources in 480x320 for iphone3 + iphone4, 800*600 for ipad, and adjust the coordinates in the code.
The laziest way is to make resources in 480x320, it can be used in both iphone3/iphone4/android HVGA/android WVGA/android pads and more. The 2nd laziest resolution is 960*640, it can be work on iphone4 & all android devcies.

hi guys, what do you think about this solution? It would be just about having the iPhone screen ressolution (retina + non retina) and the same with iPad. If I detect the device is ios.

For the positioning, I use a fixed coordinate system, based on a fixed wirefrime (let’s say it is 480x320 for example). Then I position everything in a fixed coordinate system, converting the positions in the wireframe multiplying them for the scale of my current screen resolution.

I have a post here about this:
http://www.jesusbosch.com/2012/06/cross-platform-and-cross-device-screen.html

If I find a better or more refined approach, I would publish that into the wiki, but it’s not mature enough for now.

Cheers,

JB
@jboschaiguade

I just started to learn Cocos2D-X and I thought how multi-resolution is handled. I noticed those black bars and didn’t like them :confused: I am currently handling multi-resolution in my games (coded with java) using two coordinate systems. One coordinate system for world sprites and one coordinate system for screen. Screen coordinates are always 0.0-1.0. That’s because I can draw background images, buttons etc. that doesn’t need to be scaled in same aspect. World coordinates are set by screen aspect ratio. Screen height is always constant and width is aspect*height. Lets say height is 10 and aspect is 1.5. So width would be 15 and so on. If you have wider screen, you just see more game world. Sprite scale factory is calculated using screen_height / design_height so sprites are scaled in same aspect. That’s how sprites can be scaled smoothly while you can still use screen coordinates to draw background images to cover a whole screen. It would be nice if there could be method to just draw image in screen coordinates giving x,y,width and height. (0,0,1,1 would fill a whole screen).