So I have a button with a listener and I want it to only register and respond to the first click. Is there a code I can add that will count number of clicks so that I can make the listener invalid after a certain number of clicks?
Something else I tried is at the beginning I made object = true, and what I want to do is have the listener only to work when that statement is true.
For example (just to be clear on what I want)
If object = true then
button: addEventListener (“touch”, buttonHandler)
end
So that later on when I make object = false it won’t continue on to the event listener.
In the listener function remove the touch event listener from the button. That’ll be something like self:removeEventListener(“touch”, self) [import]uid: 12108 topic_id: 6500 reply_id: 22732[/import]
I said “something like,” not “this exact text.” You need to modify it so the removeEventListener() command points to your button. [import]uid: 12108 topic_id: 6500 reply_id: 22979[/import]