所以我希望我的主菜单有一个 ccMenu。我尝试使用垂直对齐和 alignItemsInColumns 进行探索,但所有这些选项都将菜单中的项目居中。如果我想要看起来像这样的东西:
标题
Option 1 has a very long name
Option 2 is short
Shorter
而不是这个:
标题
Option 1 has a very long name
Option 2 is short
Shorter
我怎样才能在 cocos2d 中实现这一点?谢谢您的帮助。
编辑:
我尝试使用此代码,但得到了以下结果:
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];
好像什么都没做。代码有什么问题?