Put the input events into your own internal queue. Process the your event queue in your update-AI/update-user-event phase of your game logic. The queue should be locked when adding/removing events.
On Wednesday, April 24, 2013 4:26:02 PM UTC+1, bob wrote: > > I've been investigating an insidious error in an Android OpenGL game app. > This error was brought to my attention by ACRA. > > I believe that the source of the error is that the code in an onTouchEvent > executes in a different thread than the code > in the OpenGL drawing thread. > > So, basically, the drawing thread was looping thru some enemy ships trying > to draw them. > > Meanwhile, someone pressed the reset button on the game (an onTouchEvent), > and the enemy ship LinkedList got cleared. This clearing occurred while > the drawing thread was looping thru them. Thus an > IndexOutOfBoundsException occurred. > > Anyhow, I guess my question is... how would the professional Android > developer have prevented this? > > Thanks. > > > -- -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

