Game Development Reference
In-Depth Information
// If the 1st suffix is not found and if fallback is enabled then fallback suffixes
// are searched. If no fallback file is found, it will try the file without any suffix.
// On iPad Retina : "-ipadhd", fallback: "-ipad", second fallback: "-hd"
// On iPad : "-ipad", fallback: "-hd"
// On iPhone Retina: "-hd"
CCFileUtils *sharedFileUtils = [CCFileUtils sharedFileUtils];
[sharedFileUtils setEnableFallbackSuffixes:NO];
[sharedFileUtils setiPhoneRetinaDisplaySuffix:@"-hd"];
[sharedFileUtils setiPadSuffix:@"-ipad"];
[sharedFileUtils setiPadRetinaDisplaySuffix:@"-ipadhd"];
So if you specify in your code to load a file named ship.png , then on a Retina dis-
play device it will first try to load ship-hd.png , and if that file doesn't exist or the
device isn't a Retina display device, the SD image ship.png is loaded. On the iPad it
tries to load the ship-ipad.png file and, if fallback is enabled, it also tries loading
ship-hd.png before trying to load ship.png . On the Retina iPad cocos2d first
looks for ship-ipadhd.png and, if fallback is enabled, it also tries ship-
ipad.png , followed by ship-hd.png , before finally reverting to load ship.png .
Because those fallback mechanisms can be quite tricky to get right, I strongly recom-
mend that you provide assets for all variants. For iPhone and iPod touch apps, you need
standard resolution files with no suffix and the Retina resolution with the -hd suffix.
For iPad apps, you will want to supply -ipad and -ipadhd assets. And for a univer-
sal app, you should really provide all four variants.
Of course, this makes sense only if all HD images have exactly twice the resolution of
the SD ones. Otherwise, you'll notice that HD images which are not exactly twice the
resolution are more or less offset when displayed in your app. In general, you should
avoid using HD images, whose pixel resolution is not divisible by two without a re-
mainder. If you do support Retina displays, you should create all images in HD resolu-
tion first and then scale them down by 50 percent and save them as the SD images.
Upscaling SD images doesn't give you Retina display quality with more image de-
tails—that can only be done by the computer experts on CSI . The programming com-
munity at large is still perplexed about how they do that.
The nice thing about cocos2d's HD image support is that your game doesn't even have
to know if it's running on a Retina device. The code is the same. The only thing you do
Search Nedrilad ::

Custom Search