Advertisement
xerpi

Multitouch bug

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