-
Book Overview & Buying
-
Table Of Contents
Android NDK Game Development Cookbook
By :
Until now, we have not handled any user interaction except the BACK button on Android. In this recipe, we show how to process multi-touch events on Android.
You should be familiar with the concepts of multi-touch input handling. In Java, Android multi-touch events are delivered inside the MotionEvent class, an instance of which is passed as a parameter to the onTouchEvent() method of your Activity class. The MotionEvent class contains all the information of the currently active and released touches. In order to pass this information to our native code, we convert a single event carrying multiple touches into a series of events holding data for a single touch. This keeps the JNI interoperation simple and enables easy porting of our code.
Each Android activity supports multi-touch event handling. All we have to do is override the onTouchEvent() method of the Activity class:
Change the font size
Change margin width
Change background colour