我正在制作wp7应用程序,而我的触摸屏似乎无法工作。我写的代码是c#,xna,wp7触摸屏不工作
protected override void Update(GameTime gameTime)
{
TouchCollection touches = TouchPanel.GetState();
if (touches.Count > 0 && touches[0].State == TouchLocationState.Pressed)
{
SpriteFont font = Content.Load<SpriteFont>("Font");
Point touchPoint = new Point((int)touches[0].Position.X, (int)touches[0].Position.Y);
spriteBatch.Begin();
spriteBatch.DrawString(font, "hello ", new Vector2(touchPoint.X, touchPoint.Y), Color.White);
spriteBatch.End();
while (TouchPanel.IsGestureAvailable)
{
GestureSample gesture = TouchPanel.ReadGesture();
switch (gesture.GestureType)
{
case GestureType.Tap:
case GestureType.DoubleTap:
spriteBatch.Begin();
spriteBatch.DrawString(font, " ", new Vector2(touchPoint.X, touchPoint.Y), Color.White);
spriteBatch.End();
break;
}
}
}
base.Update(gameTime);
}
这是怎么回事?有没有任何接触?第一个的状态是什么?是否有错误被抛出? – 2011-05-03 08:31:17