前端之家收集整理的这篇文章主要介绍了
Cocos2d-x_获取当前设备语言,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
bool HelloWorld::init()
{
if ( !CCLayer::init() )
{
return false;
}
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCLabelTTF *ttfCurLanguage = CCLabelTTF::create("","Arial",20);
ttfCurLanguage->setPosition(ccp(winSize.width/2.0,winSize.height/2.0));
this->addChild(ttfCurLanguage);
ccLanguageType curLanguage = CCApplication::sharedApplication()->getCurrentLanguage();
switch (curLanguage)
{
case kLanguageEnglish:
ttfCurLanguage->setString("当前语言是:English");
break;
case kLanguageChinese:
ttfCurLanguage->setString("当前语言是:Chinese");
break;
case kLanguageFrench:
ttfCurLanguage->setString("当前语言是:French");
break;
case kLanguageGerman:
ttfCurLanguage->setString("当前语言是:German");
break;
case kLanguageItalian:
ttfCurLanguage->setString("当前语言是:Italian");
break;
case kLanguageRussian:
ttfCurLanguage->setString("当前语言是:Russian");
break;
case kLanguageSpanish:
ttfCurLanguage->setString("当前语言是:Spanish");
break;
default:
break;
}
return true;
}
原文链接:https://www.f2er.com/cocos2dx/346800.html