vlg789
vlg789

Reputation: 751

Cocos2d C++ equivalent of objective-c function CCCallBlock actionWithBlock

Does anyone knows what is the c++ equivalent of objective-C CCCallBlock actionWithBlock ?

[CCCallBlock actionWithBlock:^{ ... code here .. }]

Upvotes: 0

Views: 142

Answers (1)

yasuharu519
yasuharu519

Reputation: 244

In the cocos2d-x, you can't use CCCallBlock, instead, you can use cocos2d::CallFunc and since cocos2d-x v3.0, you can use C++11 features, so it would be pretty much simple.

If the code is like this,

id block = [CCCallBlock actionWithBlock:^{
             [do func1]
             [do func2]
           }];

then, it would be like the following code.

auto block = cocos2d::CallFunc::create(
                    [&](){
                          func1();
                          func2();
                     });

And then you can make the spite do block as like the one with CCCallBlock.

Upvotes: 1

Related Questions