我正在使用XNA开发Windows应用程序。
实际上我成功移动了我的精灵,但我想在用户触摸精灵时添加不同的动作但不要移动它。我知道TouchlocationState
枚举exist但我不明白Moved
和Pressed
之间的区别。
现在我使用Released
,这就足够了,我更新精灵位置,而它没有被释放,然后我检查碰撞。
那么如何在点击时只添加一种触摸方法?我的意思是当用户点击精灵但不移动它。
一些代码:
TouchPanelCapabilities touchCap = TouchPanel.GetCapabilities();
if (touchCap.IsConnected)
{
TouchCollection touches = TouchPanel.GetState();
if (touches.Count >= 1)
{
Vector2 PositionTouch = touches[0].Position;
if (touches[0].State == TouchLocationState.Released)
{
// Pause button click and others buttons
Mouseclik((int)PositionTouch.X, (int)PositionTouch.Y);
}
if (!PausePopUp)
{
CheckMoove(PositionTouch);
if (touches[touches.Count - 1].State == TouchLocationState.Released)
{
// this is where i try to add/check if its only "click" on my sprite
if (touches[0].Position == touches[touches.Count - 1].Postion)
{
TempoRectangle = ListSprite[save].ShapeViser;
isclicked = true;
}
我的目标是在精灵上方添加一个图片框来显示信息,然后如果在图片框被显示时触摸了另一个精灵,我想在这两个精灵之间划一条线。
答案 0 :(得分:0)
区别很简单:
TouchLocationState.Pressed
表示检测到新位置。 TouchLocationState.Moved
表示位置位置已在同一位置更新或按下这意味着每次触摸操作只会获得Pressed
状态,按下触摸时每个周期都会Moved
一系列,当您释放它时,您将获得Released
1}}。
这也在您提供的链接中进行了解释。