Cocos2d-x Text的使用

前端之家收集整理的这篇文章主要介绍了Cocos2d-x Text的使用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。


Size size = Director::getInstance()->getVisibleSize();
cocos2d::ui::Text* text = cocos2d::ui::Text::create("TextArea Widget can line wrap","AmericanTypewriter",32);
text->ignoreContentAdaptWithSize(false);
text->setPosition(Vec2(size.width /2,size.height /2));
text->setContentSize(Size(280,150));
text->setTextHorizontalAlignment(TextHAlignment::CENTER);
text->setTouchScaleChangeEnabled(true);
text->setTouchEnabled(true);
text->addTouchEventListener([=](Ref* sender,cocos2d::ui::Widget::TouchEventType type)
{
if (type == cocos2d::ui::Widget::TouchEventType::ENDED)
{
if ((int)text->getContentSize().width == 280)
{
text->setContentSize(Size(380,100));
}
else{
text->setContentSize(Size(280,150));
}
}

}); this->addChild(text);

原文链接:https://www.f2er.com/cocos2dx/340239.html

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