Closed fyt000 closed 7 years ago
I think it would be better if its menu->setPosition(Point::Zero);
I have to call this every time i create a menu.
@three0s it sounds reasonable. @ricardoquesada what's your opinion?
@minggo makes sense. PR here: https://github.com/cocos2d/cocos2d-x/pull/17090
@ricardoquesada thanks. The PR breaks compatibility, i think it is better to keep compatible by default, and add a new method to use content size.
or just add a default parameter to use the windows size
@minggo it might break compatibility if the user changed the menu's contentSize
manually.
But by default, the menu's contentSize()
is the Director's contentSize
.
See this line:
https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-3.13.1/cocos/2d/CCMenu.cpp#L142
hey, I was wondering why use contentSize? All nodes are created with Point::Zero position why change it here? I understand its usability in multi-resolution but we lose the consistency in code due to this.
@Bilalmirza sorry, I didn't understand the question. we are not changing menu's contentSize. we are just using it instead of using Director's winSize. And by default, menu's contentSize is Director's winSize.
@ricardoquesada oh okay, thanks
As in title, Menu always set everything with respect to windows size. For example, In Menu::alignItemsInColumnsWithArray we have
Size winSize = Director::getInstance()->getWinSize();
The position of each MenuItem will be set relative to the winSize. This makes it very difficult to align items in a given area, it always expands to the whole screen. I suggest changing it to the followingSize winSize = getContentSize();
So that we can do something likemenu->setContentSize(Size(vsize,hsize));
to easily limit the span of the menu. As by default we will fall back and use the windows size.