How to use callback function?

How to use callback function?
0.0 0


The situation is like this I define a sprite and a action
Then I runAction.I want to run some codes when the action is over

The code is like this:
var sprite=cc.Sprite.create(source);
var action=cc.MoveTo.create(1, (200,200));
var sprite.runAction(action);

when the animation is over I want to get some reaction.For example print something


Hi, Jie

var action=cc.MoveTo.create(1, (200,200)); var finish = cc.CallFunc.create(this.removeSprite, this); var seq = cc.Sequence.create(action, finish); sprite.runAction(seq);

For more details or more complexe usage, it’s really a good way to look up in our API documentation :
Search for cc.Sequence on this page.



thank you