... If (this. _ super () {// init text this. _ topdisplaylabel. setstring (""); this. _ bottomdisplaylabel. setstring ("richtext"); var widgetsize = This. _ widget. getcontentsize (); // richtext // container var richtext = new ccui. richtext (); richtext. ignorecontentadaptwithsize (false); richtext. setcontentsize (CC. size (120,100); // create a string of different colors 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", "Helveti CA ", 10); // supports image var reimg = new ccui. richelementimage (6, CC. color. white, 255, "Res/cocosui/sliderballnormal.png"); // The image is suspended and supports animation 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); // then fight back the image var re6 = new ccui. riche Lementtext (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 ;}...
This article is from Eric's home_value blog, please be sure to keep this source http://ericyu.blog.51cto.com/2320641/1566102
Cocos2d-x 3.0 Rich Text