How to call callfunc function in cocos2dx 3.0

Vanarajan picture Vanarajan · Jan 19, 2014 · Viewed 12.6k times · Source

I have to convert objective c++ to C++ 11. I have stuck with the following syntax. I have referred in testcpp and try the following syntax.

Here the code which i tried:

this->runAction
(
 Sequence::create
 (
  blink,
  CallFunc::create(CC_CALLBACK_0(Hero::stopBlinking, NULL)),    -> issue this line.
  NULL
  )
 );

It shows error "no matching function for call to 'bind'" in "CallFunc::create". Can any one assist or help me.

Answer

user2815602 picture user2815602 · Jan 20, 2014

In your coding, just replace the below code:

 CallFuncN::create(CC_CALLBACK_1(Hero::stopBlinking,this));

Because

 CallFunc can be created with an @std::function<void()>  
 CallFuncN can be created with an @std::function<void(Node*)

Refer:

http://www.cocos2d-x.org/wiki/Release_Notes_for_Cocos2d-x_v300/diff/5