In order to facilitate debugging, I modified the following code, and output the screen coordinate value of node2 twice in the code. The code is as follows:
After executing the ‘Follow’ animation,
The output value of the variable ‘b’ and the variable ‘a’ is the same, that is to say, regardless of whether the ‘Follow’ animation is executed or not, the coordinates output by the node2 node are the same, and they are all on the screen.
In this case,
If the ‘Follow’ animation is not added, the node2 node can be seen. After adding the ‘Follow’ animation, why can’t the node2 node be seen after the program runs?
I’m not sure what you mean by “follow animation”, but the follow action you’ve created appears to be incorrect, since you’re making node2 follow itself.
The cpp-tests project has a number of examples of correct usage.
Try changing this: node2->runAction(pFollow);
to this this->runAction(pFollow);