I'm using a
FrameLayout where I have a
GLSurfaceView at the bottom and a few
Views on top of it. One of those
Views is a
TextView that displays the current score.
Here's how I'm updating the score
TextView based on what happens in my game loop: whenever an event happens that increases the score, I call
activity is the activity that has the above
FrameLayout (my main game activity) and
updater is just a
Runnable that increments the score. From my understanding, using
runOnUiThread() from the OpenGL thread is standard practice - otherwise you'll get an exception, I can't remember its name.
The problem is that there's a very noticeable lag between the event and the score update. For example the character gets a coin, but the coin count is not updated quickly. I tried summing all the score events from my game loop and calling
runOnUiThread() only once per loop, but it doesn't seem to make much of a difference - the lag is still noticeable.
How can I improve my design to avoid this lag?