经过了不断的调试,终于解决了这个问题,虽然花的时间久了些,不过很值得
这是移动的代码
if(Input.touchCount>0&&Input.GetTouch(0).phase.Equals(TouchPhase.Began))
{
touchBeganPosition = Input.GetTouch(0).position;
}
//这是触屏的代码
TouchDirection direction = TouchDirection.None;
direction = GetTouchDirection();
if(direction==TouchDirection.None)
{
return;
}
通过switch控制方向
switch (direction)
{
case TouchDirection.None:
return;
case TouchDirection.Top:
…
break;
case TouchDirection.Botton:
…
break;
case TouchDirection.Left:
….
break;
case TouchDirection.Right:
…..
break;
}
private TouchDirection GetTouchDirection()
{
if (Input.touchCo