尝试淡出CCLabelTTF,更改文本,然后淡入

时间:2013-09-07 06:58:41

标签: cocos2d-iphone opacity unrecognized-selector fadeto cclabelttf

我试图让CCLabelTTF使用字符串数组每10秒更改一次文本。 这是我到目前为止的代码,但它给了我这个错误!

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

如果对runAction和CCLabel更有经验的人可以帮助我,那将非常有帮助!

这是我的代码: 我有_list是字符串数组,_text是CCLabelTTF,我想操纵

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++;
}

谢谢!!!

1 个答案:

答案 0 :(得分:0)

很抱歉,这是一个非常简单的错误,并且有些调整修复了它! 我只是想把它留在这里以防其他人试图做同样的事情! 正确的代码是:

-(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];
}