Lambda expression on action completion

Lambda expression on action completion
0.0 0


In Cocos2d, I was able to do this:

    id easek = [CCEaseSineInOut actionWithAction:[CCMoveTo actionWithDuration:0.1 position:ccp(target.x, target.y - kKeyPressOffset)]];
    id spawnk = [CCSpawn actions:easek, scalek, nil];
    id endblock = [CCCallBlock actionWithBlock:^
        [self updateCurrentPositionFromActual];
        z = initial_z;
        [self.parent reorderChild:self z:z + kKeyCapHeight + 2];
        [spriteShadow.parent reorderChild:spriteShadow z:z + kKeyBaseLine];
    [self runAction:[CCSequence actions: spawnk, endblock, nil]];

How would I achieve the same effect in cocos2d-x using lambda expressions instead of the CCCallBlock?

Note, I’ve got cocos2d-x compiling in Xcode for C++11 no problem.


I create this small class when I port my game to cocos2d-x. See my gist:


I’ve tried it, it works great. Many, many thanks!