Wednesday, 17 July 2013

To Disable touch of all CCMenu items or sub nodes on a CCLayer

Call below methods as needed:

[self MenuStatus:NO Node:self]; // to disable touch 

[self MenuStatus:YES Node:self]; // to enable touch


Method:

-(void)MenuStatus:(BOOL)_enable Node:(id)_node
{
    for (id result in ((CCNode *)_node).children) {
        if ([result isKindOfClass:[CCMenu class]]) {
            for (id result1 in ((CCMenu *)result).children) {
                if ([result1 isKindOfClass:[CCMenuItem class]]) {
                    ((CCMenuItem *)result1).isEnabled = _enable;
                }
            }
        }
        else
            [self MenuStatus:_enable Node:result];
    }

}