Cocostudio Study Notes (5) Text + TextAtlas + TextBMFont, cocostudio

Source: Internet
Author: User

Cocostudio Study Notes (5) Text + TextAtlas + TextBMFont, cocostudio
In the afternoon, a group of college students visited our company and learned how to develop a game...

The controls studied tonight are three labels: Text, TextAtlas, and TextBMFont.

In cocostudio, I first drag all three labels into the scene and name them label, atlas, and bitMap respectively. Finally, export the project and load the Widget in cocos2dx.

cocos2d::ui::Widget* labelUI = GUIReader::getInstance()->widgetFromJsonFile("LabelUI/LabelUI_1.json");this->addChild(labelUI,2);
Some people may say that since cocos2d: ui scope has been declared before, why not directly use widgets here? My answer is that I am also a newbie and I am not used to writing these APIs, so I can only use this method to deepen my impression.

I. Read Text first
1. Extract the label from the Widget.The Code is as follows:
Text* m_label = static_cast<Text*>(Helper::seekWidgetByName(labelUI,"label"));m_label->setPosition(Point(300,300));

2. Check the source code of Text.:
Static Text * create (); // create static Text * create (const std: string & textContent, const std: string & fontName, int fontSize ); void setText (const std: string & text); // set the displayed text const std: string & getStringValue (); obtain the text content ssize_t getStringLength (); // obtain the string length in text
Actually, it is similar to how to use the Label in cocos2dx.

Ii. TextAtlas
1. Retrieve the widgets in the label

TextAtlas* m_atlas = static_cast<TextAtlas*>(Helper::seekWidgetByName(labelUI,"atals"));m_atlas->setPosition(Point(400,300));

2. speechless

3. TextBMFont
1. Extract the label from the Widget.

TextBMFont* m_bmf = static_cast<TextBMFont*>(Helper::seekWidgetByName(labelUI,"bitMap"));m_bmf->setPosition(Point(200,300));

2. speechless

4. Conclusion: I did not give a more in-depth introduction to the above because I found that the Text in cocostudio is almost the same as the Label in cocos2dx, so I am too lazy to introduce it. Previously, the blog gave a clear introduction to the Label after 3.0.

Respect Original, reprinted please indicate Source: http://blog.csdn.net/star530/article/details/37370285



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.