cocos2d-x JS 富文本(为一段文本中的个别字体上颜色)
setWinText : function (levelStr1,levelStr2,levelStr3,color1,color2) { var imgRankingBG = this.container.getComponentByName("imgRankingBG",this.maskNode); var str1 = new ccui.RichElementText(11,color1,255,levelStr1,null,30); var str2 = new ccui.RichElementText(12,color2,255,levelStr2,null,30); var str3 = new ccui.RichElementText(13,color1,255,levelStr3,null,30); var rt = new ccui.RichText(); rt.pushBackElement(str1); rt.pushBackElement(str2); rt.pushBackElement(str3); rt.setPosition(cc.p(241.74,204.64)); rt.setContentSize(cc.size(275.03,30.00)); imgRankingBG.addChild(rt); }