display.newEmitter crashes simulator

Hi all, I have a function that uses display.newEmitter to create an effect after a drag and drop operation. Most of the time it works, but occasionally, this particular line of code causes the simulator to crash. It’s always on the creation of the emitter:

local emitter = display.newEmitter(particle)

This is in a game where letters are dropped to fill out a crossword. The emitter is created when a letter is dropped on the wrong space, to highlight the error.

Anyone else seeing this kind of behavior?

it would be easier on resources and hopefully wont crash your software, if you create it once and then only start and stop it when you use it. dont create it every time, it can cause a slight hickup.

for instant amooth effects, create them when at an appropriate time, perhaps when drawing graphics, then start/stop on need.

remember to remove once you dont need the emitter anymore

If you only have a handful of emitters there should be no issues at all with creating on demand.  It does depend on your emitter configuration and how you are creating them.

It could be that in your case that particle may be nil or invalid json,

i’ve done test where creating emitters would cause a very slight glitch in graphics on a medium powerful device.

intializing first and the starting and stopping on need works for me.

@anaqim with your emitters instead of stop/start try pause/start instead.  you’ll get a much smoother experience IMHO (emitter depending)

Hi sphere,

Yeah i know but if you start after pause it will “resume”, and if you want to fire the effect off from the start, then you need to stop it first.

or even pause… then stop and start afresh.  I don’t like the way stopping an emitter kills it dead - it just looks wrong for things like fire, smoke, trails, etc

Thanks all! I will go with the idea of creating it just once and then start/stopping it as needed. 

i forgot that pause finishes the particles, so if you want to end the effect before its over, yeah use pause.

then maybe add the extra time it takes to die out, which is the lifetime value, before you kill it.

i do that in my radiance program and for v2, it will be in the playback script.

it would be easier on resources and hopefully wont crash your software, if you create it once and then only start and stop it when you use it. dont create it every time, it can cause a slight hickup.

for instant amooth effects, create them when at an appropriate time, perhaps when drawing graphics, then start/stop on need.

remember to remove once you dont need the emitter anymore

If you only have a handful of emitters there should be no issues at all with creating on demand.  It does depend on your emitter configuration and how you are creating them.

It could be that in your case that particle may be nil or invalid json,

i’ve done test where creating emitters would cause a very slight glitch in graphics on a medium powerful device.

intializing first and the starting and stopping on need works for me.

@anaqim with your emitters instead of stop/start try pause/start instead.  you’ll get a much smoother experience IMHO (emitter depending)

Hi sphere,

Yeah i know but if you start after pause it will “resume”, and if you want to fire the effect off from the start, then you need to stop it first.

or even pause… then stop and start afresh.  I don’t like the way stopping an emitter kills it dead - it just looks wrong for things like fire, smoke, trails, etc

Thanks all! I will go with the idea of creating it just once and then start/stopping it as needed. 

i forgot that pause finishes the particles, so if you want to end the effect before its over, yeah use pause.

then maybe add the extra time it takes to die out, which is the lifetime value, before you kill it.

i do that in my radiance program and for v2, it will be in the playback script.