C# 游戏在手机上运行缓慢,但在电脑上运行良好
我正在写一个简单的益智游戏,类似于游戏三,但其中包含了所有的两个。它在编辑器中运行得很快,但在我的手机上运行不正常。这是我为更新方法中的滑动检测编写的代码。这有什么问题吗?注意TouchComplete是一个全局变量C# 游戏在手机上运行缓慢,但在电脑上运行良好,c#,mobile,unity3d,touch,C#,Mobile,Unity3d,Touch,我正在写一个简单的益智游戏,类似于游戏三,但其中包含了所有的两个。它在编辑器中运行得很快,但在我的手机上运行不正常。这是我为更新方法中的滑动检测编写的代码。这有什么问题吗?注意TouchComplete是一个全局变量 if (Input.touchCount > 0) { Touch touch = Input.GetTouch (0); switch (touch.phase) { case TouchPhase.Began:
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;
}
}
问题在于移动设备上的目标帧速率设置为30,为了使动画效果平滑,我将应用程序设置为.targetFrameRate=1000,效果很好。您认为这是为什么问题?因为当我仅使用touch.deltaPosition检测滑动时,它的工作速度与@Almo相同