I am REALLY confused about how to use CCCallFunc. I have used many types of callbacks before in C and C++ but this one has alluded me for about 4 hours now…. So any help would be greatly appreciated.
I have a class called “Character” that contains a CCSprite* and a series of CCAction*’s. I have loaded the sprite in correctly, and have filled all the actions with animations from a plist. when I play them one at a time, all is good! When I setup a CCSequence containing just the animations and play that, again all is good! However at the end of the sequence I would really like to call a callback to change to another animation sequence based on flags set during the current sequence. So fairly vanilla stuff. But I cant seem to get the syntax/configuration of the CCCallFunc/CCCallFuncN/CCCallFuncND to work at all…… I am trying to set a member method of “Character” to respond to the call.
Current code setup:
Character is a class
checkForAnimationChange is the member method of Character I wish to call when the sequence finishes
Code I tried and failed:
Note - I tried all 3 flavors of CCCallFunc
Note - I tried both static and non static versions of checkForAnimationChange
- CCCallFunc::actionWithTarget(this, callfunc_selector(Character::checkForAnimationChange)); //Wont compile
- CCCallFunc::actionWithTarget(NULL, callfunc_selector(Character::checkForAnimationChange)); //This one compiles, ONLY when checkForAnimationChange is not static. Which causes a crash.
- void (Character::*ptrToMember)();
ptrToMember = &Character::checkForAnimationChange;
CCCallFunc::actionWithTarget(NULL, callfunc_selector(ptrToMember)); //Wont compile
- A ton of other ideas that passed through my head over the last 4 hours……
So long story short. How do I setup a CCCallFunc to call a class member method….