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
Problem:
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.
Solution:
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.
Call:
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 ));
Note:
The getContentSize and setContenSize methods of some classes can still be used, such as ImageView.