Best practice for removing particle objects?

Hi everyone, newbie here.

I am searching for a way to effectively removing particle objects created with Particle Designer (Yes, the one you created with display.newEmitter() )

After searching and reading the documentation I found no clue about this matter. So my guess is using a timer.performWithDelay to manually removing the particle object after use.

I am wondering if anyone have a better solution for this matter.

Thank you for reading.

Hi @duy.nguyen,

Please see this API for details:

https://docs.coronalabs.com/api/type/EmitterObject/stop.html

You can “stop” the emitter and let the particles die off in their own life span, OR you can remove the emitter outright and kill all particles immediately.

Best regards,

Brent

Thanks for the answer, Brent.

So particle will automatically delete itself when the emitter duration’s up? So I don’t need to manually remove it, right?

It seem like I misinterpret the clause “finish their cycle naturally” there. 

Sorry to bother you on such basic question.

Hi @duy.nguyen,

Well, in most particle effects, individual particles have a “life span” and they will die off normally in that time span.

If you stop the emitter using the “stop” API call, the emitter will stop generating new particles, and the existing particles will die off in their own individual lifespan. However, that will not destroy the emitter object… if you don’t need it anymore (no need for new particles) then you should remove it outright in your code.

Hope that helps,

Brent

Thanks for the quick answer.

So is there any event for particle emitter? Some thing like a callback when the emitter finish it emitting duration?

Currently there’s no event triggered when the duration is complete. For this, I would suggest that you run a timer simultaneously, and when the timer is completed, you do whatever you need with the emitter object.

Brent

I’m going in that direction now.

Thanks for the helpful advice, Brent.

Hi @duy.nguyen,

Please see this API for details:

https://docs.coronalabs.com/api/type/EmitterObject/stop.html

You can “stop” the emitter and let the particles die off in their own life span, OR you can remove the emitter outright and kill all particles immediately.

Best regards,

Brent

Thanks for the answer, Brent.

So particle will automatically delete itself when the emitter duration’s up? So I don’t need to manually remove it, right?

It seem like I misinterpret the clause “finish their cycle naturally” there. 

Sorry to bother you on such basic question.

Hi @duy.nguyen,

Well, in most particle effects, individual particles have a “life span” and they will die off normally in that time span.

If you stop the emitter using the “stop” API call, the emitter will stop generating new particles, and the existing particles will die off in their own individual lifespan. However, that will not destroy the emitter object… if you don’t need it anymore (no need for new particles) then you should remove it outright in your code.

Hope that helps,

Brent

Thanks for the quick answer.

So is there any event for particle emitter? Some thing like a callback when the emitter finish it emitting duration?

Currently there’s no event triggered when the duration is complete. For this, I would suggest that you run a timer simultaneously, and when the timer is completed, you do whatever you need with the emitter object.

Brent

I’m going in that direction now.

Thanks for the helpful advice, Brent.