Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cocos2d and the new iPhone 5 aspect ratio

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).

like image 254
mm24 Avatar asked Sep 12 '12 20:09

mm24


2 Answers

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 
like image 88
Ben Trengrove Avatar answered Sep 29 '22 17:09

Ben Trengrove


iOS will automatically place thin black bars on either side of the app so it remains consistent with the way the apps were originally designed for previous versions of the iPhone

Several sources report this, this is from here.

As of yet, with no devices nor iOS 6 being available, we don't even know if or which kind of modifications would need to be done to cocos2d to support iPhone 5. Stop worrying. Don't assume. Wait and see.

As with all other devices, there will be ways to detect the exact device type. Again, this would have to wait until we get at least iOS 6. You could join the beta program in hopes of finding out, but as long as its in beta such information is under NDA and you can only find out perhaps via the private Apple developer forums.

like image 26
LearnCocos2D Avatar answered Sep 29 '22 17:09

LearnCocos2D