Hi, i just created grid menu from other code found on the internet. It's from three menus, menu image, menu font (text, number, 1,2,3,4,5...) and menu stars. there is a function, sorting menuitems to the grid. You can call it and set up like you want.
I hope it help someone.
P.S.: Image at the bottom
@implementation Levely
-(id) init
{
if( (self=[super init]) ) {
.
.
.
.
.
.
.//menuitems setuping...
CCMenu *menu =[CCMenu menuWithItems: item1, item2, item3, item4, item5,item6,item7,item8,item9,item10,item11,item12, item13, nil];
[menu alignItemsInColumns:[NSNumber numberWithUnsignedInt:4],[NSNumber numberWithUnsignedInt:4], [NSNumber numberWithUnsignedInt:4], [NSNumber numberWithUnsignedInt:1],nil];
[self addChild: menu];
CCMenu *menu2 = [CCMenu menuWithItems:it1, it2,it3,it4,it5,it6,it7,it8,it9,it10,it11,it12,it13, nil];
[self addChild:menu2];
CCMenu *menu3 = [CCMenu menuWithItems:ih1, ih2, ih3,ih4,ih5,ih6,ih7,ih8,ih9,ih10,ih11,ih12,ih13, nil];
[self addChild:menu3];
NSMutableArray *pole = [[NSMutableArray alloc] initWithObjects:item1, item2, item3, item4, item5,item6,item7,item8,item9,item10,item11,item12, item13, nil];
NSMutableArray *pole2 = [[NSMutableArray alloc] initWithObjects:it1, it2,it3,it4,it5,it6,it7,it8,it9,it10,it11,it12,it13, nil];
NSMutableArray *pole3 = [[NSMutableArray alloc] initWithObjects:ih1, ih2, ih3,ih4,ih5,ih6,ih7,ih8,ih9,ih10,ih11,ih12,ih13, nil];
[self usporiadajMenuItemy:pole padding:65 pozicia:100 col:4 row:4 scale:1];
[self usporiadajMenuItemy:pole2 padding:65 pozicia:100 col:4 row:4 scale:0.7];
[self usporiadajMenuItemy:pole3 padding:65 pozicia:80 col:4 row:4 scale:0.6];
[ih3 setOpacity:0];
[ih5 setOpacity:0];
[ih12 setOpacity:0];
[ih13 setOpacity:0];
item12.isEnabled = NO;
it12.isEnabled = NO;
item13.isEnabled = NO;
it13.isEnabled = NO;
}
return self;
}
-(void)usporiadajMenuItemy:(NSArray*)pole padding:(int)padding pozicia:(int)pozicia col:(int)coll row:(int)roww scale:(float)scale{
int col = 0, row = 0;
for (CCMenuItem* item in pole)
{
// Calculate the position of our menu item.
item.position = CGPointMake(self.position.x + col * padding -pozicia, self.position.y - row * padding +pozicia);
// Increment our positions for the next item(s).
++col;
if (col == coll)
{
col = 0;
++row;
if( row == roww )
{
col = 0;
row = 0;
}
}
[item setScale:scale];
}
}