iOS game development: handling different screen resolutions [deprecated] - Plunge Interactive

iOS game development: handling different screen resolutions [deprecated]

ASSETS SIZES

My favorite option for iOS game development is to use just the exact size for the assets that each device actually uses. It basically is (at the time of writing this article):

  • iPhone 3G/iPod3: 480×320
  • iPhone 4/iPo4: 960×640
  • iPad 1,2: 1024×768
  • iPad 3 (or “new iPad”…): 2048×1536
This gives us the top quality for each device and the best user experience. Since there is an important variety of necessary assets if we want to cover all the devices, I do not recommend to build universal versions. I recommend a version for the small devices, and then another for iPad, but that depends a lot on each game.
NOTE: This article has been deprecated, since it is not valid with the latest version of Cocos2d-x 2.x and newer.

How does this work? You first need to enable the retina mode:
pDirector->enableRetinaDisplay(true);
You just need to have one call for each texture. For example: CCSprite::create(“mypic.png”); and then Cocos2dX will actually look for the adequate file to the current iOS device. This is:
mypic.png
mypic-hd.png
mypic-ipad.png
mypic-ipadhd.png
And that’s it! Cocos2DX will automatically load the necessary asset for the current platform, there is no need to check what is the platform in your own code, what is great.
But I have more! :-) You can actually change the predefined suffixes if you want to (not sure why anyone might want to do it, but you have the choice):
CCFileUtils::setiPadSuffix("-mysufix");
CCFileUtils::setiPadRetinaDisplaySuffix("-mysufix");
CCFileUtils::setiPhoneRetinaDisplaySuffix("-mysufix");

BUG: The problem comes when you want to create a game for iPad only. Cocos2D-X will always look for xxx.yyy file. This means that having your xxx.ipad.yyy and xxx.ipadhd.yyy is not enough, and if you don’t put the xxx.yyy file in the project, the execution will fail.

POSITIONING ASSETS

Then, the next interesting thing is about positioning. All the small devices share a device width and heigh of 480×320 points, so you can use the same absolute positioning for them if you want. iPad and iPad hd will also share the 1024×760 points.

I don’t like relative positionings… I prefer to control where is everything on the screen. But anyway, if anyone finds a good solution to use the same positioning system for iPhone and iPad please let me know :-)

Please feel free to follow me on twitter and share your thoughts :-) @jboschaiguade

This site uses cookies to store information on your computer. Some cookies on this site are essential, and the site won't work as expected without them. Read more about them

ACCEPT