Livecode ha incorporato anche un sistema per gestire il multitouch senza limite al numero di dita da poter utilizzare contemporaneamente. Questo sistema funziona su Android e iOS.
I messaggi da intercettare sono: touchStart, touchMove e touchEnd.
Per ognuno di essi abbiamo a disposizione un identificatore unico (tID) del dito a contatto con lo schermo, che è rappresentato da un numero.
- touchStart è inviato appena un dito tocca lo schermo
- touchMove è inviato quando un dito scorre sullo schermo, fornisce anche la posizione (X,Y) del dito
- touchEnd è inviato appena un dito si stacca dallo schermo
on touchstart tID lock screen create field ("dito" & tID) set the width of the field ("dito" & tID) to 250 put "1," & (22 * tID) into temp #posizione set the topleft of the field ("dito" & tID) to temp create graphic ("dito" & tID) set the opaque of graphic ("dito" & tID) to True set the style of graphic ("dito" & tID) to oval put (25 * tID) & comma & (25 * tID) & comma & (25 * tID) into temp #colore set the backgroundcolor of graphic ("dito" & tID) to temp set the width of graphic ("dito" & tID) to 30 set the height of graphic ("dito" & tID) to 30 unlock screenend touchstart
on touchend tID delete field ("dito" & tID) delete graphic ("dito" & tID)end touchend
on touchmove tID, tX, tY set the text of field ("dito" & tID) to ("il dito " & tID & " si trova in " & tX & comma & tY) set the loc of graphic ("dito" & tID) to (tX & comma & tY)end touchmoveEd ecco il risultato su un cellulare Android:

Nessun commento:
Posta un commento