The story : I try to understand PC and to make it work with director class. Beginnings were hard, but I now manage to do funny things.
I was working on events demo, Particles.SetEmitterListener("E1", MyParticleDestroyListener)
just putting :
-- Count Particles destroyed
local pDestroyed = 0
local StatusText2 = display.newText( "", screenW/2, screenH-40, "Verdana-Bold", 12 )
StatusText2:setTextColor( 255,255,255 )
StatusText2.text = "destroyed : "..0
-- DIRECTOR
localGroup:insert(StatusText2)
and in MyParticleDestroyListener function :
pDestroyed = pDestroyed + 1
StatusText2.text = "destroyed :"..pDestroyed
to count destroyed particles.
I navigate between two screens, just before the screen change, I have ----- Candy clean up before changing scene -----
Particles.SetEmitterListener("E1", nil)
Emitter = nil
Particles.CleanUp()
Runtime:removeEventListener( "enterFrame", main )
----- Director -----
director:changeScene("home","fade", "black")
I first realized that when i change screens (screen with particles - home screen - back to screen with particles), the pDestroyed was not 0 …
Looking at the terminal I have :
When I quit screen with particles to home screen :
"
–> Particles.ClearParticles()
–> Particles.DeleteParticleType(): REMOVING ‘Test1’ FROM EMITTER ‘E1’
–> Particles.DeleteParticleType(): DELETED PARTICLE TYPE ‘Test1’
–> Particles.DeleteEmitter(): DELETED EMITTER ‘E1’
–> Particles.CleanUp(): FINISHED.
"
When I click back to screen with particles :
EVENT RECEIVED: particleKilled
EVENT RECEIVED: particleKilled
EVENT RECEIVED: particleKilled
… many times …"
Wow ! I thought I destroyed the listeners when I quit ! It’s still there when I’m back …hm hm
I even realized (waiting on home screen before returning back to particles screens) that the more I wait the more event received fire (and pDestroyed increases) …
Is that a nice problem ? [import]uid: 9328 topic_id: 6317 reply_id: 306317[/import]