Reputation: 22042
What's CCCallBlockN alternative for Cocos2d 3.0 ?
Here is my Cocos2d 2.0 Code:
id calBlock = [CCCallBlockN actionWithBlock:^(CCNode *node){
node.position = orign;
}];
Upvotes: 0
Views: 817
Reputation: 64477
The CCCallBlockN
and CCCallBlockND
variants have always been superfluous since blocks can reference objects in the local scope:
id someData = (some data however created or obtained);
CCNode* someNode = (some node however created or obtained);
id callBlock = [CCActionCallBlock actionWithBlock:^{
someNode.position = origin;
[someData quickDoSomething];
}];
[someNode runAction:callBlock];
You just need to have a reference like someNode
in the outer scope of the block in order to use it inside the block.
You will usually have the desired node reference because after all you're going to run the action on the desired node after creating the action. Only in cases where you create the actions first and run them later would the passed-in node be useful, but I guess that's a rare situation and probably not good style anyway.
Upvotes: 2