我正在编写一个类似于游戏三的简单益智游戏,但其中包含所有两个游戏。它在编辑器中速度极快,但它在我的手机上运行不正常。这是我为Update()中的Swipe Detection编写的代码方法有什么问题吗?注意TouchComplete是全局变量
if (Input.touchCount > 0) {
Touch touch = Input.GetTouch (0);
switch (touch.phase) {
case TouchPhase.Began:
touchStart = touch.position;
TouchComplete = false;
break;
case TouchPhase.Moved:
if (TouchComplete)
return;
Vector2 deltaPostion = touch.position - touchStart;
if (Mathf.Abs (deltaPostion.x) < SWIPE_THRESHHOLD || Mathf.Abs (deltaPostion.y) < SWIPE_THRESHHOLD)
return;
if (Mathf.Abs (deltaPostion.x) > Mathf.Abs (deltaPostion.y)) {
if (deltaPostion.x > 0) {
RightSwipe ();
} else {
LeftSwipe ();
}
} else {
if (deltaPostion.y > 0) {
UpSwipe ();
} else {
DownSwipe ();
}
}
TouchComplete = true;
break;
default:
TouchComplete = true;
break;
}
}
答案 0 :(得分:0)
问题在于移动设备上的目标帧速率设置为30,因为动画效果很流畅我设置Application.targetFrameRate = 1000
并且它工作正常。