Problem in removing particle system object and emitter object

Hi, all. :slight_smile:

Well, I’m having some problem in removing a group of particle objects. I usually call the command display.remove(particleSystemObject) within the scene:destroy(event) function. Sometimes, when the button to play again is pressed before the particleSystemObject lifetime is over, the simulator crashes and close itself. When it does not crash the first time, the next time the game is over and the button is pressed, there comes the crash.

The same happens with a emitter object I have in the game. When needed, I also remove that one before the game is over.

I also tried using a

if(particleSystemObject)then display.remove(particleSystemObject); particleSystemObject = nil; end if(emitterObject)then display.remove(emitterObject); emitterObject = nil; end

within the scene:hide(event) function. This same snippet goes within the scene:destroy(event).

Can someone tell me what might be wrong?

Someone?

Hi @Wiler Jr,

Can you be more specific please? Is one of these a physics particle system, as in Liquid Fun particles? Then, is the other an emitter object, as in one created by display.newEmitter() for the purposes of creating a visual particle effect?

I know the difference is subtle, but it’s important that I understand… there are “particles” that are visual and created by Corona emitter objects. And there are “particles” that are created by the physics Liquid Fun system which behave like elements of liquid simulations.

Thanks,

Brent

Hi, Brent. 

Well, I use a particleDesigner.newEmitter() for emitting “fireplace_flame.json” from some items and another for emitting a “hongshizi.json” for each determined item my hero collides with. And, once per match, I use a Liquid Fun physics.newParticleSystem() to emit some droplets as a liquid simulation.

Hi @Wiler Jr,

For the particle object (Liquid Fun), perhaps try pausing the physics engine before you remove that object, and make sure that you’re not trying to remove it while the physics engine is working out collision math or something like that.

For the emitter, try stopping the emitter before you destroy it.

Brent

Someone?

Hi @Wiler Jr,

Can you be more specific please? Is one of these a physics particle system, as in Liquid Fun particles? Then, is the other an emitter object, as in one created by display.newEmitter() for the purposes of creating a visual particle effect?

I know the difference is subtle, but it’s important that I understand… there are “particles” that are visual and created by Corona emitter objects. And there are “particles” that are created by the physics Liquid Fun system which behave like elements of liquid simulations.

Thanks,

Brent

This is exactly what has happened to me for the past 8hours that I’ve been debugging… until I saw this post. 

After adding the particle system in scene:create(), (EVEN THOUGH you don’t call the createParticle() ) Corona always seems to bheave strangely or crashes when the scene ends, or when you invoke the scene again during a Retry, and it’s very intermittent.   I thought Composer will do the housekeeping for me when I  put the particle system in the scene group self.view and the scene performs scene:destroy.

It turned out it is YOUR responsibility to remove the particle system if you’re done using it… otherwise you get sorts of crashes.  

so I put this

display.remove(particleSystem); particleSystem = nil;

after I stop physics  in the scene:destroy function and the crashes disappear.

Hi, Brent. 

Well, I use a particleDesigner.newEmitter() for emitting “fireplace_flame.json” from some items and another for emitting a “hongshizi.json” for each determined item my hero collides with. And, once per match, I use a Liquid Fun physics.newParticleSystem() to emit some droplets as a liquid simulation.

Hi @Wiler Jr,

For the particle object (Liquid Fun), perhaps try pausing the physics engine before you remove that object, and make sure that you’re not trying to remove it while the physics engine is working out collision math or something like that.

For the emitter, try stopping the emitter before you destroy it.

Brent

This is exactly what has happened to me for the past 8hours that I’ve been debugging… until I saw this post. 

After adding the particle system in scene:create(), (EVEN THOUGH you don’t call the createParticle() ) Corona always seems to bheave strangely or crashes when the scene ends, or when you invoke the scene again during a Retry, and it’s very intermittent.   I thought Composer will do the housekeeping for me when I  put the particle system in the scene group self.view and the scene performs scene:destroy.

It turned out it is YOUR responsibility to remove the particle system if you’re done using it… otherwise you get sorts of crashes.  

so I put this

display.remove(particleSystem); particleSystem = nil;

after I stop physics  in the scene:destroy function and the crashes disappear.