I've been struggling with similar issues on-and-off with a game I've been
slowly incubating.
The drop in frame-rate experienced with touch events may be caused by their
continual generation (fingers aren't like mice, even an apparently static
finger will exhibit variation). If this is the case it can be addressed by
sleeping the event thread for a short period of time after handling each
touch event.

Your more significant problem, with the application failing to respond
(apparently at random) for extended periods of time I don't have a direct
solution for. I tried similar approaches to you. In my case I have
identified *one* cause: background game music playing via a MediaPlayer;
disabling the music seemed to fix the problem (perhaps temporarily).
Excessive amounts of graphics rendering might be another cause.

I'm increasingly confident that the problem is not related to my code, but I
haven't found a useful test case (I have spent many fruitless hours hunting
for one). My intuition (and its nothing more than a gut feeling) is that it
has all the hallmarks of unfair monitor contention. I have no evidence for
any of this though and am still looking forward to that eureka moment when I
find out how I've managed to make a mistake in my code that is both stupidly
basic and deviously subtle.

Tom

2009/2/6 Zombies and Robots <caecus...@gmail.com>

>
> Hello.
>
> I am working on a game that displays its graphics through a modified
> SurfaceView.  The game scrolls around a map based on the location of
> the main character.  That all works fine.
>
> I am trying to add a feature to the game that allows you to touch the
> screen and drag the camera around to see other parts of the map.  This
> is where I am running into trouble.  The game's SurfaceView overrides
> 'public boolean onTouchEvent(MotionEvent event)' to call another
> method in the game's thread which handles the events.  Sometimes, this
> works fine (although the frame rate drops significantly while the
> screen is touched).  Other times, there will be a delay of several
> seconds before the game responds to a touch event, during which time
> the game continues, but the user loses all control.  During these
> delays, a message sometimes appears stating that my activity is not
> responding, and giving the options to 'Force close' or 'Wait'.  If the
> user selects 'Wait', the game almost always resumes right away, but
> these delays are obviously not acceptable.
>
> The delays occur only the first time the screen is touched after the
> game is started.  Once the game has resumed after a delay, the touch
> events work just fine again.
>
> I have experimented with having the game thread sleep for short
> periods at various points throughout the game.  Although this does
> seem to have a small effect on the problem, the delays still happen.
> Has anyone else run into this?  What am I doing wrong?
>
> Thank you very much for any suggestions you can provide.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to