Hi guys,
I am looking for a smart solution to stop created emitter by touching it.
I am not interested for prescheduled timer.performWithDelay stop(s).
Also, I am not looking for **emitter:stop() **built in library, because I do not know where exactly is emitter onscreen…
So emitter is created by screen touch on event.x event.y position, and it is running/emitting.
function stopTouchedEmitter(self, event) if(event.phase == "began") then display.remove(self) self = nil end end function spawnEmitters(event) emitter = loader.newEmitter( "emitters/explosion.rg", "emitters/particle.png") emitter.x = event.x emitter.y = event.y emitter.touch = stopTouchedEmitter emitter:addEventListener( "touch", emitter ) emitterGroup:insert(emitter) emitterGroup:toFront() end
How to stop applicable touched emitter?
Above code does not work (I could iterate through emitterGroup and compare touch event.x and event.y with emitterGroup child(s) x and y… but that is too much workload :P ).
Many, many thanks!!
Ivan