Cocos2d-x CCCallBlock explanation

Hello!
I have a problem porting some code from Obj-C to C++

for (CCSprite *sprite in tmpArr)
{                        
         actionBlock = [CCCallBlock actionWithBlock:^{
                            [sprite runAction:[CCFadeIn actionWithDuration:0.25]];
                        }];
         [lineArr addObject:actionBlock];
}

Later in the code there is something like this:

[self runAction:[CCSequence actionWithArray:lineArr]];

So I created a Vector<Node*> lineVec so that I can use later the Sequence::create method but the part where I have problems is this:

     actionBlock = [CCCallBlock actionWithBlock:^{
                        [sprite runAction:[CCFadeIn actionWithDuration:0.25]];
                    }];

Whats the best way to port it? I though about CC_CALLBACK_1 but I get an error when i do something like this:

auto actionBlock = CallFunc::create(CC_CALLBACK_1(MainScene::runLineAction(sprite), this));

and runLineAction(Sprite* s) looks like this:

void MainScene::runLineAction(Sprite* s)
{
    s->runAction(FadeIn::create(0.25));
}

Hello,

Try with following code.

auto actionBlock = CallFunc::create(CC_CALLBACK_0(MainScene::runLineAction, this,sprite));

Regards,

1 Like

lol, yes this works! :open_mouth: THANKS!