5

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. The best I could do is make an arc (by modifying the yAcceleration property of CAEmitterCell), but I can't do a complete circle. 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?

cpprulez
  • 896
  • 2
  • 9
  • 21

3 Answers3

3

You can use a CAKeyframeAnimation to animate the emitterPosition:

CAKeyframeAnimation *particleAnimation = [CAKeyframeAnimation animationWithKeyPath:@"emitterPosition"];
[particleAnimation setPath:yourPath];
[particleAnimation setDuration:1.0];
[particleAnimation setCalculationMode:kCAAnimationPaced];
[yourEmitterLayer addAnimation:particleAnimation forKey:@"yourAnimation"]; 
Marco
  • 330
  • 5
  • 13
0
yourEmitter.emitterShape = kCAEmitterLayerCircle;
yourEmitter.emitterMode = kCAEmitterLayerOutline;
walker
  • 140
  • 1
  • 8
0

You want to use particleEmitter.emitterShape = kCAEmitterLayerCircle

http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/CAEmitterLayer_class/Reference/Reference.html

Weston
  • 1,481
  • 1
  • 11
  • 31