Reputation: 12446
I have an CCMenuItem
and I want to disable it until an animation is finished, but I don't want to disable all touches with:
[CCDirector sharedDirector].touchDispatcher.dispatchEvents = NO;
Any easy solution?
Upvotes: 1
Views: 370
Reputation:
You can disable the CCMenuItem with
CCMenuItem *item = [[CCMenuItem alloc] initWith...];
item.isEnabled = YES;
and enable it afterwards.
Upvotes: 1
Reputation: 39091
Use CCSequence
to first use the animation action and when that is done you create an action that calls a function with the CCMenuItem
as parameter and in that function make it enabled.
Code example: (PS: It was a long time since I used cocos2d.)
{
...
CCMenuItem *menuItem = [CCMenuItem itemWith...];
menuItem.isEnable = NO;
CCMenu *menu = [CCMenu menuWithItems:menuItem, nil];
[self addChild:menu];
[menuItem runAction:[CCSequence actions:[CCAction actionWith...], [CCCallFunc actionWithTarget:self selector:@selector(enable:)], nil]];
...
}
-(void)enable:(CCMenuItem *)item {
item.isEnable = YES;
}
Upvotes: 1