0

我正在尝试使用字符串数组使 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++;
}

谢谢!!!

4

1 回答 1

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];
}
于 2013-09-07T07:17:26.833 回答