Cocos2d-x3.2システム言語環境の取得
1659 ワード
//GameScene.h
#include "cocos2d.h"
class GameScene : public cocos2d::Layer
{
public:
static cocos2d::Scene* createScene();
virtual bool init();
void menuCallback(cocos2d::Ref* pSender);
CREATE_FUNC(GameScene);
};
//GameScene.cpp
// : ,
#include "GameScene.h"
USING_NS_CC;
cocos2d::Scene* GameScene::createScene()
{
auto scene = Scene::create(); //
auto layer = GameScene::create(); //
scene->addChild(layer);
return scene;
}
//
bool GameScene::init()
{
if(!Layer::init()) //
return false;
//
Size visibleSize = Director::getInstance()->getVisibleSize();
//auto size = Director::getInstance()->getWinSize();
//
auto sprite = Sprite::create("OnePiece_1.png");
sprite->setPosition(Vec2(visibleSize.width/2, visibleSize.height/2));
this->addChild(sprite);
auto label = Label::createWithSystemFont("", "Marker Felt", 45);
label->setAnchorPoint(Vec2::ZERO);
label->setPosition(Vec2(0, visibleSize.height*0.5));
this->addChild(label);
auto curLanguage = Application::getInstance()->getCurrentLanguage();
switch (curLanguage) {
case cocos2d::LanguageType::CHINESE:
label->setString("CHINESE");
break;
case cocos2d::LanguageType::ENGLISH:
label->setString("ENGLISH");
break;
//......................
default:
break;
}
return true;
}