Hi, I am new to corona and had a problem working with emitters. I am working on a splash emitter which plays every time the player collides with an obstacle. But how can I stop the emitter after a given time and play again from the start (sort of reset the emitter). When I set the duration to 1 sec it plays for a sec and then doesn’t. Is there any way to reset the particle emission other than stopping and playing manually.
This is all that I found in the Corona documentation:
https://docs.coronalabs.com/api/type/EmitterObject/index.html
https://docs.coronalabs.com/api/library/display/newEmitter.html
Plus I found a tutorial for a tool for Particle Designing:
https://coronalabs.com/blog/2014/03/25/tutorial-using-particle-designer-in-corona/
Hi @leokarun,
Stopping and restarting the emitter is the proper way to make a “splash each time on contact” sort of effect. And, of course, setting the duration of the emitter to 1 second or whatever looks best.
Best regards,
Brent
please refer to https://docs.coronalabs.com/api/type/EmitterObject/index.html in particular the duration property. you want to set this to 1 to ensure your emitter runs for 1 second.
note: to run an emitter for ever set this to -1
Hey guys,
Thanks for the replies. But when I set the duration to 1 sec, the emitter never plays again. Since there are multiple collisions, I cant assign a new emitter for every collision. So I have to find a way to reuse the same emitter i.e. make the emitter play from the start till the duration(1 sec) and repeat this on next collision.
As for the particle designer tool it is not for windows and runs only on Mac, I am a windows user.
Thanks
Hi @leokarun,
In this case, I would suggest you keep the emitter’s duration infinite (no limit). Then, set up a separate timer (associated as a property of the player would be convenient). That timer would start upon any collision, run for 1 second, and then upon completion, stop the emitter. If another collision occurred during that time span (before the timer finished), cancel that timer and start it new with another 1 second of duration.
So basically this:
-
Player starts moving around. Emitter is currently stopped (don’t start playing it).
-
When a collision occurs, start emitter playing and start separate timer ( not the emitter’s duration) for 1 second.
-
If another collision occurs while timer is running, cancel that timer and reset it to a new timer of 1 second. Otherwise, if no additional collisions before timer ends, use the timer’s ending time to stop the emitter. That way, if you have 2+ collisions in a very short timespan, the emitter won’t prematurely stop emitting particles (a self-contained duration) before you want it to.
As for designer tools, Windows users have the Radiance Particle Creator available to them (Mac users too). If you’re planning to use a lot of beautiful particle effects in your game, it will be money well spent.
https://marketplace.coronalabs.com/asset/radiance-particles-effects-creator-v1-42
Take care,
Brent
Thanks Brent. It seems that’s the only solution at this point of time. I hope corona will introduce a reset mechanism later.
Thank you all.
“reset” in Corona normally is achieved by dropping and recreating.
So you could do the following and then call it whenever you need your emitter to fire and for how long. It is self cleaning too. Which one would be something like “splash.json”, “fire.json”, etc.
function beginEmitter(whichOne, time) emitter = particleDesigner.newEmitter( whichOne ) timer.performWithDelay(time, {function() emitter:stop() emitter:removeSelf() emitter = nil end}) end
This is using the particleDesigner helper class
This is all that I found in the Corona documentation:
https://docs.coronalabs.com/api/type/EmitterObject/index.html
https://docs.coronalabs.com/api/library/display/newEmitter.html
Plus I found a tutorial for a tool for Particle Designing:
https://coronalabs.com/blog/2014/03/25/tutorial-using-particle-designer-in-corona/
Hi @leokarun,
Stopping and restarting the emitter is the proper way to make a “splash each time on contact” sort of effect. And, of course, setting the duration of the emitter to 1 second or whatever looks best.
Best regards,
Brent
please refer to https://docs.coronalabs.com/api/type/EmitterObject/index.html in particular the duration property. you want to set this to 1 to ensure your emitter runs for 1 second.
note: to run an emitter for ever set this to -1
Hey guys,
Thanks for the replies. But when I set the duration to 1 sec, the emitter never plays again. Since there are multiple collisions, I cant assign a new emitter for every collision. So I have to find a way to reuse the same emitter i.e. make the emitter play from the start till the duration(1 sec) and repeat this on next collision.
As for the particle designer tool it is not for windows and runs only on Mac, I am a windows user.
Thanks
Hi @leokarun,
In this case, I would suggest you keep the emitter’s duration infinite (no limit). Then, set up a separate timer (associated as a property of the player would be convenient). That timer would start upon any collision, run for 1 second, and then upon completion, stop the emitter. If another collision occurred during that time span (before the timer finished), cancel that timer and start it new with another 1 second of duration.
So basically this:
-
Player starts moving around. Emitter is currently stopped (don’t start playing it).
-
When a collision occurs, start emitter playing and start separate timer ( not the emitter’s duration) for 1 second.
-
If another collision occurs while timer is running, cancel that timer and reset it to a new timer of 1 second. Otherwise, if no additional collisions before timer ends, use the timer’s ending time to stop the emitter. That way, if you have 2+ collisions in a very short timespan, the emitter won’t prematurely stop emitting particles (a self-contained duration) before you want it to.
As for designer tools, Windows users have the Radiance Particle Creator available to them (Mac users too). If you’re planning to use a lot of beautiful particle effects in your game, it will be money well spent.
https://marketplace.coronalabs.com/asset/radiance-particles-effects-creator-v1-42
Take care,
Brent
Thanks Brent. It seems that’s the only solution at this point of time. I hope corona will introduce a reset mechanism later.
Thank you all.
“reset” in Corona normally is achieved by dropping and recreating.
So you could do the following and then call it whenever you need your emitter to fire and for how long. It is self cleaning too. Which one would be something like “splash.json”, “fire.json”, etc.
function beginEmitter(whichOne, time) emitter = particleDesigner.newEmitter( whichOne ) timer.performWithDelay(time, {function() emitter:stop() emitter:removeSelf() emitter = nil end}) end
This is using the particleDesigner helper class