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

这篇博客介绍了如何使用Cocos2d-x3.3的RichText组件创建富文本内容,包括设置不同颜色和字体的文本、插入图片以及嵌入骨骼动画。通过示例代码展示了如何创建和添加RichElementText、RichElementImage以及RichElementCustomNode,并播放Armature动画。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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的大小,按照默认的渲染器的大小进行渲染。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值