Hi,
I am using an image to that i am adding a event listener. The problem is when touch that image vigorously the event function sometimes getting called twice. How do i avoid this?
Thanks,
kumar Ks.
Hi,
I am using an image to that i am adding a event listener. The problem is when touch that image vigorously the event function sometimes getting called twice. How do i avoid this?
Thanks,
kumar Ks.
Please post your code for future explantation.
Please when you do such posts describe it better what kind of event listener (touch I assume) etc.
Touch listeners are called on various events like began, moved, ended etc.
So you wish to do if in your event listener functions for example
if event.phase ==“ended” then
— code
end
Best regards Dirindnon
Ya i am doing the same and its touch listener,
,
if event.phase == “began” then
display.getCurrentStage():setFocus(event.target,event.id)
elseif event.phase == “ended” then
if self._Punch_Button_Enable_Flag then – Only when flsg is set to true we should enable the touch
self:onTouch_Punch(event)
display.getCurrentStage():setFocus(event.target,nil)
return true
else
end
end
Hi Brent,
Ya i have enabled the multi touch.
Thanks,
Kumar KS.
Hi @Kumar,
I’m confused what you’re trying to do. Shouldn’t you be settting the “flag” when the touch first occurs (“began”)? Why are you setting it when the touch ends? Also, why would you set it to “true” when the touch ends, but then you never reset it to “false”?
Brent
You probably want your “return true” at the end of the listener, instead of buried inside two if statements (which are only sometimes called). Not necessarily related to the issue, but couldn’t hurt. Maybe there’s some weird interaction with another display object.
Please post your code for future explantation.
Please when you do such posts describe it better what kind of event listener (touch I assume) etc.
Touch listeners are called on various events like began, moved, ended etc.
So you wish to do if in your event listener functions for example
if event.phase ==“ended” then
— code
end
Best regards Dirindnon
Ya i am doing the same and its touch listener,
,
if event.phase == “began” then
display.getCurrentStage():setFocus(event.target,event.id)
elseif event.phase == “ended” then
if self._Punch_Button_Enable_Flag then – Only when flsg is set to true we should enable the touch
self:onTouch_Punch(event)
display.getCurrentStage():setFocus(event.target,nil)
return true
else
end
end
Hi Brent,
Ya i have enabled the multi touch.
Thanks,
Kumar KS.
Hi @Kumar,
I’m confused what you’re trying to do. Shouldn’t you be settting the “flag” when the touch first occurs (“began”)? Why are you setting it when the touch ends? Also, why would you set it to “true” when the touch ends, but then you never reset it to “false”?
Brent
You probably want your “return true” at the end of the listener, instead of buried inside two if statements (which are only sometimes called). Not necessarily related to the issue, but couldn’t hurt. Maybe there’s some weird interaction with another display object.