cocos2d-objc
cocos2d-objc copied to clipboard
CCLayoutBox with vertical direction: sort order is inverse of expected order
If a layout box has 4 children, then the child nodes are displayed bottom up, ie 4th child node is at the top and 1st child node at the bottom.
Best seen in SpriteBuilder:
This happens only when direction is set to vertical, in horizontal mode the order of nodes is logical (quit is to the left, resume to the right).
this should be a simple fix.
accumulate the maximum height while searching for the max width, and subtract the rolling height from the max height as the nodes are organised.
This is not a bug, but I guess it can be a matter of discussion for how to do this. Bottom up, like the coordinate system – or top down like the UI often is layout.
This is, however, not an easy fix as changing this will break any ccb files in SpriteBuilder.
I didn't think of the effects of this in spritebuilder because I have yet to use it.
I suppose a third layout direction for top down could be added eventually
Yeah, that could be a better option, or a property that defines the direction.
I gave a much simpler fix some time ago: https://github.com/cocos2d/cocos2d-iphone/pull/563
Yeah... I remembered that issue but hadn't gotten around to checking out what happened to it. Is this a regression or did somebody change their mind?
Yes it was committed then reversed for the same reason Vik posted here - breaking things in Sprite Builder... I agree, adding a property for 3rd layout direction would be the best. And making it the default for vertical direction
Top down and vert would be nice defaults