Sunday, June 02, 2013

Running Code After X Seconds Delay in Cocos2D-x

Assuming you have a class called YOUR_CLASS in Cocos2-dx

You use something like this:

CCCallFunc* moveCallback = CCCallFunc::create(this, callfunc_selector(YOUR_CLASS::callfunc_selector_startTurn));

CCDelayTime* delayAction = CCDelayTime::create(2.0f);

this->runAction(CCSequence::create(delayAction, moveCallback, NULL));


And include a function like this for the CCCallFunc to call


void YOUR_CLASS::callfunc_selector_startTurn(void)
{
// do some stuff
}

Inspired by this blog post:





0 Comments:

Post a Comment

<< Home