Cocos2d-x_获取当前设备语言

前端之家收集整理的这篇文章主要介绍了Cocos2d-x_获取当前设备语言前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
  1. bool HelloWorld::init()
  2. {
  3. if ( !CCLayer::init() )
  4. {
  5. return false;
  6. }
  7.  
  8. CCSize winSize = CCDirector::sharedDirector()->getWinSize();
  9. CCLabelTTF *ttfCurLanguage = CCLabelTTF::create("","Arial",20);
  10. ttfCurLanguage->setPosition(ccp(winSize.width/2.0,winSize.height/2.0));
  11. this->addChild(ttfCurLanguage);
  12. ccLanguageType curLanguage = CCApplication::sharedApplication()->getCurrentLanguage();
  13. switch (curLanguage)
  14. {
  15. case kLanguageEnglish:
  16. ttfCurLanguage->setString("当前语言是:English");
  17. break;
  18. case kLanguageChinese:
  19. ttfCurLanguage->setString("当前语言是:Chinese");
  20. break;
  21. case kLanguageFrench:
  22. ttfCurLanguage->setString("当前语言是:French");
  23. break;
  24. case kLanguageGerman:
  25. ttfCurLanguage->setString("当前语言是:German");
  26. break;
  27. case kLanguageItalian:
  28. ttfCurLanguage->setString("当前语言是:Italian");
  29. break;
  30. case kLanguageRussian:
  31. ttfCurLanguage->setString("当前语言是:Russian");
  32. break;
  33. case kLanguageSpanish:
  34. ttfCurLanguage->setString("当前语言是:Spanish");
  35. break;
  36. default:
  37. break;
  38. }
  39. return true;
  40. }

猜你在找的Cocos2d-x相关文章