Is it possible to check if a particle system is still "running" (duration still active)?

I wonder how I can check if a particle system (created with particle designer) can be checked for it’s duration value?

For example: I start a system in Corona with psystem:start() and this system has a duration of 2 seconds. Now I want to check if the duration is over until I start the system again… something like: if psystem is still active do not start it again… but if the duration already is ‘reached’ start the system again.

Thx for you help!

Daniela

I don’t see a way in the docs to do that.  We don’t have an onComplete handler.  However if you know what the duration is supposed to be, then you could use a timer.performWithDelay(durationInMillseconds, function() do whatever you want when the emitter is done; end) right after to simulate an onComplete.  I’m not familiar with the JSON data that the particle system uses, but you likely could get the duration out of the emitterParams table and use it to feed your timer.

Rob

Thank you for your fast help with this one Rob!

I’m building my own solution from your info right now and it looks like it’s working so far :wink:

Daniela

One other thing:

How is an emitter working with duration? Do I have to use emitterobj:stop() even after an emitter has reached it’s maximal duration? Or is this something which is already ‘done’ in the background? I mean: is an emitter always emitting something and has to be stopped or is it enough when the duration is reached?

For example: I start an emitter which is running for 2 seconds and then the duration is reached and it ‘stops’ automatically. Do I have to still do something to this emitter in the code so the particlesystem isn’t using any resources in the background?

I just want to make sure I’m using particles correctly, so I don’t get any trouble when using a LOT of them :wink:

Thx!

Daniela

hi Daniela, an EmitterObject stops as soon as its duration is complete, unless it’s infinitely looping.

I’ve added a new “state” read-only property to help you determine when a non-looping EmitterObject is done playing. This new property will soon be available in a future daily build. Not the next daily build, but soon after. My best guess is by the end of next week.

Wow! Thank you so much! This really is awesome. You guys rock! :slight_smile:

Best,

Daniela

I don’t see a way in the docs to do that.  We don’t have an onComplete handler.  However if you know what the duration is supposed to be, then you could use a timer.performWithDelay(durationInMillseconds, function() do whatever you want when the emitter is done; end) right after to simulate an onComplete.  I’m not familiar with the JSON data that the particle system uses, but you likely could get the duration out of the emitterParams table and use it to feed your timer.

Rob

Thank you for your fast help with this one Rob!

I’m building my own solution from your info right now and it looks like it’s working so far :wink:

Daniela

One other thing:

How is an emitter working with duration? Do I have to use emitterobj:stop() even after an emitter has reached it’s maximal duration? Or is this something which is already ‘done’ in the background? I mean: is an emitter always emitting something and has to be stopped or is it enough when the duration is reached?

For example: I start an emitter which is running for 2 seconds and then the duration is reached and it ‘stops’ automatically. Do I have to still do something to this emitter in the code so the particlesystem isn’t using any resources in the background?

I just want to make sure I’m using particles correctly, so I don’t get any trouble when using a LOT of them :wink:

Thx!

Daniela

hi Daniela, an EmitterObject stops as soon as its duration is complete, unless it’s infinitely looping.

I’ve added a new “state” read-only property to help you determine when a non-looping EmitterObject is done playing. This new property will soon be available in a future daily build. Not the next daily build, but soon after. My best guess is by the end of next week.

Wow! Thank you so much! This really is awesome. You guys rock! :slight_smile:

Best,

Daniela