iPhone Retina display vs non-Retina

So I’m not sure how exactly the engine does this or if I have to do it on my side.

How does the engine differentiate between what it’s using and how does this affect the images I have? Do I need to say like “if(retinaDisplayEnabled(true) load HDImage else load RegularImage”?

Also how does this work for world positions? Do I need to set it up kinda like the images? Meaning if it’s a retina display, put the object at this position or if it’s in non-retina, put it in this position?

Any information on how this works is greatly appreciated!

For the retina images, please take a look at this http://www.cocos2d-x.org/boards/7/topics/9797.
For instance, just provide images for both version retina and non-retina.

For position related, yes, you need to check whether the current mode is in retina or not (one of ways to check is via CC_CONTENT_SCALE_FACTOR() to check if it equal 2 or more than 1), then position your sprite accordingly.

FYI: I believe you can take advantage of content scaling to work on all size of image to correctly place your sprite’s position for any screen resolution.

Instead of making a bunch of if statements for the differentiating positions, is there a quick way to do it via the preprocessor?

Like #if CC_CONTENT_SCALE_FACTOR()>=2 then do HD stuff #else do non-HD stuff?

I won’t think you can do that as both version of sprite may have a totally different resolution (i mean not the right scaled version of the original one).

But if those images have exactly resolution that is a scaled version from the base image you have. I believe you can do that. Just think in a way that you have one image and scale for all other screen resolutions. That could work.
If that so, I suggest to calculate the image ratio as compared to the original one you base at and then use that value to position your sprite accordingly. One code, and will work for all screen resolution.

But by doing this, you have to base your positioning to one such image ratio (or say one such screen resolution).
Look at the code below

_precomputedS = fminf(winSize.width / 1024, winSize.height / 768);

I have based all of my sprites to screen resolution 1024 * 768 (which is iPad2).

Whenever it’s time to position your sprite, you do this.

Example : I position my left paddle (in pong style game) that works with any screen resolution, I modified the code for your case especially
leftPaddle->setPositionInPixels(ccp((50+leftPaddle_baseImage_original_width)*_precomputedS, winSize.height/2));

In which the process for creating a leftPaddle sprite with the right image can be ignored for us, as cocos2d-x will find a right one and will make our code works.