hello there i am programing a mobile game with corona sdk using the lua language. i encountered a problem while adding and removing event listeners, it is going as follows:
i have an object which when you “touch” it, it’s alpha goes down to 0.5, and this removes the event listener that causes this, and now a new event listener is applied which calls another function to get it’s alpha back to 1, this time it will return the previous function event listener to enable it to keep making a loop. the functions are applied as follow:
object:addEventListener(“touch”, dropAlpha);
local function dropAlpha(event)
event.target.alpha = 1;
object:addEventListener(“touch”, dropAlpha);
object:removeEventListener(“touch”, increaseAlpha);
end
local function dropAlpha(event)
event.target.alpha = 0.5;
object:removeEventListener(“touch”, dropAlpha);
object:addEventListener(“touch”, increaseAlpha);
end
the problem is as you can see is the stack traceback is wrong, because that does not let it read a function that is not defined already in the code. what can i do inorder to make it work, without using 1 function that asks: ‘IF(alpha = 1) do this ELSE do this END.’ thanks in advance.