Cocos2d-x 3.0 RichText富文本

前端之家收集整理的这篇文章主要介绍了Cocos2d-x 3.0 RichText富文本前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
...
if(this._super()){
//inittext
this._topDisplayLabel.setString("");
this._bottomDisplayLabel.setString("RichText");

varwidgetSize=this._widget.getContentSize();

//RichText
//容器
varrichText=newccui.RichText();
richText.ignoreContentAdaptWithSize(false);
richText.setContentSize(cc.size(120,100));

//创建不同颜色的字串
varre1=newccui.RichElementText(1,cc.color.WHITE,255,"Thiscoloriswhite.","Helvetica",10);

varre2=newccui.RichElementText(2,cc.color.YELLOW,"Andthisisyellow.",10);
varre3=newccui.RichElementText(3,cc.color.BLUE,"Thisoneisblue.",10);
varre4=newccui.RichElementText(4,cc.color.GREEN,"Andgreen.",10);
varre5=newccui.RichElementText(5,cc.color.RED,"Lastoneisred",10);
//还能支持图片
varreimg=newccui.RichElementImage(6,"res/cocosui/sliderballnormal.png");

//这里就吊了,还支持动画
ccs.armatureDataManager.addArmatureFileInfo("res/cocosui/100/100.ExportJson");
varpAr=ccs.Armature.create("100");
pAr.getAnimation().play("Animation1");

varrecustom=newccui.RichElementCustomNode(1,pAr);
//然后最后再拼回图片
varre6=newccui.RichElementText(7,cc.color.ORANGE,"Havefun!!",10);

richText.pushBackElement(re1);
richText.insertElement(re2,1);
richText.pushBackElement(re3);
richText.pushBackElement(re4);
richText.pushBackElement(re5);
richText.insertElement(reimg,2);
richText.pushBackElement(recustom);
richText.pushBackElement(re6);

richText.setPosition(cc.p(widgetSize.width/2,widgetSize.height/2));

this._mainNode.addChild(richText);
this._richText=richText;
returntrue;
}
...
原文链接:https://www.f2er.com/cocos2dx/346784.html

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