Advertisement
Guest User

Untitled

a guest
Aug 14th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.13 KB | None | 0 0
  1.             touchCollection = TouchPanel.GetState();
  2.  
  3.  
  4.             if (touchCollection.Count > 0)
  5.             {
  6.                 //Only Fire Select Once it's been released
  7.                 if (touchCollection[0].State == TouchLocationState.Pressed)
  8.                 {
  9.                     OldtouchCollection = TouchPanel.GetState();
  10.                     Debug.WriteLine("Pressed");
  11.                 }
  12.                 else if (touchCollection[0].State == TouchLocationState.Moved)
  13.                 {
  14.                     //Debug.WriteLine("x: " + (touchCollection[0].Position.X - OldtouchCollection[0].Position.X) + " /y: " + (touchCollection[0].Position.Y - OldtouchCollection[0].Position.Y));
  15.                     //Debug.WriteLine("Old touch : x: " + OldtouchCollection[0].Position.X + " /y: " + OldtouchCollection[0].Position.Y);
  16.                     //Debug.WriteLine("New touch : x: " + touchCollection[0].Position.X + " /y: " + touchCollection[0].Position.Y);
  17.  
  18.                 }else if (touchCollection[0].State == TouchLocationState.Released)
  19.                 {
  20.                     Vector2 finger = new Vector2(OldtouchCollection[0].Position.X - touchCollection[0].Position.X, OldtouchCollection[0].Position.Y - touchCollection[0].Position.Y);
  21.                     if (Math.Abs(finger.X) < 10 && Math.Abs(finger.Y) < 10)
  22.                     {
  23.                         Debug.WriteLine("Tap !");
  24.                     }
  25.                     else if (Math.Abs(finger.X) > Math.Abs(finger.Y))
  26.                     {
  27.                         if (finger.X > 0)
  28.                         {
  29.                             Debug.WriteLine("Swipe Left");
  30.  
  31.                         }else
  32.                         {
  33.                             Debug.WriteLine("Swipe Right");
  34.                         }
  35.  
  36.                     }else
  37.                     {
  38.                         if (finger.Y > 0)
  39.                         {
  40.                             Debug.WriteLine("Swipe Up");
  41.                         }
  42.                         else
  43.                         {
  44.                             Debug.WriteLine("Swipe Down");
  45.                         }
  46.                     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement