Trying to fade out CCLabelTTF, change text, and then fade back in

954 views Asked by At

I am trying to make CCLabelTTF change its text every 10 seconds using an array of strings. This is the code I have so far, but it is giving me this error!

2013-09-07 15:47:34.618 MazeIt[6271:1b503] -[TitleLayer opacity]: unrecognized selector sent to instance 0xa553bb0

If anyone who is more experienced with runAction and CCLabel could help me out, it would be extremely helpful!

This is the code I have: I have _list which is the array of strings, _text which is CCLabelTTF which I want to manipulate

In init _text and _list is created:
[self schedule:@selector(callback) interval:10.0f];

-(void) callback
{
    id fadeIn = [_text runAction:[CCFadeTo actionWithDuration:0.5 opacity:127]];
    id fadeOut = [_text runAction:[CCFadeTo actionWithDuration:0.5 opacity:255]];
    id change = [CCCallFunc actionWithTarget:_text selector: @selector(changeText:)];
    id sequence = [CCSequence actions: fadeIn, change, fadeOut, nil];
    [self runAction: sequence];
}
- (void)changeText:(id)sender{
    [_text setString:@"You completed no levels!"];
//    [_text setString:_list[0]];
//    [_text setString:_list[_next%[_list count]]];
    _next++;
}

Thank you!!!

1

There are 1 answers

0
nick.jw.park On BEST ANSWER

LOL my bad it was a really simple error, and some tweaking fixed it! I am just going to leave this up here in case someone else is trying to do the same thing! The correct code is:

-(void) callback
{
    id fadeIn = [CCFadeTo actionWithDuration:0.5 opacity:0];
    id fadeOut = [CCFadeTo actionWithDuration:0.5 opacity:255];
    id change = [CCCallFunc actionWithTarget:self selector: @selector(changeText:)];
    id sequence = [CCSequence actions: fadeIn, change, fadeOut, nil];
    [_text runAction: sequence];
}