2014-01-19 12 views
4

我必须将目标C++转换为C++ 11.我坚持使用以下语法。 我已在testcpp中引用并尝试以下语法。如何在cocos2dx 3.0中调用callfunc函数

这里,我试图代码:

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

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

+0

您需要将NULL更改为您希望调用该方法的对象。 – TigerCoding

回答

2

自从我有同样的问题,它可能帮助某人

CallFunc::create(std::bind(&Hero::stopBlinking,this)); 
1

你需要通过lambda函数做以下

FiniteTimeAction *callAct = CallFunc::create(CC_CALLBACK_0(Hero::stopBlinking, this)); 
    Sequence* seq = Sequence::create(blink,callAct ,NULL); 
    this->runAction(seq); 
1

另一种方式:

CallFuncN *callFunc = CallFuncN::create([&] (Node* node) { 
    // cast node to Hero and do what you need with it 
}); 

但当然,这是更适合喜欢一小段代码:

node->removeFromParent();