Cocos2d:如何在CCSequence中执行选择器(更改标签)

时间:2014-04-02 11:48:42

标签: ios objective-c cocos2d-iphone

我需要更改标签文本" chainsLabel"在它淡出之后。但是,似乎我不能这样做,因为showChainNumber是一个类方法。那我怎么能避免这个问题呢?

感谢您的任何建议!

以下代码:

+ (void)showChainNumber{
    id action = [CCFadeOut actionWithDuration:0.5f]; // fading out
    id change = [CCCallFunc actionWithTarget:self selector: @selector(changeText:)];
    [chainsLabel runAction:[CCSequence actions:action,change, nil]];
}

- (void)changeText:(id)sender{
    [chainsLabel setString:@""];
}

2 个答案:

答案 0 :(得分:1)

first change textLabel then fade out

try this
[chainsLabel runAction:[CCSequence actions:change,action, nil]];

答案 1 :(得分:0)

我发现以下代码可以正常工作,仅针对具有相同问题的其他代码:

    id action = [CCFadeOut actionWithDuration:0.5f]; // fading out
    id change = [CCCallBlock actionWithBlock:^{[GameLayerChainMode changeText];}];
    [chainsLabel runAction:[CCSequence actions:action,change, nil]];