我只想调用一个接受Sprite类型参数的序列中的方法 -
到目前为止我的代码 -
auto obstacleSprite = CCSprite::create(OBSTACLE_SPRITE);
obstacleSprite->setPosition(Vec2(visibleSize.width*0.25,visibleSize.height*0.15));
this->addChild(obstacleSprite);
Sequence *seq = Sequence::create(DelayTime::create(randomDelay),CallFunc::create( std::bind(&GamePlayScene::createObstacles,this) ), NULL);
this->runAction(seq);
要调用的方法
void GamePlayScene::createObstacles(Sprite *spriteObj){
CCLOG("HA HA HA");
}
我没有得到如何在CallFunc中传递Sprite(obstacleSprite)对象。请帮忙。
答案 0 :(得分:2)
你可以做这样的事情(我现在不能测试):
Sequence *seq = Sequence::create(DelayTime::create(randomDelay), CallFunc::create(std::bind(&GamePlayScene::createObstacles, this, obstacleSprite)), NULL);
另外,请看一下:" tests / cpp-tests / Classes / ActionsTest / ActionsTest.cpp",第981行和第1010行。