Well, probably as a lot of developers I came across the problem that my fps drops when you move your finger on the screen. This is cause by the overflow of data the ontouch event has to process.
To solve this I had some help of Robert Green by using input pipelines: Robert Green
But I still have the problem that within my game, an air hockey game, the push object is moving slower than the finger moves on the screen.
The games has been build as follow:
- an activity which gets the ontouchevents, starts the threas and sets the surfaceview
- the thread does all the calculations (processes all the ontouch events which are received through the pipeline) and draws on the surfaceview
- the surfaceview clears the background and draws the background
When the activity receives an ontouchevent it goed to sleep for 16 miliseconds so the thread has enough time to process everything.
My guess is that when the activity goed to sleep, the surfaceview also goed to sleep since it has been set by the activity. That will also cause the thread to sleep since it cannot update the surfaceview anymore and has to wait before it can update the surfaceview again.
Is this what causes the problem? And how can it be solved? Because the activity always has to set the surfaceview and the thread has to update the surfaceview...
An example youtube video of the game where you can see the slowdown of the push: