TargetPlatform target = getTargetPlatform();//获取当前设备类型
设备枚举变量如下:
kTargetWindows: window系统
kTargetLinux: linux系统
kTargetMacOS: mac os系统
kTargetAndroid: Android系统
kTargetIphone: iOS系统-iphone&itouch
kTargetIpad: iOS系统-Ipad
kTargetBlackBerry: 黑莓系统
项目默认目录为Resources,创建的hd、ipadhd、ipad的文件夹与Resources同一级,所以这里设置目录为”../hd” ,”../ipad”,”../ipadhd”
附:
- TargetPlatform target = getTargetPlatform();//获取当前设备类型
- if (target == kTargetIpad){//如果是Ipad
- if (pDirector->enableRetinaDisplay(true)){ //如果开启高清视网膜
- CCFileUtils::sharedFileUtils()->setResourceDirectory("../ipadhd");
- }else {
- CCFileUtils::sharedFileUtils()->setResourceDirectory("../ipad");
- }
- }else if (target == kTargetIphone) {//如果是iphone
- if (pDirector->enableRetinaDisplay(true))
- {
- CCFileUtils::sharedFileUtils()->setResourceDirectory("../hd");
- }
- }
这篇博客介绍了如何在cocos2d-x中使用getTargetPlatform()函数来获取当前设备类型,包括Windows、Linux、Mac OS、Android、iOS(iPhone/iPad)和BlackBerry系统。并展示了根据设备类型动态设置资源目录的方法,以实现不同设备的高清显示。
1166

被折叠的 条评论
为什么被折叠?



