Particle Candy Cleanup not fully functional

local cleanUp = function()
display.remove(fighterShip)
sheet1:dispose()
Particles.ClearParticles()
Particles.CleanUp()
collectgarbage(“collect”)
local alert = native.showAlert(“Game Over”, “would you like play again?”, {“Yes”, “No”}, buttonListener)
end


have the above cleanup code running. Still seems to have left over particles on screen. If I go back to menu then run the game again, the old particle are still on screen, on every screen for that matter. I am using this with Director Class.

Any help would be truly appreciated.

Alex

*EDITED: Moved to correct forum section. Please choose the appropriate subsection for your threads! [import]uid: 55144 topic_id: 11488 reply_id: 311488[/import]

If you declare an emitter you also have to nil that emitter

[lua]local Emitter = Particles.GetEmitter(“E1”)[/lua]

Cleanup:

[lua]E1 = nil
Particles.CleanUp()[/lua] [import]uid: 40033 topic_id: 11488 reply_id: 41712[/import]

No emitters created. I am basically using the modified sample code for comets. [import]uid: 55144 topic_id: 11488 reply_id: 41765[/import]

Comets - that might explain it. If I remember correctly, there’s a ResetComet function, I think that keeps running like a timer and you have to stop it. [import]uid: 40033 topic_id: 11488 reply_id: 41769[/import]

–============================ Comets ========================================

local Particles = require(“lib_particle_candy”)

–local StatusText = display.newText( " ", _W/2, _H-20, native.systemFont, 12 )
–StatusText:setTextColor( 255,255,255 )

– COMETS
local CometB = display.newImageRect(“comet_blue.png”,64,256)

CometB.yReference = -110
CometB.blendMode = “add”

– CREATE EMITTERS (NAME, SCREENW, SCREENH, ROTATION, ISVISIBLE, LOOP)
Particles.CreateEmitter(“E2”, 0,0, 90, false, true)

– DEFINE PARTICLE TYPES
Particles.CreateParticleType (“TailBlue”,
{
imagePath = “tail_blue.png”,
imageWidth = 32,
imageHeight = 128,
velocityStart = 150,
autoOrientation = true,
killOutsideScreen = false,
lifeTime = 6000,

scaleStart = 0.5,
scaleVariation = 0.15,
scaleInSpeed = 3.0,

alphaStart = 0,
fadeInSpeed = 0.45,
fadeOutSpeed = -0.9,
fadeOutDelay = 1000,
} )
– FEED EMITTERS (EMITTER NAME, PARTICLE TYPE NAME, EMISSION RATE, DURATION, DELAY)
Particles.AttachParticleType(“E2”, “TailBlue”, 7, 99999, 0)

– TRIGGER THE EMITTERS
Particles.StartEmitter(“E2”)

function ResetComet(Comet)
Comet.x = math.random()*_W
Comet.y = -Comet.height
Comet.speed = 5 + math.random()*10
Comet.rotation = 120 + math.random()*120
Comet.xSpeed = math.cos(math.rad(Comet.rotation - 90)) * Comet.speed
Comet.ySpeed = math.sin(math.rad(Comet.rotation - 90)) * Comet.speed
end

ResetComet(CometB)


– MAIN LOOP

local function main( event )

– UPDATE PARTICLES
Particles.Update()

– MOVE COMET

if CometB.y > _H or CometB.x < 0 or CometB.x > _W then ResetComet(CometB) end
CometB.x = CometB.x + CometB.xSpeed
CometB.y = CometB.y + CometB.ySpeed
Particles.GetEmitter(“E2”).x = CometB.x
Particles.GetEmitter(“E2”).y = CometB.y
Particles.GetEmitter(“E2”).rotation = CometB.rotation-180

– DISPLAY PARTICLE COUNT
–StatusText.text = “PARTICLES:”…Particles.CountParticles()
end
–============================================================================

Above is the entire code I am working with.

I have a Runtime EnterFrame listener that is tied to the main() function above.

Now If I run Particles.Freeze() then the active Particle on screen is stopped but other particle continue to spawn (this is problem 2)

Problem 1. was the initial issue, where when I run the CleanUp() function there are occasionally still particle left over between screens.

Now I think Particle Candy is an excellent product, but its not very useful to me right now. [import]uid: 55144 topic_id: 11488 reply_id: 41829[/import]

OK some updates.

I was wrong about the particles not pausing, they paused but the comet did not. had to remove the runtime listener on game pause, then put it back on resume.

Next the particle cleanup() did work, the comet was been left behind, they blended I it was not jump out at me until I combed through the code that they were separate entities.

User problem as usual, just that use to being the user :frowning:

No more issues [import]uid: 55144 topic_id: 11488 reply_id: 41834[/import]