首页 > 代码库 > Cocos2d-x 3.0 RichText富文本
Cocos2d-x 3.0 RichText富文本
... 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; } ...
本文出自 “Eric的HOME_VALUE” 博客,请务必保留此出处http://ericyu.blog.51cto.com/2320641/1566102
Cocos2d-x 3.0 RichText富文本
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。