C# 在Windows Phone 8上使用触摸屏拖动对象时,如何防止延迟?
我正在用C#和XNA为WindowsPhone8制作一个游戏。游戏包括在屏幕上拖动物体。update方法使用以下代码移动对象C# 在Windows Phone 8上使用触摸屏拖动对象时,如何防止延迟?,c#,input,windows-phone-8,xna,windows-phone,C#,Input,Windows Phone 8,Xna,Windows Phone,我正在用C#和XNA为WindowsPhone8制作一个游戏。游戏包括在屏幕上拖动物体。update方法使用以下代码移动对象 //Check for input on the touchscreen GestureSample gesture = TouchPanel.ReadGesture(); //'selectedObject' is a variable of type 'GameObject' - It refers to the current object that is bei
//Check for input on the touchscreen
GestureSample gesture = TouchPanel.ReadGesture();
//'selectedObject' is a variable of type 'GameObject' - It refers to the current object that is being moved
if (selectedObject == null)
{
//The method checks which game object to use as the selected object if one is not already being moved
foreach (GameObject gameObject in gameObjects)
{
//Check if the input is a dragging motion and that the user's input intersects with the objects hitbox
if (gesture.GestureType == GestureType.FreeDrag && gameObject.Hitbox.Contains((int)gesture.Position.X, (int)gesture.Position.Y))
{
//Make 'selectedObject' refer to the newly touched game object
selectedObject = gameObject;
//'selectedPosition' is a 'Vector2' that is used in the drawing method to draw the selected object at a specific point on the screen
selectedPosition = gesture.Position;
break;
}
}
}
else
{
//If an object is currently being moved, update its position
selectedPosition = gesture.Position;
}
代码成功地移动了正确的对象,并显示它们正在移动。然而,物体的运动明显延迟。如果在拖动对象时用户的手指在屏幕上向上移动,则该对象需要几秒钟才能跟上。选定对象的移动不会减慢其他对象的速度(它们随机移动,并以与用户开始交互之前相同的速度继续移动)。如何防止这种延迟并实时显示正在移动的选定对象(即,当用户的手指向一个方向移动时,显示对象立即跟随,而不是停留一秒钟然后重复该操作)?您是否尝试过“手势.手势类型==手势类型.触地”或其他方法?这可能是您的问题,但我不能确定。
GestureType.touching
在GestureType枚举中不作为选项出现。有没有一个具体的参考,我需要包括?在快速查看后,我看到,没有一个真正的类型类似于着陆事件。但就像我说的,我不知道这是否是你的问题。