Mintoris Forum

Author Topic: Multi-Touch Demo  (Read 3259 times)

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Multi-Touch Demo
« on: Oct 22, 2012, 12:34 AM »
This program requires Basic 5.6 and higher.  It demonstrates the use of the new TouchEvent command.

Code: [Select]
' Multi-Touch Demo
' Written by: Charles Charbonneau
' 10-05-2012

Graphics On
SetScale 400,800

button = LoadBitmap("graphics/calcbutton.png")

TouchDown = 0
TouchUp = 1
TouchMove = 2
TouchCancel = 3

maxPointers = 10

dim x(maxPointers)
dim y(maxPointers)

' Set all the button positions to -1
' to indicate the button is not visible.
x() = -1
y() = -1

TextAlign 0
TextColor 100,100,100
DrawText "Multi Touch Demo", 200,200,0

Color 0,0,0

Do

  ' Pause and wait for a touch event.
  TouchEvent action, idx, x, y

  ' If the first finger is lifted clear all the buttons
  if idx = 0 and (action = TouchUp or action = TouchCancel) then
    x() = -1
    y() = -1
  ' Otherwise update the pointer indicated by idx
  elseif idx >= 0 and idx <= 10 then
    x(idx) = x
    y(idx) = y
  endif

  ' Update the screen
  CLS
  DrawText "Action = " + str$(action) + "  Index = " + str$(idx),200,200,0
  For i = 0 to maxPointers
    if x(i) <> -1 and y(i) <> -1 then DrawBitmap button, x(i), y(i)
  Next

Loop
« Last Edit: Mar 23, 2016, 08:03 PM by Chuck »

rendomizer

  • Full Member
  • ***
  • Posts: 87
Re: Multi-Touch Demo
« Reply #1 on: Nov 25, 2015, 10:10 PM »
How many simultaneous touch is possible ?

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Re: Multi-Touch Demo
« Reply #2 on: Nov 26, 2015, 03:04 AM »
The maximum number of touches varies by device