user773578
user773578

Reputation: 1161

Handling callbacks or checking if an action is complete

How does one find out when an action is complete or when a sequence of actions is complete?

I have a bunch of sprites with different actions depending on the state of them, and when e.g. the sprite is pressed and the state is e.g. state1, then some code should execute. if the sprite is pressed during the execution of cocos2d behind the scenes, then the next state is triggered.

I need to know when the first actions are complete so that I can then "unlock" the sprite and allow for further touch detection.

How do I check if the sequence is done?

Thanks

Upvotes: 1

Views: 2614

Answers (1)

ScottPetit
ScottPetit

Reputation: 814

If you're using CCActions, which it seems like you are, then you can just use CCCallFuncN. It looks something like this:

id doneAction = [CCCallFuncN actionWithTarget:self selector:@selector(yourMethod)];

Just add that to the sequence of actions you're running and it will call 'yourMethod' when they get done.

Upvotes: 6

Related Questions