In Android, multi-touch is a very interesting technology. multi-touch can make your game more playable. First, let's talk about how to implement multi-touch.
Event. getaction () // obtain touch actions such as action_down
Event. getpointercount (); // obtain the number of touch points. For example, if 2 is used, two fingers may simultaneously press the screen.
Event. getpointerid (NID); // For the details of each touch point, we can obtain the index by executing the getpointerid method in a loop.
Event. getx (NID); // obtain the X position of the NID touch point
Event. Gety (NID); // obtain the Y position of the NID point.
Event. getpressure (NID); // LCD can sense the user's finger pressure. Of course, the specific level is determined by the driver and physical hardware.
Event. getdowntime () // Press Start Time
Event. geteventtime () // event end time
Event. geteventtime ()-event. getdowntime (); // it takes a long time to press
Events on the Android platform can be processed using the motionevent object method. When the touch starts, action_down is triggered, while action_move is performed, and action_up is triggered when the finger is released. Of course, user-less operations may trigger the action_cancel action.
How can I use the application layer to support multi-touch operations? For general control touch operations, the setontouchlistener () interface of the view is internally implemented and the ontouchevent () method is implemented. For the parameter motionevent of the ontouchevent method, we can process it in detail to implement multi-touch.
I would like to remind you that multi-touch operations can only be achieved through LCD driver and application software, for example, mobile phones that were previously Android 2.1 or listed in North America may not support multi-touch firmware, due to Apple's patent, new firmware models after Android 2.1 in Europe and Asia Pacific have been supported in screen drivers, and the simulator cannot perform multi-touch testing.