Easy 🙂
1) Initialized sparrowView with real screen bounds that I get from [UIScreen mainScreen] bounds]
2) Added a new method to SPUtils:
+ (bool)isIphone5
{
return [UIScreen mainScreen].bounds.size.height == 568; // it's 1136 (retina 4-inch screen height)/2
}
3) Modified absolutePathToFile method in SPUtils:
+ (NSString *)absolutePathToFile:(NSString *)path withScaleFactor:(float)factor
idiom:(UIUserInterfaceIdiom)idiom
{
// iOS image resource naming conventions:
// SD: <ImageName><device_modifier>.<filename_extension>
// HD: <ImageName>@2x<device_modifier>.<filename_extension>
NSString *originalPath = path;
if (factor != 1.0f)
{
if([self isIphone5])
{
NSString *suffix = [NSString stringWithFormat:@"-5@%@x", [NSNumber numberWithFloat:factor]];
NSString *pathWithScale = [path stringByAppendingSuffixToFilename:suffix];
BOOL isAbsolute = [path isAbsolutePath];
NSBundle *appBundle = [NSBundle appBundle];
NSString *absolutePath = isAbsolute ? pathWithScale : [appBundle pathForResource:pathWithScale];
if ([SPUtils fileExistsAtPath:absolutePath]) return absolutePath;
}
(didn't change anything below)
And then created images with following file names:
image.png - normal iPhone
image@2x.png - retina iPhone
image-5@2x.png - iPhone 5
I also defined a macro to get screen height in case if I need it for sprite placement:
#define _H [UIScreen mainScreen].bounds.size.height
Oh, and you shouldn't forget to add retina (4-inch) launch image to the project, or it will initialize application with iPhone 4 screen size.
Not sure that this code will work in case of universal app, but you get the idea so you can modify it to make it happens in case if you need it.
As for the "old framework"... Players really doesn't care which framework you've been used, and I thought that making iPhone 5 support for Sparrow 1 would be much faster than moving everything to Sparrow 2 since I use plenty of custom opengl.