在cocos2dx中延迟后调用一个函数

时间:2015-01-23 15:05:45

标签: android cocos2d-x

尝试在延迟后运行GoToGameOverScene(this)函数。我得到“无视值,因为它应该是”

// set up the time delay
DelayTime *delayAction = DelayTime::create(2.5f);
// perform the selector call
CallFunc *callSelectorAction = CallFunc::create(this, SEL_CallFunc(GoToGameOverScene(this)));
// run the action
this->runAction(Sequence::create(delayAction, callSelectorAction, NULL));

其他功能如下:

void GameScreen::GoToGameOverScene(cocos2d::Ref *pSender)
{
    auto scene = GameOver::createScene();

    Director::getInstance()->replaceScene(scene);
}

4 个答案:

答案 0 :(得分:1)

SpriteNM->runAction(Sequence::create(DelayTime::create(1.0),CallFunc::create(std::bind(&ClassNM::MethodNM, this,IfParameter)),NULL));

答案 1 :(得分:0)

更改此

CallFunc *callSelectorAction = CallFunc::create(this, SEL_CallFunc(GoToGameOverScene(this)));

CallFunc *callSelectorAction = CallFunc::create(this, callfunc_selector(ClassName::GoToGameOverScene));

干杯...

答案 2 :(得分:0)

如果您使用的是v 3.3,则必须以这种方式使用它:

CallFunc *callSelectorAction = CallFunc::create(this, CC_CALLBACK_1(ClassName:GoToGameOverScene,this));

其中,CC_CALLBACK_1在您的函数有一个参数时使用。

答案 3 :(得分:0)

this->runAction(Sequence::create(DelayTime::create(1.0),CallFunc::create(std::bind(&ClassName::MethodName, this,IfParameter)),NULL));

SpriteName->runAction(Sequence::create(DelayTime::create(1.0),CallFunc::create(std::bind(&ClassName::MethodName, this,IfParameter)),NULL));