GameLoop checking for input (Android/GlSurfaceView)
If I have some basic game loop in a thread, lik开发者_如何学Pythone this:
public void run(){
getInput(); //onTouchEvent method is only available in view class.
updateState();
renderScreen();
}
I was wondering how to actually check for input (touchscreen ie). I know I can use the onTouchEvent() in my view class, but I want to check it from my game loop. How is this done ?
ps: i'm using android with GlSurfaceView.
Usually i would copy the input events in the UI thread and make them available to the game thread in a threadsafe fashion.
You may use the input implementation of libgdx as a good example.
精彩评论