Game Development Reference
In-Depth Information
Of course, the CCCallFunc actions also work with CCRepeatForever sequences.
Your methods will be called repeatedly at the appropriate time.
CCCallBlock Actions
For all intents and purposes, you can replace the CCCallFunc actions with
CCCallBlock actions. The only thing block actions don't allow is passing an arbit-
rary void* pointer—mainly because doing so conflicts with ARC (see the previous
Caution box).
The CCCallBlock , CCCallBlockN , and CCCallBlockO classes are initialized
and used as follows:
CCCallBlock* blockA = [CCCallBlock actionWithBlock:^void(){
CCLOG(@"action with block got called");
CCCallBlock* blockB = [CCCallBlock actionWithBlock:^{
CCLOG(@"action with block got called");
CCCallBlockN* blockN = [CCCallBlockN actionWithBlock:^void(CCNode* node){
CCLOG(@"action with block got called with node %@", node);
CCCallBlockO* blockO = [CCCallBlockO actionWithBlock:^void(id object){
CCLOG(@"action with block got called with object %@", object);
CCSequence* sequence = [CCSequence actions:block, blockN, blockO, nil];
[label runAction:sequence];
The blockA and blockB instances of the CCCallBlock class only differ in the
way the block is declared. Because that particular block has no return value, you can
omit void . And because it takes no parameters, you can also omit the brackets as well.
This means ^void(){ .. } and ^{ .. } declare exactly the same type of block,
the latter simply being a shorthand for the former.
Search Nedrilad ::

Custom Search