I want to know which method of child get called when we remove any Node from its parent.
I created MyLayer by extending Layer class and then add my own sprite MySprite which extend Sprite class of cocos2d-x framework. I need to decrease a counter when child removed so i need a method which i'd override in my MySprite class.
I use this method to remove.
parent->removeChild(child);
Here parent is MyLayer and child is MySprite pointer.
If the child is running these two methods will be called:
If you remove the child with
cleanup = true
(which is the default value),child->cleanup();
will be also called.So the best solution for you would be to override
virtual void onExit();
function of the child. And in the overridden method don't forget to callNode::onExit();
or whatever your superclass will be.