I am using CAEmitterLayer to emit some star images. Our clients want to change the alpha of the star from 0 to 1 , and then to 0. I know we can use alphaSpeed property of CAEmitterCell to increase or decrease the alpha, but how to change the alpha like 0 -> 1 -> 0 ? Thanks a lot!
Asked
Active
Viewed 208 times
0
-
You can animate any emitter cell property using key value coding. See http://www.apeth.com/iOSBook/ch17.html#_emitter_layers – matt May 10 '21 at 08:11
-
Thanks! But this solution did not help. I've read the article and tried the code below: ////////////// let baseAnimation = CABasicAnimation(keyPath: "emitterCells.star.alphaSpeed") baseAnimation.fromValue = 0.3 baseAnimation.toValue = -0.3 baseAnimation.duration = 3 baseAnimation.repeatCount = 1000; particleEmitterLeft.add(baseAnimation, forKey:"") /////////////////As the animation is add to the layer, the alpha property of all the stars will be changed together. This is not what I need. – Rufus May 11 '21 at 05:34
-
I was not suggesting you should animate a change in the alpha speed. – matt May 11 '21 at 05:47