Cocos Code Research (+) widget sub-class Richview learning notes

Source: Internet
Author: User

Theoretical part

A container class that displays multiple richelement. We can use it to easily display text with pictures and inherit from widgets.

Code practices

Static RichText * Create ()
Create an empty RichText

void Insertelement (richelement *element, int index)
Inserts a richelement at the specified location.

void Pushbackelement (Richelement *element)
Inserts a richelement at the end of the container.

void removeelement (int index)
Removes the richelement at the specified location.

void Removeelement (Richelement *element)
Remove a richelement.

void Setverticalspace (float space)
Sets the vertical interval for each richelement.

void Formattext ()
Rearrange all the richelement. Often called internally.

Static Richelementtext * Create (int tag,//Tag value.
Const COLOR3B &color,//color value.
Glubyte opacity,//opacity.
Const std::string &text,//text content.
Const std::string &fontname,//text font name.
float fontSize)//text font size.
Create a Richelementtext class from multiple variables.

Static Richelementimage * Create (int tag,//Tag value.
Const COLOR3B &color,//color value.
Glubyte opacity,//opacity.
Const std::string &filepath)//Picture file name.
Create a Richelementimage class from multiple variables.

Static Richelementcustomnode * Create (int tag,//Tag value.
Const COLOR3B &color,//color value.
Glubyte opacity,//opacity.
Node *customnode)//custom nodes pointer.
Create a Richelementcustomnode class from multiple variables.

Instance:

        //RichText_richtext =richtext::create (); _richtext->ignorecontentadaptwithsize (false); _richtext->setcontentsize (Size ( -, -)); Richelementtext* Re1 = Richelementtext::create (1, Color3b::white,255, STR1,"SimSun",Ten); Richelementtext* Re2 = Richelementtext::create (2, Color3b::yellow,255,"And this is yellow.","Helvetica",Ten); Richelementtext* Re3 = Richelementtext::create (3, Color3b::gray,255, STR2,"Yu Mincho",Ten); Richelementtext* Re4 = Richelementtext::create (4, Color3b::green,255,"and Green with TTF support.","Fonts/marker Felt.ttf",Ten); Richelementtext* Re5 = Richelementtext::create (5, Color3b::red,255,"Last one is red","Helvetica",Ten); Richelementimage* Reimg = Richelementimage::create (6, Color3b::white,255,"Cocosui/sliderballnormal.png"); Cocostudio::armaturedatamanager::getinstance ()->addarmaturefileinfo ("Cocosui/100/100.exportjson"); Cocostudio::armature*par = Cocostudio::armature::create (" -"); PAr->getanimation ()->play ("Animation1"); Richelementcustomnode* Recustom = Richelementcustomnode::create (1, Color3b::white,255, PAr); Richelementtext* Re6 = Richelementtext::create (7, Color3b::orange,255,"Have fun!!","Helvetica",Ten);

Cocos Code Research (+) widget sub-class Richview learning notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.