locked
How do you clear touch panel buffer? RRS feed

  • Question

  • I have my touch panel set to tap and if i double tap on the screen it will act like two taps i have a timer delay for this tap event to happen but when the timer ends it will act like i have taped the screen when i have not. So how do you clear the buffer?
    1             if (onground)  
    2             {  
    3                 vel.X *= .90f;  
    4             }  
    5             else 
    6             {  
    7                 Charge = Charge < 100.0f ? Charge + (float)gameTime.ElapsedGameTime.Milliseconds/100 : 100.0f;  
    8             }  
    9             if (Charge >= 100.0f)  
    10             {  
    11                 while (TouchPanel.IsGestureAvailable)  
    12                 {  
    13                     GestureSample gesture = TouchPanel.ReadGesture();  
    14                     if (gesture.GestureType == GestureType.Tap)  
    15                     {  
    16                         Vector2 gestpos = Vector2.Zero;  
    17                         gestpos.X = gesture.Position.X;  
    18                         gestpos.Y = gesture.Position.Y;  
    19                         Vector2 Diff;  
    20                         Diff = pos - gestpos;  
    21                         float gestangle = (float)Math.Atan2(Diff.Y, Diff.X);  
    22                         vel.X += 5 * (float)Math.Cos(gestangle);  
    23                         vel.Y = Math.Abs(vel.Y);  
    24                         vel.Y += 5 * (float)Math.Sin(gestangle);  
    25                         Charge = 0.0f;  
    26                     }  
    27                 }  
    28             } 
    Tuesday, November 15, 2011 1:16 AM

All replies

  • Is there a problem with using GestureType.DoubleTap?
    Tuesday, November 15, 2011 1:44 AM
  • the thing is I dont want double tap just a single tap. But if I tap again when the timer is counting to 100 then when it reaches 100 it will automatically act like i have taped the screen.
    Tuesday, November 15, 2011 9:34 AM
  • What is the purpose of the timer?
    Tuesday, November 15, 2011 10:53 AM
  • The timer acts like a recharge bar to give the play more velocity. i have also found out how to solve the problem.
    1             if (onground)     
    2             {     
    3                 vel.X *= .90f;     
    4             }     
    5             else    
    6             {     
    7                 Charge = Charge < 100.0f ? Charge + (float)gameTime.ElapsedGameTime.Milliseconds/100 : 100.0f;     
    8             }       
    11                 while (TouchPanel.IsGestureAvailable)     
    12                 {     
    13                     GestureSample gesture = TouchPanel.ReadGesture();     
    14                     if (gesture.GestureType == GestureType.Tap)     
    15                     {     
    9                         if (Charge >= 100.0f)     
    10                        {   
    16                         Vector2 gestpos = Vector2.Zero;     
    17                         gestpos.X = gesture.Position.X;     
    18                         gestpos.Y = gesture.Position.Y;     
    19                         Vector2 Diff;     
    20                         Diff = pos - gestpos;     
    21                         float gestangle = (float)Math.Atan2(Diff.Y, Diff.X);     
    22                         vel.X += 5 * (float)Math.Cos(gestangle);     
    23                         vel.Y = Math.Abs(vel.Y);     
    24                         vel.Y += 5 * (float)Math.Sin(gestangle);     
    25                         Charge = 0.0f;     
                               }  
    26                     }     
    27                 }     
     


    Wednesday, November 16, 2011 12:52 AM