I am working on a game for iOS and I have to schedule an NSMutableArray addobject to be able to see my animation.
[monster stopAllActions];
[monster startDeathAction];
[monsterToDelete addObject: lilMonster];
I stop all actions on the monster object, then start the death animation and then I insert it into an array to delete it. The fact is that I cannot see the animation because it instant-deletes the monster.
I have been trying to schedule that addObject but I cannot find a way to do it.
Can I have some help from you? Thanks 🙂
In short: i want to wait an animation to finish to do a [array addObject: object];
PS: I didn’t mention it. I am working with Cocos2d
You have two options here:
OPTION 1:Add a variable to monster that will basically tell if it’s death action has finished. Set it to true when you want to delete it. You’ll also have to modify the code that cleans up the monstersToDelete array to only delete the monsters that have their death action finished.
OPTION 2: Make the monster call a delegate when the death action is done. Something like:
and on the code where you are starting the death action add