I'm trying to make a method for my CCSprite
based Player
class to start the player instance fading in and out until stopped by calling stopAllActions.
In my Player
class I have:
- (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];
}
This doesn't work and doesn't address the repeat forever part. I know I should probably use CCRepeatForever
but I'm not seeing how to implement it correctly.
Thanks!
I have not run this, but I think others have succeeded with something like:
- (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];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With