A.I, Data and Software Engineering

Tutorial: Multi-touch gesture for android


Multi-touch gestures are very useful in many common scenarios, such as zooming, panning. For game development, handling multi-touch is essential. This post will give a quick guide for handling multi-touch points.

Project structure

We create a new project name MultiTouch with Java and add a new class named GameScene as a subclass of android.view.View.

create new project android studio

The basic GameScene class is as follows.

And to use GameScene as the main view of our demo. We set it in MainActivity as follows.

The task

We will now modify the `GameScene so that it will display the location info of touched points. You can then modify your own logic to achieve your own goal.

We will need:

We initialize these in the constructor

Next, we handle the touch event by adding all touched points to the array and remove it when a finger leaves the screen

Finally, we draw text based on the touch points.

The multi-touch result

multi-touch android studio

Useful links:


A.I, Data and Software Engineering

PetaMinds focuses on developing the coolest topics in data science, A.I, and programming, and make them so digestible for everyone to learn and create amazing applications in a short time.

Pin It on Pinterest


You have successfully subscribed to the newsletter

There was an error while trying to send your request. Please try again.

Petaminds will use the information you provide on this form to be in touch with you and to provide updates.
%d bloggers like this: