Hello,
Im using a “tap” event listener, but it looks like when i tap something in my game it gets executed multiple times. When i print in the listener I will get around 10 prints in my terminal. Why does it not only do this once? I only tap it once, so it should only execute this once right?
Thanks in advance
Alexander
EDIT: Sorry I think there is something wrong the way I create the listener
So now I want to ask something about that. I create the listeners in a for loop, depending on whether or not the object in the loop has a quest availeble or not. This is running in the enterFrame event. So i think it was adding extra listeners to the object (Or something like that)
Now I want to check if the object has a listener already before applying the listener, I found the following way on the forums. But it does not seem to work, it says the _functionListeners is nil.
Summary of my code:(quests is a table which parallels to the characters table, to check if the character has any available quests or not(true or false) ) Normally this for loop has more statements but i summarized it to make it easier to read
[lua]function EnterFrame(event)
for o=1,#characters do
if quests[o] then
if questIsStarted == false then
if characters[o]._functionListeners.tap==nil then
characters[o]:addEventListener( “tap”, onTapNPC )
end
end
end
end
end[/lua]
Does anyone have tips how to do this [import]uid: 118839 topic_id: 33770 reply_id: 333770[/import]
