I'm developing a game for Android. It's got a lot going on but is running reasonably smoothly. That is, of course, until the user touches the screen.
While they're touching it, onTouchEvent
is called (with action = ACTION_MOVE
, x = 0
and y = 0
) roughly once every ten milliseconds at what appears to be a fairly high priority, as it absolutely obliterates the framerate. As soon as the touch ends the framerate returns to its nice state.
I've tried
onTouchEvent
handle input for the game as usualonTouchEvent
return true
straight awayonTouchEvent
implemented at allThe problem persists in all three situations.
Has anyone encountered this? Is there a way to reduce the rate at which ACTION_MOVE
events are generated, or to ensure that they're only generated when there is actual movement, or use a polling method that just gets the current location of the touch? Or even just a way to disable it entirely?
Read this thread. Basically you want to sleep the event thread since otherwise the system will pump a lot of events (between x,y and pressure there is always some movement going on) that you need to handle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With