cocos2d-x 3以不推荐的方式创建标签

时间:2014-07-09 15:02:42

标签: c++ label cocos2d-x cocos2d-x-3.0

我想使用Arial字体创建标签。我尝试2路,但都声明已弃用。创建标签的好方法是什么?

Label::create("Hello World", "Arial", 32); //declared deprecated
LabelTTF::create("Hello World", "Arial", 32); //declared deprecated

1 个答案:

答案 0 :(得分:5)

您可以尝试以下代码:

std::string str = "五十嵐信介あろほほほaaaaaaaaaaaa";
cocos2d::ui::Text* titleLable = cocos2d::ui::Text::create(str,"AmericanTypewriter",35);
titleLable->setColor(Color3B::WHITE);
titleLable->setTextHorizontalAlignment(TextHAlignment::CENTER);
titleLable->setAnchorPoint(Vec2(0, 0));
titleLable->setPosition(Vec2(130, visibleSize.height - 50));
titleLable->setContentSize(Size(visibleSize.width - 200, 150));
this->addChild(titleLable);