Multitouch. Piano multitouch, you can click in several keys concurrently. Studio multitouch

Hi friends,

in others post I wrote about Multitouch:

  • Multitouch. You can touch concurrently zones in screen

https://community.thunkable.com/t/extension-multitouch-you-can-touch-concurrently-zones-in-screen/11659

https://groups.google.com/forum/#!category-topic/mitappinventortest/app-inventor-extensions/9dbZpOSTJb0

Multitouch refers to the capability of a touchscreen to recognize two or more points of contact on the surface concurrently.

Two methods:
1.- onTouch and getAction.
2.- GestureDetector and ScaleGestureDetector

We use onTouch method.

Dimensions:

Factor density screen, in my device = 3

Screen.Width x 3 = 320 x 3 = 960 real pixels.
Screen.Height x 3 = 570 x 3 = 569 x 3 = 1707 real pixels.

By Design we put a total VerticalArrangement, Height and Width: Fill parent.

VerticalArrangement.Width x 3 = 320 x 3 = 960 real pixels.
VerticalArrangement.Height x 3 = 527 x 3 = 1581 real pixels.

Look, Screen.Height is higher than VerticalArrangement.Height, because clock and title bars are 14 (42 real pixels).


Handling Multi-Touch Gestures. onTouch.

ACTION_DOWN: For the first pointer that touches the screen. This starts the gesture. The pointer data for this pointer is always at index 0.
ACTION_POINTER_DOWN: For extra pointers that enter the screen beyond the first. The pointer data for this pointer is not 0.
ACTION_MOVE: A change has happened during a press gesture with first pointer.
ACTION_POINTER_UP: Sent when a non-primary pointer goes up.
ACTION_UP: Sent when the last pointer leaves the screen.

Index: A MotionEvent effectively stores information about each pointer in an array. The index of a pointer is its position within this array.
ID: Each pointer also has an ID mapping that stays persistent across touch events to allow tracking an individual pointer across the entire gesture.

Coordinates:

x,y: real pixels relatives to our View VerticalArrangement.
rawX, rawY: real pixels relatives to Screen (rawY is 47 more than y)

Pointer up and Pointer down are actual pointer coordinates (no first touch)

table: is a list of coordinates of all fingers in Screen, example:

204:1384,442:1106,488:693,943:584

xs: is a list of coordinates x

204,442,488,943

ys: is a list of coordinates y

1384,1106,693,584

http://kio4.com/appinventor/296_extension_estudio.htm

p196_multitouchestudio.aia (14.9 KB)

com.KIO4_MultitouchStudy.aix (10.8 KB)

Hola amigos, de nuevo con una extensión de Multitouch, recuerda que esto significa que puedes pulsar varias zonas de la pantalla a la vez.

En esta ocasión es un estudio de Multitiouch, pulsando en varias zonas de la pantalla obtenemos las coordenadas de los lugares tocados.

Puedes obtener más información esta página web:

http://kio4.com/appinventor/296_extension_estudio.htm

Saludos.

7 Likes

Other example of Multitouch, a no_pia_no

We set a VerticalArrangement with Height and Width: Fill parent, (this component fire onTouchListener), into several labels and an HorizontalArrangement with 8 images.

In Label1 we get a string with coordinates x:y —> 146:530,869:352,511:468,1250,570
In Label2, coordinates x—> 146 869 511 1250
In Label3, coordinates y—> 530 352 468 570


  • When touch over images, get position x and play a sound, look code.

  • This is only a didactic code, you can optimize it, this piano sounds as 100 cats inside a metal cask.

http://kio4.com/appinventor/296_extension_estudio.htm

Aquí pongo otro ejemplo de Multitouch, en este caso intenta ser un piano, podemos pulsar varias teclas a la vez y se oirá la mezcla de sonidos, como podrás oir no suena todo lo bien que debiera, pero esto es solo un ejemplo didáctico para trabajar con multitouch, tu puedes mejorar el código si te interesa.

p197_multitouch_piano.aia (128.5 KB)

2 Likes

Hello,
I’m not quite following how to make this work in Thunkable. Could you please explain to me step by step how to use Multitouch within Thunkable?
Thanks so much!

@carlin100i00 This topic is about the Classic version of Thunkable so if you’re using Thunkable X, you’ll need to find another way.

I don’t have a lot of experience with the Canvas but I’m guessing that you would use the “pointer” values for multitouch:

https://docs.thunkable.com/direction

Edit just tested those properties and… I could be wrong because they don’t show up in labels.

Thanks for your reply!
Hmmmmm so looks like it might not be possible to have multitouch at this stage?
I’ll check out Canvas, which I haven’t used before, see if I can find anything. I’ll post back here if I do.
Cheers