Hi, everyone! I have a problem with touch event listener. I have an object and when I touched in the simulator the score = score + 1 but I put my Phone and on phone score = score + (2,4,). Why? Thanks
Phases.
You’re probably not taking into account phase:
-
began
-
moved
-
ended
-
not to mention the various (something went wrong) phases
–Wrong way to do a touch listener local button = display.newCircle( 10, 10, 10 ) local score = 0 function button.touch( self, event ) score = score + 1 end button:addEventListener( “touch” )
– Right way to do a touch listener local button = display.newCircle( 10, 10, 10 ) local score = 0 function button.touch( self, event ) if( event.phase == “ended”) then score = score + 1 end return false end button:addEventListener( “touch” )
Phases.
You’re probably not taking into account phase:
-
began
-
moved
-
ended
-
not to mention the various (something went wrong) phases
–Wrong way to do a touch listener local button = display.newCircle( 10, 10, 10 ) local score = 0 function button.touch( self, event ) score = score + 1 end button:addEventListener( “touch” )
– Right way to do a touch listener local button = display.newCircle( 10, 10, 10 ) local score = 0 function button.touch( self, event ) if( event.phase == “ended”) then score = score + 1 end return false end button:addEventListener( “touch” )