Cocos2dx-2.X Layout set size issue, cocos2dx-2.xlayout

Source: Internet
Author: User

Cocos2dx-2.X Layout set size issue, cocos2dx-2.xlayout
Cocos2dx-2.X Layout settings size issues
CocoStudio 1.1.6
Cocos2dx 2.2.6

There is a demand two days ago, because the number of items is not certain, you need to add the item, and then calculate the size.
After adding an item to the Layout control, I call the setContentSize method because
The class itself is inherited from CCNode, and all methods will have the setContentSize method. However,
There is no effect at all, and the Layout size remains unchanged.
I asked in the cocos group later, someone said that setLayoutSize was used, and I found it,
This method is not available at all, but there is a Widget: setSize, while Layout
Inherited from the Widget, I tried the setSize method. The result is correct and the problem is solved. There is also
GetSize method.

In the WidgetReader: setPropsFromJsonDictionary method
File, get the width and height, and then call the setSize method to set.
Float w = DICTOOL-> getFloatValue_json (options, "width ");
Float h = DICTOOL-> getFloatValue_json (options, "height ");
Widget-> setSize (CCSizeMake (w, h ));

The getContentSize and setContenSize methods of some classes can still be used, such as ImageView.

Related Article

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: 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.