Hello,
First off let me say that I really like the multiresolution system that cocos2dx (v2.0) offers. I have successful got my game working on iPadHD, iPad, iPhone retina (960x640), and iPhone resolutions without any stretching or graphical artifacts. Unfortunately when it comes to testing on iPhone 5 I get two senarios happen. When I try to treat it like an iphone 4s (960x640) resolution I get the screen to fill up but it gets cropped on the edges. And when I try to conform to the 640x1136 resolution I get stretching. For my project I made all my raw assets in photoshop at the iPadHD scale (2048x1536). Then inside texturepacker I create sprite sheets for iPadHD, iPad, and iPhone sizes. These sprite sheets are exported at their respective scales of the original iPadHD. So for example the sprite sheet for iPadHD is 1.0, iPad is 0.5, and iPhone is 0.234375. For the iPhone retina (960x640) I use the iPad (728x1024) sprite sheet I find that it works without any graphical issues. Next for menu layouts I use cocosbuilder and in there I have double check that I am using percent based coordinated and sizes. Here is the code for setting up my resolutions:
CCSize designSize = CCSizeMake(320, 480);
if(screenSize.height > 1024)
{
// iPhone 5 (640x1136)
if(screenSize.width < 1536)
{
CCSize designSize = CCSizeMake(320, 568);
CCSize resourceSize = CCSizeMake(768, 1024);
CCFileUtils::sharedFileUtils()->setResourceDirectory("ipad");
pDirector->setContentScaleFactor(resourceSize.width/designSize.width);
}
// iPadHD (1536x2048)
else
{
designSize = CCSizeMake(1536, 2048);
CCSize resourceSize = CCSizeMake(1536, 2048);
CCFileUtils::sharedFileUtils()->setResourceDirectory("ipadhd");
pDirector->setContentScaleFactor(resourceSize.width/designSize.width);
}
}
// iPad (768x1024)
else if (screenSize.height > 960)
{
designSize = CCSizeMake(768, 1024);
CCSize resourceSize = CCSizeMake(768, 1024);
CCFileUtils::sharedFileUtils()->setResourceDirectory("ipad");
pDirector->setContentScaleFactor(resourceSize.width/designSize.width);
}
// iPhoneHD (640x960)
else if (screenSize.height > 480)
{
CCSize resourceSize = CCSizeMake(768, 1024);
CCFileUtils::sharedFileUtils()->setResourceDirectory("ipad");
pDirector->setContentScaleFactor(resourceSize.width/designSize.width);
}
// iPhone (320x480)
else
{
CCSize resourceSize = CCSizeMake(360, 480);
pDirector->setContentScaleFactor(resourceSize.width/ designSize.width);
CCFileUtils::sharedFileUtils()->setResourceDirectory("iphone");
}
Any suggestions what I can do to fix the stretching in iPhone 5 would be great. Thanks!