Pregunta

Here's a video of what I've got thus far. Pardon the choppiness, my MBP + QuickTime + Xcode isn't the best.

http://www.youtube.com/watch?v=DGRwz7n3kNA

It's a really rough draft on what I want, but you can get the idea. Performance is the biggest problem, but even performance aside I'm wasting CPU/GPU time rendering/computing particles that are behind my UIImageView (the demonic rune looking thing).

Does anyone have any idea how to emit particles along a path or a better way to get a glowing animation behind a view? Here's a snippet of my emitter view that set's up the animation:

emitter = (CAEmitterLayer*)self.layer;
CGSize size = self.frame.size;
[emitter setEmitterPosition:CGPointMake(size.width / 2.0f, size.height / 2.0f)];
[emitter setEmitterSize:CGSizeMake(size.width, size.height)];
[emitter setEmitterShape:kCAEmitterLayerCircle];
[emitter setRenderMode:kCAEmitterLayerAdditive];

CAEmitterCell *runeGlow = [CAEmitterCell emitterCell];
[runeGlow setColor:[[UIColor whiteColor] CGColor]];
[runeGlow setName:@"runeGlow"];
[runeGlow setBirthRate:4000.0f];
[runeGlow setVelocity:30.0f];
[runeGlow setLifetime:0.6f];
[runeGlow setEmissionRange:M_PI * 2.0f];
[runeGlow setContents:(id)[[UIImage imageNamed:@"burn.png"] CGImage]];

[emitter setEmitterCells:[NSArray arrayWithObject:runeGlow]];
¿Fue útil?

Solución

You can set the emitter mode to only emit particles on the outline of the shape, like this

[emitter setEmitterMode:kCAEmitterLayerOutline];

(As you've probably noticed "volume" is the default value)

That would probably allow you to lower the amount of particles which would increase performance (since you don't have to create a lot of particles that appear behind the circle).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top