hkysk8r187 at December 1st, 2011 14:44 — #1
I have a function that is not part of a class that I want to call after a delay.
CCDelayTime *delayAction = CCDelayTime::actionWithDuration(3.0f);
CCCallFunc *callSelectorAction = CCCallFunc::actionWithTarget( this, callfunc_selector( ShowWinScreen ) );
helloWorldScene->runAction( CCSequence::actions( delayAction, callSelectorAction, NULL ) );
Now, if I make ShowWinScreen part of the class, such as HelloWorld::ShowWinScreen() then it works, however I don’t want this function part of the class. How can I make a global function call after a delay? Thanks for all the help.
zhangxm at December 1st, 2011 17:07 — #2
What problem did you meet?
May be you should define ShowWinScreen before the definition of HelloWorld.
hkysk8r187 at December 2nd, 2011 08:15 — #3
Even with ShowWinScreen defined earlier, or put into the header I still get the same issue:
callfunc_selector says “invalid type conversion”, and at compile this:
error C2440: ‘type cast’ : cannot convert from ‘void (__cdecl *)(void)’ to ‘cocos2d::SEL_CallFunc’
crana at December 7th, 2011 23:46 — #4
Instead of writing void ShowWinScreen(), type voidShowWinScreen(CCNode* sender)
don’t forget to make changes in header file as well.
You problem will be solved