gpt4 book ai didi

ios - 使用 Core Animation 淡出发射器单元

转载 作者:可可西里 更新时间:2023-11-01 03:06:12 27 4
gpt4 key购买 nike

我正在使用 CAEmitterLayer 和 CAEmitterCell 实例创建粒子动画。动画没有问题,但我希望它们慢慢淡出。我正在使用下面的代码,但粒子突然消失,那里没有淡出动画。

        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"];

此代码在五个不同发射器单元的 for 循环中运行。

你发现这段代码中有错误吗?

谢谢

最佳答案

对于 CAEmitterCell,将 alpha 速度值设置为 -1.0/lifetime。

关于ios - 使用 Core Animation 淡出发射器单元,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24245073/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com