How can I disable the touch detection within the action that running, because I don't want the character flying in the sky like a superman if the player clicking and clicking within the action, the character will never land if they keep clicking. I found the method "isDone", is that relate to this method?? player click -> action(cannot click within the action) -> action finish -> click again..... that's what i want~
You could always put a transparent UIView over top of the area you want to "disable" tap input for, have it listen for taps, and have it ignore them. Remove the UIView (or hide it) when you want input to be listened to again.
Why don't you use some kind of (simple version) boolean to remember i.e. isInAction = true and after the action finished isInAction = false...
So when someone clicks, u use something like
if (!isInAction) {
isInAction=true;
try {
doYourAction;
} catch {
...
} finally {
isInAction=false;
}
}
// The Code is some kind of pseudocode, because I haven't yet programmed for the IPhone, just to visualize what I mean.
Disable user interactions in your view till the action completes and then enable it again.
To disable touch
[self.view setUserInteractionEnabled:NO];
To enable touch
[self.view setUserInteractionEnabled:YES];
Please try and be a bit more concise of what you want the next time.
Perhaps I didn't understand your question but is this what you're looking for?
(BOOL)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [Superman Fly]; self.isTouchEnabled = NO; }
(void)SupermanLanded{ self.isTouchEnabled = YES; }
Just gonna make a wild assumption that you're talking about the specific Action class in Cocos2D. If that's true, then you should know that every Action has an "isDone" Bool you can check to see if it's done. Let me know if that's what you're asking and I'll post an example, but there's a huge chance you could be talking about something else because your wording is so confusing ;)
This is the best answer to your question:
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
[[UIApplication sharedApplication] endIgnoringInteractionEvents];