Cocos2D Disable CCMenu
I am new to Cocos2d. I gonna create a sample game which has Menu(CClayer) ,in which each menuitems add CClayer as a child to the Menu Layer. Now i add the settings layer as a child to the Menu layer. when i select the settings layer, the touch detected in Menu layer not in settings layer. how to disable CCMenu in Menu Layer.
Menu Layer:Which contains CCMenu ; Settings Layer: which contains also CCMenu;
H开发者_运维技巧elp me,
From your description without codes i can only tell you this line of code..
MenuLayer.yourMenuObj.isTouchEnabled = NO;
In my MenuLayer(CCLayer) which has ccmenu declared in Init Method
{
CCMenuItem *Play = [ CCMenuItemFont itemFromString:@"Level Select" target:self
selector:@selector(toPlay) ];
CCMenuItem *options = [ CCMenuItemFont itemFromString:@"Options" target:self
selector:@selector(toSettings) ];
CCMenu *mainMenu=[CCMenu menuWithItems:startGame,settings,nil];
[mainMenu alignItemsVertically];
mainMenu.position = ccp(240,160);
[self addChild:mainMenu z:1];
}
-(void) toPlay
{
OptionsLayer *tOptionsLayer=[OptionsLayer node];
[self addChild:tOptionsLayer z:2];
}
When i touch the "Options" in Menu it shows the OptionsLayer as a child to the MenuLayer. The OptionsLayer have Menu Items , when i touch the Menu items in OptionsLayer , the touch Touched in Menulayer. so again it shows the OptionsLayer. how to disable the touch on menuitems in MenuLayer.
精彩评论