Is OnTouchListener faster than OnClickListener?

I am making an Android 2D game that is multiplayer and two players are using the same screen ...

Each user has multiple buttons to control their player and sometimes they have to press those buttons as fast as they can ... And that's what I'm having trouble with!

I tested the app on a real device and (I'm not sure about this, but) I think that when both users press multiple buttons at the same time, some of those clicks won't work! I see the players moving slowly ...

Is it because of the device (which is a Samsung Galaxy S3)? Or because of what OnClickListener

I have used? Is it OnTouchListener

better in this case? Or are they the same?

+3


source to share


2 answers


When called, the OnClickListener

user must press and release the button.
With, OnTouchListener

you can check for an event ACTION_DOWN, which means your application doesn't need to wait for two events before it can respond. So in theory it OnTouchListener

should be "faster" if you implement it correctly.



Hope I helped :)

+5


source


onTouchListener is faster than clickListener

onTouchListener : - defines the interface for the callback to be called when the touch event for view is dispatched. The callback will be called before the submit event is dispatched to the view.



onClickListener : - Defining an interface for the callback to be called when the view is clicked.

If you really care about touch or not use onClickListener

+4


source







All Articles