Guest User

Untitled

a guest
Jan 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.46 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.Xna.Framework;
  4. using Microsoft.Xna.Framework.Graphics;
  5. using Microsoft.Xna.Framework.Input;
  6. using Microsoft.Xna.Framework.Input.Touch;
  7.  
  8. namespace GameStates
  9. {
  10.     class Input
  11.     {
  12.         static Point index;
  13.         public static void Init()
  14.         {
  15.             TouchPanel.EnabledGestures =
  16.                 GestureType.Hold |
  17.                 GestureType.Tap |
  18.                 GestureType.DoubleTap |
  19.                 GestureType.FreeDrag |
  20.                 GestureType.Flick |
  21.                 GestureType.Pinch;
  22.         }
  23.  
  24.         public static void checkInput()
  25.         {
  26.            
  27.         }
  28.         public static bool checkTap()
  29.         {
  30.             while (TouchPanel.IsGestureAvailable)
  31.             {
  32.                 GestureSample gesture = TouchPanel.ReadGesture();
  33.  
  34.                 switch (gesture.GestureType)
  35.                 {
  36.                     case GestureType.Tap:
  37.                         return true;
  38.                 }
  39.             }
  40.             return false;
  41.         }
  42.  
  43.         public static Point getPosition()
  44.         {
  45.  
  46.             TouchCollection touches = TouchPanel.GetState();
  47.             if (touches.Count > 0 && touches[0].State == TouchLocationState.Pressed)
  48.             {
  49.                 index = new Point((int)touches[0].Position.X, (int)touches[0].Position.Y);
  50.                 return index;
  51.             }
  52.             return index;
  53.         }
  54.     }
  55. }
Add Comment
Please, Sign In to add comment