我们可以检查CGPoint是否已经触及CMenu项目吗?如果点在按钮中,我需要返回 YES,如果点不在按钮中,我需要返回 NO。
-(BOOL)isButton:(CGPoint)point
{
if(controlMode == 1)
{
for (CCMenu *menu in self.children)
{
// If point in button
return YES;
// else
return NO;
}
}
}
return NO;
}
菜单按钮:
CCMenuItem *pauseItem = [CCMenuItemImage itemFromNormalImage:@"pause.png" selectedImage:@"pause_.png" target:self selector:@selector(pauseGame:)];
CCMenuItem *resetItem = [CCMenuItemImage itemFromNormalImage:@"reset.png" selectedImage:@"reset_.png" target:self selector:@selector(resetClicked:)];
CCMenu *Menu = [CCMenu menuWithItems:pauseItem,resetItem, nil];
Menu.position = ccp(450, 40);
[Menu alignItemsVerticallyWithPadding:5];
[self addChild:Menu];