iOS Universal Application 支持IPHONE和IPAD的應用設置

//實現  320*180  640*960 768*1024 1536*2048 四種分辨率的圖片加載php

//在AppDelegate中把起用高清的代碼註釋去掉ios

//if( ! [director enableRetinaDisplay:YES] )git

//CCLOG(@"Retina Display Not supported");github

//在ccConfig 中把-hd去掉,這是cocos2d默認起用高清的文件,和我當時定義的不符,我就去掉了app

//#define CC_RETINA_DISPLAY_FILENAME_SUFFIX @"-hd"  改爲  #define CC_RETINA_DISPLAY_FILENAME_SUFFIX @""  iphone

#define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)ide

//驗證是不是視網模屏ui

#define isIphoneRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)]?CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)spa

#define isIpadRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)]?CGSizeEqualToSize(CGSizeMake(2048, 1536), [[UIScreen mainScreen] currentMode].size) : NO).net

#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]))

//同步iphoneipad的坐

#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

相關文章
相關標籤/搜索