cocos2d-objc icon indicating copy to clipboard operation
cocos2d-objc copied to clipboard

CCLayoutBox with vertical direction: sort order is inverse of expected order

Open LearnCocos2D opened this issue 10 years ago • 8 comments

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: screen shot 2014-05-01 at 17 14 31

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

LearnCocos2D avatar May 01 '14 15:05 LearnCocos2D

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.

kalo avatar May 01 '14 22:05 kalo

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.

vlidholt avatar May 02 '14 23:05 vlidholt

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

kalo avatar May 02 '14 23:05 kalo

Yeah, that could be a better option, or a property that defines the direction.

vlidholt avatar May 02 '14 23:05 vlidholt

I gave a much simpler fix some time ago: https://github.com/cocos2d/cocos2d-iphone/pull/563

iMobCoding avatar May 03 '14 19:05 iMobCoding

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?

slembcke avatar May 03 '14 19:05 slembcke

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

iMobCoding avatar May 03 '14 19:05 iMobCoding

Top down and vert would be nice defaults

ryanmarfone avatar Dec 11 '15 04:12 ryanmarfone