Cocos2d-x3.3Final(9)RichText常用成员函数(C++)

时间:2022-02-07 23:36:33

RichText  * _richText = RichText::create();

RichElementText * re1 = RichElementText::create(1, Color3B::RED, 255, str1, "Marker Felt", 10);

RichElementText * re4 = RIchElementText::create(4, Color3B::GREEN, 255, "And green with TTF support. ", "fonts/Marker Felt.ttf", 10);

RichElementImage * reimg = RichElementImage::create(6, Color3B::WHITE, 255, "sliderballnormal.png");


cocostudio::ArmatureDataManager::getInstance()->addArmatureFileInfo("100/100.ExportJson");

cocostudio::Armature * pAr = cocostudio::Armature::create("100");

pAr->getAnimation()->play("Animation1"); //创建骨骼动画


RichElementCustomNode * recustom = RichElementCustomNode::create(1, Color::WHITE, 255, pAr); //构造富文本元素


_richText->pushBackElement(re1);

_richText->insertElement(re2, 1);

_richText->insertElement(reimg, 2);

_richText->pushBackElement(recustom);


_richText->setLocalZOrder(10);

addChild(_richText);


_richText->ignoreContentAdaptWithSize(true); //是否忽略当前内容适应大小,为true则 不管_richText的大小,按照默认的渲染器的大小进行渲染。