[iOS] Cocos2d-x 2.0.2 multi resolution for iPhone 3 & iPhone Retina

[iOS] Cocos2d-x 2.0.2 multi resolution for iPhone 3 & iPhone Retina
0.0 0


Using Cocos2d-x 2.0.2 I use a design resolution of 640x960 - so all images have this size.

With this setup in code , the iPhone 3 (non retina) images will have wrong postion coords.

I use the same coords in point for retina & non retina - since this is how retina on iOS works. Same position coords but just 2x resolution assets

Any help?

I thought setting the design resolution (non retina) would just work also for placing images?

Looks like the current multi res. solution just scales images, but I think it should scale the position of the images, too.

@ if(getTargetPlatform()!=kTargetIpad){
//Retina for iPhone only
if(! pDirector->enableRetinaDisplay(true)){
//None Retina then set design resolution size 640x960
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(640, 960, kResolutionShowAll);
else{ //iPad case
CCEGLView::sharedOpenGLView()->setDesignResolutionSize(640, 960, kResolutionExactFit);

Major iPhone Retina Bug
multi-resolution doesn't work.

Yeah, enableRetina is meant to be used the other way around, you design your game for 320x480 and then enableRetinaDisplay() (graphics are 640x960 but coordinates for 320x480).

But, I think you might be able to do this: Looking at the code for enableRetinaDisplay you will see all it does is call “setContentScaleFactor(newScale);” where the scale for normal is 1 and retina is 2. Since your game is “1” at 640x960 then I think all you need to do is call “setContentScaleFactor(0.5);” when running on a 3GS.


@GavT GMTDEV Thanks for reply. Scale 0.5 for iPhone 3GS is not working btw.

I just solved the iPhone problem with the code from the TestCpp iOS sample which is incl. in Cocos2d-x 2.0.2.

For iOS I use 2 asset sizes for iPhone 3GS 320x480 and iPhone4 640x960.
The same iPhone 4 asset size is used for iPad (non retina).

The coords on iOS are ALL based on 320x480 except on iPad: On iPad I have to scale position(x,y) = ccp(x*2,y*2)

Check the attachment for my setup code and my method to scale the CCPoint coords