与之前的cocos2d V2一样,我想知道CCActionCallBlock中的发件人。
id callFunc = [CCCallFuncN actionWithTarget:self selector:@selector(finishSeq:)]; //V2 style
id sequence = [CCSequnece actions: move, callFunc, nil];
[ship runAction:squence];
-(void) finishSeq: (id) sender {
CCSprite* sprite = (CCSprite*) sender;
sprite.opacity = 150;
}
现在在cocos2d V3中,我必须使用一个块,然后替换callFunc:
id callFunc = [CCActionCallBlock actionWithBlock:^{
//how do I know the sender to change it's opacity ??
}]
在这种情况下,我知道它是“船”,但我想将序列用于不同的对象。
答案 0 :(得分:1)
只需将以前用于finishSeq:
方法的代码添加到块中,如下所示:
id callFunc = [CCActionCallBlock actionWithBlock:^{
ship.opacity = 150;
}];
id sequence = [CCSequnece actions: move, callFunc, nil];
[ship runAction:sequence];