//实现 320*180 640*960 768*1024 1536*2048 四种分辨率的图片加载
//在AppDelegate中把起用高清的代码注释去掉
//if( ! [director enableRetinaDisplay:YES] )
//CCLOG(@"Retina Display Not supported");
//在ccConfig 中把-hd去掉,这是cocos2d默认起用高清的文件,和我当时定义的不符,我就去掉了
//#define CC_RETINA_DISPLAY_FILENAME_SUFFIX @"-hd" 改成 #define CC_RETINA_DISPLAY_FILENAME_SUFFIX @""
#define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
//验证是否是视网模屏
#define isIphoneRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)]?CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)
#define isIpadRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)]?CGSizeEqualToSize(CGSizeMake(2048, 1536), [[UIScreen mainScreen] currentMode].size) : NO)
#define I_PNG @".png"
#define SD_PNG @"-iphone-sd.png"
#define SD_IPHONE_PNG @"-iphone-hd.png"
#define HD_PNG @"-ipad-sd.png"
#define HD_IPAD_PNG @"-ipad-hd.png"
//取图片
#define IMG_GET(__filename__) (isPad == YES ? \
((isIpadRetina==YES)?[__filename__ stringByReplacingOccurrencesOfString:I_PNG withString:HD_IPAD_PNG]: \
[__filename__ stringByReplacingOccurrencesOfString:I_PNG withString:HD_PNG]) : \
((isIphoneRetina==YES)?[__filename__ stringByReplacingOccurrencesOfString:I_PNG withString:SD_IPHONE_PNG]: \
[__filename__ stringByReplacingOccurrencesOfString:I_PNG withString:SD_PNG]))
//同步iphone和ipad的坐标
#define TO_X(__x__) (isPad == YES ? ( __x__ * 2.133333 ) : ( __x__ ) )
#define TO_Y(__y__) (isPad == YES ? ( __y__ * 2.133333 ) : ( __y__ ) )
#define TO_XY(__x__, __y__) \
(isPad == YES ? \
ccp( ( __x__ * 2.133333 ), ( __y__ * 2.133333 )) : \
ccp(__x__, (__y__)))
//使用演示====================================
CCSprite *goodGuy = [CCSprite spriteWithTexture:[[CCTextureCache sharedTextureCache] addImage:IMG_GET("default.png")]];
[self addChild:goodGuy];
//上述代码参考了以下网址
//=============================================================
http://jonathanhui.com/ios-universal-application
http://www.slideshare.net/cliffmcc/creating-a-universal-ios-application
http://stackoverflow.com/questions/3320355/how-should-i-approach-building-a-universal-ios-app-that-will-include-ios-4-featu
https://github.com/kstenerud/iOS-Universal-Framework
Universal cocos2d game to support iPad3
http://stackoverflow.com/questions/9623720/universal-cocos2d-game-to-support-ipad3
http://michaelgilkes.info/cocos2d-using-hd-images-for-ipad-in-a-universal-app/
http://stackoverflow.com/questions/3320355/how-should-i-approach-building-a-universal-ios-app-that-will-include-ios-4-featu
cocos2d 官方高清图解决方案
http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:how_to_develop_retinadisplay_games_in_cocos2d
http://michaelgilkes.info/cocos2d-using-hd-images-for-ipad-in-a-universal-app/
http://stackoverflow.com/questions/9623720/universal-cocos2d-game-to-support-ipad3