Advertisement
xerpi

Touch algorithm

Apr 23rd, 2012
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 KB | None | 0 0
  1. foreach(var touchInfo in Touch.GetData (0)){
  2.                 //If there's no racket finger ID...
  3.                     if(this.finger_ID == 0){
  4.                         //If you PRESS near the racket...
  5.                             if( touchInfo.X > (this.x - 25) && touchInfo.X < (this.x + 25)){
  6.                                 //Set the racket finger ID!!
  7.                                     if(touchInfo.Status == TouchStatus.Down){
  8.                                         this.finger_ID = touchInfo.ID;
  9.                                         break;
  10.                                     }
  11.                             }
  12.                  //If the racket has a finger ID...
  13.                     }else{
  14.                         //If you release the finger, the racket finger ID will be 0.
  15.                             if(touchInfo.Status == TouchStatus.Canceled || touchInfo.Status == TouchStatus.Up){
  16.                                 this.finger_ID = 0;
  17.                                 break;
  18.                         //If you press and there's no racket finger ID, set the racket finger ID
  19.                             }else if(touchInfo.Status == TouchStatus.Down){
  20.                                 this.finger_ID = touchInfo.ID;
  21.                                 break;
  22.                         //If you move the finger and there's a racket finger ID, just move the racket :)
  23.                             }else if(touchInfo.Status == TouchStatus.Move){
  24.                                 //If you MOVE near the racket...
  25.                                     if( touchInfo.X > (this.x - 25) && touchInfo.X < (this.x + 25)){
  26.                                         this.y = (touchInfo.Y + 0.5f) * 544;
  27.                                     }
  28.                                     break;
  29.                             }
  30.                     }
  31.                 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement