我正在尝试为我的基于CCSprite的Player类创建一个方法来启动播放器实例淡入和淡出,直到通过调用stopAllActions停止.
在我的Player类中,我有:
- (void)pulse { [self setOpacity:1.0]; CCAction *fadeIn = [CCFadeTo actionWithDuration:0.5 opacity:0.5]; CCAction *fadeOut = [CCFadeTo actionWithDuration:0.5 opacity:1.0]; CCSequence *pulseSequence = [CCSequence actions: fadeIn,// I get a warning about incompatible pointer types... fadeOut,nil]; [self runAction:pulseSequence]; }
这不起作用,也没有解决永远重复的问题.我知道我应该使用CCRepeatForever,但我没有看到如何正确实现它.
谢谢!
我没有运行这个,但我认为其他人已经成功了:
原文链接:/cocos2dx/338129.html- (void)pulse { [self setOpacity:1.0]; CCFadeTo *fadeIn = [CCFadeTo actionWithDuration:0.5 opacity:127]; CCFadeTo *fadeOut = [CCFadeTo actionWithDuration:0.5 opacity:255]; CCSequence *pulseSequence = [CCSequence actionOne:fadeIn two:fadeOut]; CCRepeatForever *repeat = [CCRepeatForever actionWithAction:pulseSequence]; [self runAction:repeat]; }