Aligning CCMenu to a grid

前端 未结 5 1452
星月不相逢
星月不相逢 2021-01-14 07:38

Does anybody know the best practice approach to getting an array of CCMenuItems to align to a grid? This is a cocos2d question

For example :

int lev         


        
5条回答
  •  花落未央
    2021-01-14 08:10

    You just have to call one of the overloaded alignItemsInColumns or alignItemsInRows methods. For example if you have 15 menu items and you want 3 rows of 5 columns, do this:

    CCMenu* menu = [CCMenu menuWithItems:...];
    NSNumber* itemsPerRow = [NSNumber numberWithInt:5];
    [menu alignItemsInColumns:itemsPerRow, itemsPerRow, itemsPerRow, nil];
    

    The only down side is that there doesn't seem to be a way to set padding when aligning to a grid.

提交回复
热议问题