Pregunta

I have a CAEmitterCell working but I want the particles to slow down and stop. It seems if I had access to all the particles then I could just reduce their velocity and/or acceleration to 0 and they would stop moving.

I tried something like this:

NSArray *cells = [_layerEmitter emitterCells];
    for (CAEmitterCell* cell in cells) {
        ...

but that didn't work, since my layerEmitter has only one emitterCell, I don't need the emitterCell, but the particles that it has already created.

I'm not seeing this in the docs which makes me believe I had a conceptual problem. I appreciate any help.

¿Fue útil?

Solución

Unfortunately, the particles only exist in the window server, which is a completely separate process from your app. (It's called backboardd as of iOS 6.0.) You can deduce this by pausing your app in the debugger while an emitter is running. Even though your app is stopped, the particles continue spawning and moving on the simulator or the device. So there is no way you can access the individual particles.

If your emitter cell's velocityRange and emissionRange are both zero (meaning no randomness in the velocity vector of your particles), then you should be able to make the particles decelerate by playing with the xAcceleration, yAcceleration, and zAcceleration properties of the cell. However, the particles will slow to a stop and then reverse direction. If you want the particles to disappear when the stop, set the lifetime property appropriately.

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