【发布时间】:2011-05-02 18:42:22
【问题描述】:
我正在制作一个 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);
}
【问题讨论】:
-
这怎么行不通?有没有接触过?第一个是什么状态?是否抛出任何错误?
标签: c# windows-phone-7 touchscreen xna-4.0