Posts Tagged 'xCode'

Cocos2d retina support

Cocos2d is probably the most used and least documented framework out there. I’m used to docs being out-dated (doc is the most important and least maintained part of a framework) but Cocos2d gets to be my biggest loser on this scale. All that criticism aside, once you finally figure out how things are supposed to work it’s actually really nice.

If you’re familiar with the xCode you’re probably familiar with Apple using the @2x suffix on the end of their files when they need something larger than the original iPhone display resolution. ┬áTo date this is what Apple’s doing:

default.png – iPhone 3GS and older resolution
default.png@2x -Retina 3.5 inch
default-568h@2x.png – Retina 4 inch (iPhone 5 nonsense… seriously Apple?)

Cocos2d takes a similar approach:

default.png – iPhone 3GS
default-ipad.png – iPad 1 and 2 resolution
default-ipadhd.png – Retina resolutions (I don’t think they’ve got a Retina 4 inch file type as of yet.. but then again, how could I possibly know?)

This short story is you should only specify default.png as the file you’re trying to load as a Sprite. Cocos2d will automatically look to see if you have that file with the -ipad or -ipadhd extension, and load that if appropriate. (That’s all determined if you’ve got retina display enabled. Here’s some pseudo code for that:


if( ! [director_ enableRetinaDisplay:YES] )
CCLOG(@"Retina Display Not Supported");

Hope that helps!

Advertisements