想在lua中判断当前运行的是什么平台,谁知道怎么做。
在C++中是这么做的:
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
//do some thing special
#endif
想在lua中判断当前运行的是什么平台,谁知道怎么做。
在C++中是这么做的:
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
//do some thing special
#endif
local targetPlatform = cc.Application:getInstance():getTargetPlatform()
if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform)
or (cc.PLATFORM_OS_WINDOWS == targetPlatform) or (cc.PLATFORM_OS_ANDROID == targetPlatform)
or (cc.PLATFORM_OS_MAC == targetPlatform) then
尝试了一下你的方法,跑不通。我使用下面的方法可以运行,我使用的cocos2dx版本是2.2.2
local targetPlatform = CCApplication:sharedApplication():getTargetPlatform()
CCLuaLog(targetPlatform)
if kTargetAndroid == targetPlatform then
end
Lua target list:
kLanguageEnglish
kLanguageChinese
kLanguageFrench
kLanguageItalian
kLanguageGerman
kLanguageSpanish
kLanguageRussian
kLanguageKorean
kLanguageJapanese
kLanguageHungarian
kLanguagePortuguese
kLanguageArabic
kTargetWindows
kTargetLinux
kTargetMacOS
kTargetAndroid
kTargetIphone
kTargetIpad
kTargetBlackBerry
呵呵 。
Thank you!