alanlzl
alanlzl

Reputation: 41

Cocos2d: How to perform a selector (change label) in CCSequence

I need to change the text of label "chainsLabel" after it fades out. However, it seems I cannot do that since showChainNumber is a class method. So how can I avoid this problem?

Thanks for any advice!

Codes below:

+ (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:@""];
}

Upvotes: 0

Views: 100

Answers (2)

alanlzl
alanlzl

Reputation: 41

I find out the following code can work, just for others who have the same question:

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

Upvotes: 0

KARTHIK  RA
KARTHIK RA

Reputation: 469

first change textLabel then fade out

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

Upvotes: 1

Related Questions