Okay so I have a game in which I use this function in a runtime listener:
local function moveenemy(target) if(target.direction=="left") then target:setSequence("left") target:setLinearVelocity(-30,0) else target:setSequence("right") target:setLinearVelocity(30,0) end end
And I use a runtime listener to pass all my game enemies as parameters like:
Runtime:addEventListener("enterFrame",function() moveenemy(enemy1) end) Runtime:addEventListener("enterFrame",function() moveenemy(enemy2) end)
So now when enemy is dead and I need to remove its listener, how do I remove it. Apparently the following doesnt work:
Runtime:removeEventListener("enterFrame",function() moveenemy(enemy1) end) Runtime:removeEventListener("enterFrame",function() moveenemy(enemy2) end)
Thanks.