really need to see code
i was just guessing without seeing any code
really need to see code
i was just guessing without seeing any code
--This is checkIfScore() --Basically it checks whether the user's touch is the same as a pre-selected dot and, --if a dot wasn't pressed, it tries to remove the listeners (which isn't working!!!)
local function checkIfScore() if didRun1 == false then removeEventListener1() else if didRun2== false then removeEventListener2() else if didRun3 == false then removeEventListener3() end end end print ("didRun1 is " .. tostring(didRun1)) print ("didRun2 is " .. tostring(didRun2)) print ("didRun3 is " .. tostring(didRun3)) if userSelectCorrect1 == true and userSelectCorrect2 == true and userSelectCorrect3 == true then score = score + 1 scoreText.text = score audio.play(successSound) timer.performWithDelay(1000, compDotSelect) else lostLife() end end
--Below, that's where didRun3 gets set: function onTouch3(obj) didRun3 = true local function glowRemove3(obj) transition.to(obj, {alpha = 1, onComplete = checkIfScore}) end transition.to(obj,{alpha = 0.2, onComplete = glowRemove3}) userSelectCorrect3 = true -- for a reason, but I don't need to explain function removeEventListener3() -- removes previous listeners, works here if called but in checkIfScore it doesn't print("removed event listener for dot 3") dot1:removeEventListener("touch", onTouch3) dot2:removeEventListener("touch", onTouch3) dot3:removeEventListener("touch", onTouch3) end removeEventListener3() end --Here are event listeners added to some dots dot1:addEventListener("touch", onTouch3) dot2:addEventListener("touch", onTouch3) dot3:addEventListener("touch", onTouch3)
are they in that order in your code
Yes, I just edited them to be
and where is
local removeEventListener3
located
[quote name=“jstrahan” post=“193452” timestamp=“1374106570”]and where is local removeEventListener3 located[/quote] In onTouch3
try moving
local function removeEventListener3() -- removes previous listeners, works here if called but in checkIfScore it doesn't print("removed event listener for dot 3") dot1:removeEventListener("touch", onTouch3) dot2:removeEventListener("touch", onTouch3) dot3:removeEventListener("touch", onTouch3) end
above
local function checkIfScore()
Hi,
I finally found a solution. Look at this link:
http://www.ludicroussoftware.com/blog/2011/08/24/remove-all-listeners/
yes that will do it but its really a work around not a fix but anyway glad it works for you