Cocos2d-X v3.x : Calling Functions after Delay
I had been facing some issue with calling functions after some delay. So there have been syntax changes happening in cocos2dx, because of which it was a bit difficult to find out which one was the correct approach.
I finally got the below sequence to work:
float delay = 2.0f;
auto delayAction = DelayTime::create(delay); // For 2 Seconds of Delay
auto funcCallback = CallFunc::create([](){
// Add Your Code Here!
// If you want, you can call other functions from here as well
});
this->runAction(Sequence::create(delayAction, funcCallback, NULL));
Though initially I didn't like integrating a function within the code (known as lambda function), I realised this made life simpler by removing cumbersome selector calls, where you had to remember separate calls based on what kinds of arguments need to be passed.
Alternatively, you can also use the below option instead:
void ClassName::func1(){
I finally got the below sequence to work:
float delay = 2.0f;
auto delayAction = DelayTime::create(delay); // For 2 Seconds of Delay
auto funcCallback = CallFunc::create([](){
// Add Your Code Here!
// If you want, you can call other functions from here as well
});
this->runAction(Sequence::create(delayAction, funcCallback, NULL));
Though initially I didn't like integrating a function within the code (known as lambda function), I realised this made life simpler by removing cumbersome selector calls, where you had to remember separate calls based on what kinds of arguments need to be passed.
Alternatively, you can also use the below option instead:
void ClassName::func1(){
Comments
The Woori Casino App will be available 출장안마 at Woori Casino on a mobile or desktop basis. https://octcasino.com/ To play on our mobile or desktop, you can also play with your herzamanindir.com/ desktop browser, หาเงินออนไลน์