CCMenu have alignItemsInColumns that organize items based on number of rows and columns.

Note: this number must be the same as the number of elements or you will get an exception:
<blockquote>‘NSInternalInconsistencyException’, reason: ‘Too many menu items for the amount of rows/columns.’</blockquote>

Create menu with 5 elements, into 2 columns and 3 rows:

<pre style="background-image: URL(; background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"> //Init menu with items
CCMenu* menú = [CCMenu menuWithItems: item1, item2, item3, item4 nil];
//you can add items after init with
//[menu addChild:item5];
//Setup automatic align
[menu alignItemsInColumns: [NSNumber numberWithInt:2], [NSNumber numberWithInt:2], [NSNumber numberWithInt:1],nil];
About alignItemsInColumns:

<ul><li>It have 3 NSNumber parameters so it have 3 rows.</li><li>Each parameter contain the number of columns for each row.</li></ul>
<blockquote><div style="text-align: center;">Item1 Item2</div><div style="text-align: center;">Item3 Item4</div><div style="text-align: center;">Item5</div></blockquote>

Blog Logo

Daniel Gomez Rico




The findings and tips records of an Android-iOS-TheWholeShabang group

Back to Overview