Getting crashed when trying to use Particle Candy within Scene

When I add an emitter to my scene’s group, I’m getting the error below. The error comes when I exit the scene containing the emitter.

I’m calling StartAutoUpdate() in enterScene, and calling StopAutoUpdate() in exitScene (also tried didExitScene with same result).

I’m creating the particle in createScene and adding it to the scene’s group there.

Am I missing something?

–> PARTICLE SYSTEM READY. LET’S ROCK.
–> Particles.CreateEmitter(): ADDED EMITTER ‘tutu’
–> Particles.CreateParticleType(): CREATED PARTICLE TYPE ‘FireParticles’.
–> Particles.CreateParticleType(): CREATED PARTICLE TYPE ‘SparkParticles’.
–> Particles.CreateParticleType(): CREATED PARTICLE TYPE ‘SmokeParticles’.
–> Particles.AddParticleType(): ADDED PARTICLE TYPE ‘FireParticles’ TO EMITTER
‘tutu’.
–> Particles.AddParticleType(): ADDED PARTICLE TYPE ‘SparkParticles’ TO EMITTER
 ‘tutu’.
–> Particles.AddParticleType(): ADDED PARTICLE TYPE ‘SmokeParticles’ TO EMITTER
 ‘tutu’.
–> Particles.StartEmitter(): EMITTER ‘tutu’ STARTED.
–> Particles.StopEmitter(): EMITTER ‘tutu’ STOPPED.
stopped particles
Runtime error
…jects\mygame\trunk\lib\particle_candy.lua:1339: attempt to perform
 arithmetic on field ‘x’ (a nil value)
stack traceback:
        [C]: ?
        …jects\mygame\trunk\lib\particle_candy.lua:1339: in functio
n ‘Update’
        …\projects–> Particles.Freeze() - PARTICLE SYSTEM FROZEN.

I just realized that particle candy comes with sample code for working with storyboards. 

I had to run Particles.CleanUp() in my exitScene handler and that worked. Is there a reason I can’t just stop the auto update / stop my emitter instead of cleaning up everything?

Basically, I’d like my emitter to continue where it left off when the scene is resumed. With CleanUp I’m forced to recreate the emitter from scratch each time I enter the scene. Any ideas?

I just realized that particle candy comes with sample code for working with storyboards. 

I had to run Particles.CleanUp() in my exitScene handler and that worked. Is there a reason I can’t just stop the auto update / stop my emitter instead of cleaning up everything?

Basically, I’d like my emitter to continue where it left off when the scene is resumed. With CleanUp I’m forced to recreate the emitter from scratch each time I enter the scene. Any ideas?

Hey George, may be it is late but I would like to answer this question as it may help someone.

Firstly create the Particle handle in the main.lua file, defile it as Global…

— main.lua —

_G.Particles = require(“lib_particle_candy”)

Later in every scene refer to this handle for creating Emitters and Particles

Particles.CreateEmitter…

Now if you want to resume your particles when you return from another scene, you can a a logic in the createScene event for checking events.params

if events.params then

Particles.StartEmitter(…)

else

Particles.CreateEmitter(…)

end

And remember to not call Clanup() in your exitScene event, this will persist the particles and emitters. The downside of this may be memory hogging, but this depends your Emitters.

Hey George, may be it is late but I would like to answer this question as it may help someone.

Firstly create the Particle handle in the main.lua file, defile it as Global…

— main.lua —

_G.Particles = require(“lib_particle_candy”)

Later in every scene refer to this handle for creating Emitters and Particles

Particles.CreateEmitter…

Now if you want to resume your particles when you return from another scene, you can a a logic in the createScene event for checking events.params

if events.params then

Particles.StartEmitter(…)

else

Particles.CreateEmitter(…)

end

And remember to not call Clanup() in your exitScene event, this will persist the particles and emitters. The downside of this may be memory hogging, but this depends your Emitters.