managing images in an iphone/ipad universal app

Posted by taber on Stack Overflow See other posts from Stack Overflow or by taber
Published on 2010-05-09T07:08:48Z Indexed on 2010/05/09 7:18 UTC
Read the original article Hit count: 1112

Hi, I'm just curious as to what methods people are using to dynamically use larger or smaller images in their universal iPhone/iPad apps.

I created a large test image and I tried scaling down (using cocos2d) by 0.46875. After viewing that in the iPhone 4.0 simulator I found the results were pretty crappy... rough pixel edges, etc. Plus, loading huge image files for iPhone users when they don't need them is pretty lame.

So I guess what I will probably have to do is save out two versions of every sprite... large (for the iPad side) and small (for iPhone/iPod Touch) then detect the user's device and spit out the proper sprite like so:


NSString *deviceType = [UIDevice currentDevice].model;
CCSprite *test;
if([deviceType isEqualToString:@"iPad"]) {
  test = [CCSprite spriteWithFile:@"testBigHuge.png"];
} else {
  test = [CCSprite spriteWithFile:@"testRegularMcTiny.png"];
}
[self addChild: test];

How are you guys doing this? I'd rather avoid sprinkling all of my code with if statements like this. I want to also avoid using .xib files since it's an OpenGL-based app.

Thanks!

© Stack Overflow or respective owner

Related posts about iphone

Related posts about ipad