...if (this._super()) { //init text this._topDisplayLabel.setString(""); this._bottomDisplayLabel.setString("RichText"); var widgetSize = this._widget.getContentSize(); // RichText //容器 var richText = new ccui.RichText(); richText.ignoreContentAdaptWithSize(false); richText.setContentSize(cc.size(120, 100)); //创建不同颜色的字串 var re1 = new ccui.RichElementText(1, cc.color.WHITE, 255, "This color is white. ", "Helvetica", 10); var re2 = new ccui.RichElementText(2, cc.color.YELLOW, 255, "And this is yellow. ", "Helvetica", 10); var re3 = new ccui.RichElementText(3, cc.color.BLUE, 255, "This one is blue. ", "Helvetica", 10); var re4 = new ccui.RichElementText(4, cc.color.GREEN, 255, "And green. ", "Helvetica", 10); var re5 = new ccui.RichElementText(5, cc.color.RED, 255, "Last one is red ", "Helvetica", 10); //还能支持图片 var reimg = new ccui.RichElementImage(6, cc.color.WHITE, 255, "res/cocosui/sliderballnormal.png"); //这里就吊了,还支持动画 ccs.armatureDataManager.addArmatureFileInfo("res/cocosui/100/100.ExportJson"); var pAr = ccs.Armature.create("100"); pAr.getAnimation().play("Animation1"); var recustom = new ccui.RichElementCustomNode(1, cc.color.WHITE, 255, pAr); //然后最后再拼回图片 var re6 = new ccui.RichElementText(7, cc.color.ORANGE, 255, "Have fun!! ", "Helvetica", 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; return true; } ...