我本来希望屏幕左上角的“切换播放器”按钮上方有一个“菜单”按钮,但“菜单”按钮的上部位于屏幕上方。怎么来的?这是一个错误吗?
左对齐没问题。
谢谢!
-(void) superSceneEnded
{
_sceneEnded = true;
CCMenu *menu = [CCMenu menuWithItems:nil];
menu.anchorPoint = ccp(0, 1); // Upper left corner
menu.position = ccp(2, _winSize.height - 2); // Almost at upp left corner of screen
[self addChild:menu];
[self addButton:menu :@"Menu" :@selector(goToMenu)];
if ([MatchMgr instance].currentMatch.isOnDevice)
{
[self addButton:menu :@"Switch player" :@selector(switchPlayer)];
}
[menu alignItemsVerticallyWithPadding:10];
}
-(void) addButton: (CCMenu*) menu: (NSString*) text: (SEL) selector
{
CCMenuItem *menuItem = [CCMenuItemImage itemFromNormalImage:@"button.png" selectedImage:@"button-pressed.png" target:self selector:selector];
menuItem.anchorPoint = ccp(0, 1); // Upper left corner
//menuItem.scale = 0.5;
[menu addChild:menuItem];
// The code below is not relevant for the question, but I keep it for your understanding.
CCLabelBMFont *bmText = [CCLabelBMFont labelWithString:text fntFile:@"MainFont.fnt"];
bmText.color = ccBLACK;
bmText.scale = 0.75;
bmText.alignment = NSTextAlignmentCenter;
bmText.position = ccp(75, 15);
[menuItem addChild: bmText];
}