1
\$\begingroup\$

I am looking into ios game development and the first question that comes to mind is how to support the growing number of iphone resolutions.

I have seen the Unity strategy of normalized screen coordinates, but all of the cocos2d tutorials I look at seem to hard code pixel positions. How does this work with iphone 4 , 5, 6, 6+ all having different resolutions? (4 vs 6 is a major difference)

Is there a common practice for dealing with this?

\$\endgroup\$
1
\$\begingroup\$

Cocos2D-x 2.x and 3.x have very easy solution for multi-resolution problem ( either iDevices or Android devices) (and I think cocos2d-iphone should have a similar mechanism (maybe with different signature).

In fact you just need to set your DesignResolution and then just imagine your target device will has this resolution.

If target device really has this resolution ( or some other but with same ratio) cocos2d will handle to fix screen and your game looks same in all devices.

And when ratio of target device is different, you have many option ( as cocos2d language, policy) to manage that.

For example if you use Exact fit policy, cocos2d will force your game ( and design) to fit target device screen (without that black boarder).

Exact fit

The entire application is visible in the specified area without trying to preserve the original aspect ratio. Distortion can occur, and the application may appear stretched or compressed.

For more detail just take a look at the official wiki.

\$\endgroup\$
  • \$\begingroup\$ Can you please provide information about HOW to do this with cocos2D v2.x? I keep seeing so many places on the web that say "this is trivial to do on both 2.x and 3.x", yet there is absolutely no documentation anywhere on how to do it in 2.x... Everything talks about DesignResolution and resolution policies, neither of which are anywhere in the cocos2d-iphone v2.x codebase! \$\endgroup\$ – patrick Oct 12 '15 at 20:44
  • \$\begingroup\$ @patrick As I said: "I think cocos2d-iphone should have a similar mechanism". I've not had any project with cocoos2d-iphone yet and sorry if there is no similar mechanism. It's weird to me. \$\endgroup\$ – Emadpres Oct 13 '15 at 6:09
0
\$\begingroup\$

I am quoting here from one of my previous posts which you can find here.

  1. The easiest solution would be to create the graphics at the size of the highest resolution, but older iPhones have little memory so this solution would only work (smoothly) on the newer models. Instead you should target 2 resolutions. 1920 x 1080 for the iPhone 6(+) and 1136 x 640 for the 5(S). In this way you will only have to downscale for the iPhone 6. This downscaling should not have a huge effect on performance since the hardware in the iPhone 6 is more than capable.

  2. Generally you would want the experience to be the same across all devices. The iPhone 5 and up all have a 16:9 aspect ratio. Unfortunately the iPhone 4(S) doesn't. For these you will either have to downscale the content a little further and have an empty space on the top/side or have some content falling off. The latter probably isn't the best idea so downscaling and having a little extra space on top seems like the best solution.

enter image description here

The whole image is the screen of the iPhone 5(S), cut off area 2 and you get the screen of the iPhone 4(S). Now, if you want to have the same content visible on the iPhone 5 and 4 then you will need to keep the same aspect ratio. The 5 its aspect ratio is 16:9. When we apply this to the iPhone 4 then you will get area 1. The grey areas will not have any content. You can fill this up with a nice background or display an UI.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.