创建富文本(文本可以包含文字,图片,自定义节点),c++,cocos2dx

创建富文本(文本可以包含文字,图片,自定义节点)
这里测试富文本控件
ui::RichText* _richText = ui::RichText::create();
_richText->ignoreContentAdaptWithSize(false);
_richText->setSize(CCSizeMake(500, 300));


添加文字
ui::RichElementText* re1 = ui::RichElementText::create(1, ccWHITE, 255, "这是白色的文字。 ", "Helvetica", 24);
添加图片
ui::RichElementImage* reimg = ui::RichElementImage::create(6, ccWHITE, 255, "CloseNormal.png");
添加自定义节点
cocos2d::extension::CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("cocosgui/100/100.ExportJson");
cocos2d::extension::CCArmature *pAr = cocos2d::extension::CCArmature::create("100");
pAr->getAnimation()->play("Animation1");
ui::RichElementCustomNode* recustom = ui::RichElementCustomNode::create(1, ccWHITE, 255, pAr);


插入富文本


_richText->pushBackElement(re1 );
_richText->pushBackElement(reimg );
_richText->pushBackElement(recustom);


重新排序:
_richText->formatText();

猜你喜欢

转载自blog.csdn.net/u014206831/article/details/73849680
今日推荐