Cocos2d and the new iPhone 5 aspect ratio

mm24 picture mm24 · Sep 12, 2012 · Viewed 8.4k times · Source

I have just seen the announcment of iPhone 5 and it says that the pixel resolution has changed to 1136*640, affecting in this way the ASPECT RATIO of the app.

How should I deal with this in my Cocos2d game? I got all the graphics done for the "old" 960*640 retina display screen and I guess that those will be distorted on the iPhone 5 screen.

Am I right? Or will there be the "old resolution" images shown without modifying the aspect ratio and leaving some screen black?

EDIT: Is there a way to get Cocos2d to detect if it is iPhone 5 and in that case draw the background files in the top part of the screen (top 960 pixels) and get some other custom background files to be drawn in the remaining pixels (e.g. those could be some custom ad banners or some extra buttons available in our Game only for iPhone 5).

Answer

Ben Trengrove picture Ben Trengrove · Sep 13, 2012

I have just added 4 inch support to my app this morning. Cocos2d runs fine (in the simulator) with no modifications. All of my scenes have resized correctly, I just had to make a few modifications to some positions as they were fixed coordinates not relative.

There is currently no way to load different images easily, I suspect there will be a new naming convention similar to -hd in the next few days.

As for your edit question, you will probably find that once you enable the 4 inch mode your layout will have a large black space at the top already. Of course you can put whatever you want there.

You can detect if it is a tall screen using

[[UIScreen mainScreen] bounds].size.height