纳金网
标题:
触摸屏滑动的代码
[打印本页]
作者:
烟雨
时间:
2015-5-29 02:51
标题:
触摸屏滑动的代码
触摸屏滑动的代码
if (Input.GetMouseButtonDown(0))
{
began = Input.mousePosition;
isTouch = true;
}
else if (Input.GetMouseButton(0))
{
Vector2 mouseUp = Input.mousePosition;
Vector2 touchOffset = mouseUp - began;
if ((Mathf.Abs(touchOffset.x) > 50 || Mathf.Abs(touchOffset.y) > 50 && isTouch))
{
if (Mathf.Abs(touchOffset.x) > Mathf.Abs(touchOffset.y) && touchOffset.x > 0)
{
isTouch = false;
MoveRight();
if (hasMove)
{
RandomCard();
}
}
}
else if ((Mathf.Abs(touchOffset.x) > 50 || Mathf.Abs(touchOffset.y) > 50 && isTouch))
{
if (Mathf.Abs(touchOffset.x) > Mathf.Abs(touchOffset.y) && touchOffset.x < 0)
{
isTouch = false;
MoveLeft();
if (hasMove)
{
RandomCard();
}
}
}
else if ((Mathf.Abs(touchOffset.x) > 50 || Mathf.Abs(touchOffset.y) > 50 && isTouch))
{
if (Mathf.Abs(touchOffset.x) < Mathf.Abs(touchOffset.y) && touchOffset.y > 0)
{
isTouch = false;
MoveUp();
if (hasMove)
{
RandomCard();
}
}
}
else if ((Mathf.Abs(touchOffset.x) > 50 || Mathf.Abs(touchOffset.y) > 50 && isTouch))
{
if (Mathf.Abs(touchOffset.x) < Mathf.Abs(touchOffset.y) && touchOffset.x < 0)
{
isTouch = false;
MoveDown();
if (hasMove)
{
RandomCard();
}
}
}
}
复制代码
欢迎光临 纳金网 (http://go.narkii.com/club/)
Powered by Discuz! X2.5