Is there a method that gets called every time a node is deleted? or added?
Along the terms of touchesBegan
a method that gets called every time a touch on the screen happens.
or touchesMoved
a method that gets called when a node gets touched and moved.
So is there such a method that gets called when a node gets removeFromParent
?
I am currently using the update
method to detect if a node is still present like:
SKNode *n = [self childNodeWithName: @"n"];
if (!n)
{
// no n
if (life != 0)
{
[self addChild:_n);
life--;
}
}
Now when ever that node is missing I remove 1 life, and then add the node again.
The problem is the update method is running too fast that 2 lives are removed every time the node is removed. I believe this is because adding the node back is kinda slower that the update method. So it takes 2 loops on the update method before it detects that the node is present again.
update
method. If it is, then I doremoveFromParent
on it. I have tried that, and the same result happened. – majidarif