I move an instance of CCSprite
in my Cocos2D-based iPhone game like this:
[mySprite runAction:[CCMoveBy actionWithDuration:1.0
position:ccp(10, 10)]];
How can I get a callback everytime the sprite moves?
I'd like to do something like this:
[self registerForCallbacksFrom:mySprite
selector:@selector(spriteMovedOneStep)];
So spriteMovedOneStep
would be called everytime mySprite moves. Would be nice to specify the frequency of the callback too so minimize CPU usage.
One possible solution is to subclass CCMoveBy and call your callback from it's update method. You also can setup frequency and everything you want with this approach.