Cocostudio Study Notes (4) loadingbar + textfield

Source: Internet
Author: User
Tags addchild

This article records the procedure of using two controls: loadingbar and textfield.

Bytes ----------------------------------------------------------------------------------------------------------------------------

Loadingbar

Bytes ---------------------------------------------------------------------------------------------------------------------------

I will learn about loadingbar tonight. translating it into cocos2dx is progresstimer, translating it into Chinese is a progress bar, translating it into English is progressbar, and translating it into Japanese is "..
1. Create a loadingbar project in cocostudio
Finally, import the data to the project resources directory (resources) in cocos2dx ).
2. Open the cocos2dx project and add cocostudio widgets to the scene:

cocos2d::ui::Widget* progress = GUIReader::getInstance()->widgetFromJsonFile("ProgressBarUi/ProgressBarUi_1.json");this->addChild(progress,2);
3. Extract loadingbar from the widget and perform some operations on it separately., Such as bending down, upstreaming ass or something.
LoadingBar* loading = static_cast<LoadingBar*>(Helper::seekWidgetByName(progress,"progressBar"));loading->setPosition(Point(300,300));
Well, the class name is loadingbar.

4. Go to the loadingbar source code to see what it has.:
Static loadingbar * Create (); // texturename is the texture image of the progress bar, and percentage is the initial progress of the progress bar. The default value is 0 static loadingbar * Create (const STD: string & texturename, int percentage = 0); // check the types of progress bars, as shown in the following enumeration: typedef Enum {loadingbartypeleft, // indicates that the progress bar is increased from left to right loadingbartyperight // indicates that the progress bar is increased from left to right} loadingbartype; // sets the direction of the progress bar, void setdirection (loadingbartype DIR ); // obtain the direction of the progress bar. The returned value is Integer int getdirection (); // set the progress and return the current progress void setpercent (INT percent); int getpercent (); // I didn't go to check the other items about jiugongge.
5. In fact, cocostudio's loadingbar is better than cocos2dx's progresstimer, and it is difficult for new users to understand some initialization settings of progresstimer (amount, in fact, I was a little dizzy by the setmidpoine API because I was just in touch with progresstine ...).
You can set the loadingbar direction on the property Panel of the cocostudio GUI. However, I found that, whether in cocos2dx or in cocostudio, loadingbar does not have one from top to bottom or from bottom to top in the set direction. Later I thought about it, you just need to rotate the loadingbar to a certain direction.

Well, it's raining, but I'm going to bed.

Bytes ----------------------------------------------------------------------------------------------------------------------------

Textfield

Bytes ---------------------------------------------------------------------------------------------------------------------------

Well, let me just say a few words:
1. I added two textfield input boxes in the cocostudio scenario, one for entering plain text and the other for entering the password.Let's take a look at how to set the password format. Finally, export the project to the Resource Directory of cocos2dx.

2. Add the two textfield controls above in cocos2dxHow to add it? You must load the widget first.

Widget* TextFieldUI = GUIReader::getInstance()->widgetFromJsonFile("TextField/PTextFieldUi_1.json");this->addChild(pageViewUI,2);
3. Retrieve textfield separately.
Textfield * m_input = static_cast <textfield *> (helper: seekwidgetbyname (textfieldui, "editbox"); m_input-> setposition (point (300,300 )); 4. Check common textfield APIs: // create textfieldstatic textfield * Create (); static textfield * Create (const STD: string & placeholder, // set const STD: string & fontname, // set the font format int fontsize before entering any text ); // set the font size // set the touch range of textfield. When the touch coordinate of the finger is within the touch range, enter the text void settouchsize (const size & Si Ze); size gettouchsize (); void settouchareaenabled (bool enable); // set whether to enable the touch virtual bool hittest (const point & pt); // What is this? Void settext (const STD: string & text); // set the text void setplaceholder (const STD: string & value) in the input box; // set the default display text const STD :: string & getplaceholder (); // obtain the default displayed text void setfontsize (INT size); // set the font size int getfontsize (); // obtain the font size void setfontname (const STD:: string & name); // set the font format const STD: string & getfontname (); // obtain the font format const STD: string & getstringvalue (); // obtain the text void setmaxlengthenabled (bool enable) in the input box; // set whether to limit the number of words entered. bool ismaxlengthenabled (); // determine whether to limit the number of words entered. Void setmaxlength (INT length ); // set the maximum number of input words int getmaxlength (); // obtain the maximum number of input words void setpasswordenabled (bool enable); // set the text format to the password format bool ispasswordenabled (); // determine whether the password format is void setpasswordstyletext (const char * styletext); // when the password format is used, the input text uses styletext to replace the display of const char * getpasswordstyletext (); // obtain the above styletextbool getattachwithime (); void setattachwithime (bool attach); bool getdetachwithime (); void setdetachwithime (bool detach); bool getinserttext (); void setinserttext (bool inserttext); bool getdeletebackward (); void setdeletebackward (bool deletebackward); void Merge (ref * target, sel_textfieldevent selecor); // Add a callback function


5. No more.

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

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.