[英]use CAEmitterLayer to draw particles around a circle or a CGPath
I'm trying to use iOS 5's particle system (CAEmitterLayer and CAEmitterCell) to draw particles around a circle (or even better, a CGPath), but I don't know how to do it. 我正在尝试使用iOS 5的粒子系统(CAEmitterLayer和CAEmitterCell)来围绕一个圆圈绘制粒子(甚至更好,一个CGPath),但我不知道该怎么做。 The best I could do is make an arc (by modifying the yAcceleration property of CAEmitterCell), but I can't do a complete circle.
我能做的最好的是制作一个弧(通过修改CAEmitterCell的yAcceleration属性),但我不能做一个完整的循环。 Of course, I could do multiple arcs to simulate a circle, but the "knots" are very visible.
当然,我可以做多个圆弧来模拟圆形,但“结”非常明显。 Also, I don't want to use masks, because it would seem like the particles at the edges are cropped.
此外,我不想使用蒙版,因为看起来边缘的粒子被裁剪。 Any ideas how to do that?
任何想法如何做到这一点?
You can use a CAKeyframeAnimation to animate the emitterPosition: 您可以使用CAKeyframeAnimation为emitterPosition设置动画:
CAKeyframeAnimation *particleAnimation = [CAKeyframeAnimation animationWithKeyPath:@"emitterPosition"];
[particleAnimation setPath:yourPath];
[particleAnimation setDuration:1.0];
[particleAnimation setCalculationMode:kCAAnimationPaced];
[yourEmitterLayer addAnimation:particleAnimation forKey:@"yourAnimation"];
yourEmitter.emitterShape = kCAEmitterLayerCircle;
yourEmitter.emitterMode = kCAEmitterLayerOutline;
You want to use particleEmitter.emitterShape = kCAEmitterLayerCircle
你想使用
particleEmitter.emitterShape = kCAEmitterLayerCircle
http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/CAEmitterLayer_class/Reference/Reference.html http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/CAEmitterLayer_class/Reference/Reference.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.