【发布时间】:2013-11-14 22:09:33
【问题描述】:
我正在使用 XNA 开发一个 Windows 应用程序。
实际上我成功移动了我的精灵,但我想在用户触摸精灵但不移动它时添加不同的动作。我知道TouchlocationState Enum 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;
}
我的目标是在精灵上方添加一个图片框以显示信息,然后如果在显示图片框时触摸另一个精灵,我想在这两个精灵之间画一条线。
【问题讨论】:
标签: c# xna xna-4.0 touchscreen