如何在cocos2d中完成runAction后添加自己的完成块

时间:2015-08-21 18:37:47

标签: cocos2d-iphone cocos2d-x-3.0

我现在是cocos2d的新手,我现在采取以下措施:

[self.rewardLabel runAction:[CCSequence actionOne:[CCFadeOut actionWithDuration:3.5] two:[CCHide action]]];

我想在完成这一系列动作后做点什么。我怎么能实现这一点,因为持续时间为3.5秒?

1 个答案:

答案 0 :(得分:1)

我假设cocos2d 2.2用于上述代码段。如果您使用CCSequence的数组构造函数,您可以构建一些复杂的东西。以下是带有调用块的序列的示例(来自我的代码):

id scaleDown = [CCScaleTo actionWithDuration:.25 scaleX:0.f scaleY:1.f];
id scaleUp  = [CCScaleTo actionWithDuration:.25 scaleX:1.f scaleY:1.f];
id flip = [CCCallBlock actionWithBlock:^{ _normal.flipX=YES;}];
id unflip = [CCCallBlock actionWithBlock:^{_normal.flipX=NO;}];
id once = [CCSequence actions:scaleDown,flip,scaleUp,unflip,nil];
id twice = [[once copy] autorelease];
id three = [[once copy] autorelease];
id four = [[once copy] autorelease];
id done = [CCCallBlock actionWithBlock:^{
    _normal.anchorPoint=ccp(0,0);
    _normal.position=ccp(0,0);
}];
id all = [CCSequence actions:once,twice,three,four,done,nil];

[_normal runAction:all];