I am creating a particle animation with CAEmitterLayer and CAEmitterCell instances. There is no problem with the animation but I want them to fade out slowly. I am using the code below but the particles disappear suddenly, no fade out animation there.
NSString *animationPath = [NSString stringWithFormat:@"emitterCells.%@.birthRate", cell.name];
CABasicAnimation *birthRateAnimation = [CABasicAnimation animationWithKeyPath:animationPath];
birthRateAnimation.fromValue = [NSNumber numberWithFloat:30.0];
birthRateAnimation.toValue = [NSNumber numberWithFloat:0.0];
birthRateAnimation.removedOnCompletion = NO;
birthRateAnimation.duration = 10.0;
[emitterLayer addAnimation:birthRateAnimation forKey:@"birthRate"];
This code runs in a for loop for five different emitter cells.
Do you spot an error in this code?
Thanks
For the CAEmitterCell's set the alpha speed value to -1.0/lifetime.
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