C++ cocos2dx中的CCCallFunc用法
我在这一行收到警告,指出actionWithTarget方法已被弃用。 有人能告诉我们在cocos2dx中可以使用哪种替代方法吗C++ cocos2dx中的CCCallFunc用法,c++,cocos2d-x,C++,Cocos2d X,我在这一行收到警告,指出actionWithTarget方法已被弃用。 有人能告诉我们在cocos2dx中可以使用哪种替代方法吗 CCCallFunc *callBackfunc = CCCallFunc::actionWithTarget(this, callfunc_selector(GamePlay::startTrumphetAnimation)); 谢谢试试这个: CCCallFunc *func = CCCallFunc::cr
CCCallFunc *callBackfunc = CCCallFunc::actionWithTarget(this,
callfunc_selector(GamePlay::startTrumphetAnimation));
谢谢试试这个:
CCCallFunc *func = CCCallFunc::create(this, callfunc_selector(GameOverScene::MyFunction));
//同时声明此函数
void GameOverScene::MyFunction(CCObject* sender)
{
}
试试这个:
CCCallFunc *func = CCCallFunc::create(this, callfunc_selector(GameOverScene::MyFunction));
//同时声明此函数
void GameOverScene::MyFunction(CCObject* sender)
{
}
如果您使用的是新版本的Cocos2dx
auto funcCallAction = CallFunc::create([=](){
// TODO: do you stuff here
startTrumphetAnimation();
});
runAction(funcCallAction);
如果您使用的是新版本的Cocos2dx
auto funcCallAction = CallFunc::create([=](){
// TODO: do you stuff here
startTrumphetAnimation();
});
runAction(funcCallAction);
试试这个
CCCallFunc *calFunc = CCCalFunc::create(this,callfunc_selector(ClassName::methodName));
如果您使用的是cocos2dx v3:
CallFunc *calFunc = CalFunc::create(CC_CALLBACK_1(ClassName::methodName,this));
void ClassName::methodName(Ref* sender)
{
}
试试这个
CCCallFunc *calFunc = CCCalFunc::create(this,callfunc_selector(ClassName::methodName));
如果您使用的是cocos2dx v3:
CallFunc *calFunc = CalFunc::create(CC_CALLBACK_1(ClassName::methodName,this));
void ClassName::methodName(Ref* sender)
{
}
以这种方式编写函数定义 无效游戏性::startTrumphetAnimation(cObject*sender) {
}以这种方式编写函数定义 无效游戏性::startTrumphetAnimation(cObject*sender) {
}如果您使用的是COCOS2DX-3.0或3.14v
runAction( CallFunc::create([=]() { startTrumphetAnimation() }));
但是,如果您使用的是COCOS2DX-3.0或3.14v,那么您应该在GamePlay类的任何方法中写入这一行。
runAction( CallFunc::create([=]() { startTrumphetAnimation() }));
但是你应该在游戏类的任何方法中写这一行。在函数定义中传递参数,如startTrumphetAnimation(cObject*sender)在函数定义中传递参数,如startTrumphetAnimation(cObject*sender)“(=)是什么意思?[=]通过复制捕获lambda主体中使用的所有自动变量,如果存在则通过引用捕获当前对象“(=)”表示什么?[=]通过复制捕获lambda主体中使用的所有自动变量,如果存在则通过引用捕获当前对象