Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get left-aligned cocos2d menu
    primarykey
    data
    text
    <p>So I want my main menu to have a ccMenu. I tried exploring with align vertically and alignItemsInColumns but all these options center the items within the menu. If I wanted something that looked like this:</p> <p><strong>Title</strong></p> <pre><code> Option 1 has a very long name Option 2 is short Shorter </code></pre> <p>instead of this:</p> <p><strong>Title</strong></p> <pre><code>Option 1 has a very long name Option 2 is short Shorter </code></pre> <p>How could I achieve this in cocos2d? Thanks for the help.</p> <p><strong>EDIT:</strong></p> <p>I tried using this code but I got this result:</p> <pre><code>CCLabelTTF * sin = [CCLabelTTF labelWithString:@"Single Player" dimensions:CGSizeMake(120, 25) alignment:UITextAlignmentLeft fontName:font fontSize:20]; CCMenuItem * item1 = [CCMenuItemLabel itemWithLabel:sin target:self selector:@selector(goToSinglePlayer:)]; CCLabelTTF * spl = [CCLabelTTF labelWithString:@"Splitscreen" dimensions:CGSizeMake(100, 25) alignment:UITextAlignmentLeft fontName:font fontSize:20]; CCMenuItem * item2 = [CCMenuItemLabel itemWithLabel:spl target:self selector:@selector(goToSplitscreen:)]; CCLabelTTF * ach = [CCLabelTTF labelWithString:@"Achievements" dimensions:CGSizeMake(130, 25) alignment:UITextAlignmentLeft fontName:font fontSize:20]; CCMenuItem * item3 = [CCMenuItemLabel itemWithLabel:ach target:self selector:@selector(goToAchievements:)]; CCLabelTTF * str = [CCLabelTTF labelWithString:@"Store" dimensions:CGSizeMake(50, 25) alignment:UITextAlignmentLeft fontName:font fontSize:20]; CCMenuItem * item4 = [CCMenuItemLabel itemWithLabel:str target:self selector:@selector(goToStore:)]; CCLabelTTF * set = [CCLabelTTF labelWithString:@"Settings" dimensions:CGSizeMake(80, 25) alignment:UITextAlignmentLeft fontName:font fontSize:20]; CCMenuItem * item5 = [CCMenuItemLabel itemWithLabel:set target:self selector:@selector(goToSettings:)]; CCMenu * mainMenu = [CCMenu menuWithItems:item1, item2, item3, item4, item5, nil]; [mainMenu setColor:ccBLACK]; [mainMenu alignItemsVerticallyWithPadding:10]; mainMenu.position = ccp(size.width/6, size.height/2); [self addChild:mainMenu]; </code></pre> <p><img src="https://i.stack.imgur.com/JImr2.png" alt="Game Screen"></p> <p>Seems like it didn't do anything. What's wrong with the code?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload