Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在Windows Phone 8上使用触摸屏拖动对象时,如何防止延迟?_C#_Input_Windows Phone 8_Xna_Windows Phone - Fatal编程技术网

C# 在Windows Phone 8上使用触摸屏拖动对象时,如何防止延迟?

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

我正在用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 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枚举中不作为选项出现。有没有一个具体的参考,我需要包括?在快速查看后,我看到,没有一个真正的类型类似于着陆事件。但就像我说的,我不知道这是否是你的问题。