Hi All,
I have a problem that sometimes when Game Over, I want to change all Event Listener to be removed, but sometimes not sure why, when Game Over event is starting (the image is becoming big), the event listeners are not removed yet. Any opinion will be highly appreciated!
My code is below:
local changeMyListener local gameOver = function() timer.cancel(stopCountdown) changeMyListener("remove") transition.to(ausH,{time=7000,xScale=1.8,yScale=1}) transition.to(asiaH,{time=7000,xScale=1.8,yScale=1}) Runtime:addEventListener("touch", leave) end) end local changeTimeLabel = function() if remainVampire == 0 then movingWords.text = "You loss!" gameOver() end end changeMyListener = function(mode) if mode == "add" then asia:addEventListener("touch",PAsia) europe:addEventListener("touch",PEurope) aus:addEventListener("touch",PAus) Africa:addEventListener("touch",PAfrica) NAmerica:addEventListener("touch",PNAmerica) SAmerica:addEventListener("touch",PSAmerica) elseif mode =="remove" then asia:removeEventListener("touch",PAsia) europe:removeEventListener("touch",PEurope) aus:removeEventListener("touch",PAus) Africa:removeEventListener("touch",PAfrica) NAmerica:removeEventListener("touch",PNAmerica) SAmerica:removeEventListener("touch",PSAmerica) end end
