CCMenuAdvanced
CCMenuAdvanced copied to clipboard
Content size includes an extra amount of padding
Content size is currently calculated like this (for vertical alignment).
float width = 0.0;
float height = 0.0;
// calculate contentSize,
CCMenuItem *item = nil;
CCARRAY_FOREACH(children_, item)
{
height += item.contentSize.height * item.scaleY + padding;
width = MAX(item.contentSize.width * item.scaleX, width);
}
This includes 1 padding per item. But the last padding should always be removed. A better method is as follows:
float width = 0.0;
float height = 0.0;
// remove 1 amount of padding
int itemCount = [children_ count];
if ( itemCount > 0 )
{
height -= padding;
}
// calculate contentSize,
CCMenuItem *item = nil;
CCARRAY_FOREACH(children_, item)
{
height += item.contentSize.height * item.scaleY + padding;
width = MAX(item.contentSize.width * item.scaleX, width);
}