您好,登錄后才能下訂單哦!
... 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; } ...
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。