如何在cocos2dx 3.0中调用callfunc函数

Van*_*jan 4 cocos2d-x c++11 cocos2d-x-3.0

我必须将目标c ++转换为C++ 11.我坚持使用以下语法.我在testcpp中引用并尝试以下语法.

这里是我试过的代码:

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

它显示错误"no matching function for call to 'bind'" in "CallFunc::create". 可以任何人协助或帮助我.

小智 8

在您的编码中,只需替换以下代码:

 CallFuncN::create(CC_CALLBACK_1(Hero::stopBlinking,this));
Run Code Online (Sandbox Code Playgroud)

因为

 CallFunc can be created with an @std::function<void()>  
 CallFuncN can be created with an @std::function<void(Node*)
Run Code Online (Sandbox Code Playgroud)

参考:

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