我想使用Arial字体创建标签。我尝试2路,但都声明已弃用。创建标签的好方法是什么?
Label::create("Hello World", "Arial", 32); //declared deprecated
LabelTTF::create("Hello World", "Arial", 32); //declared deprecated
答案 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);