0
我正在寫一個簡單的益智遊戲,類似於遊戲三,但其中包含所有二者。它在編輯器中快速燃燒,但它在我的手機上運行不正常。這是我在Update()方法中爲滑動檢測編寫的代碼方法是否有什麼問題?注意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;
}
}
爲什麼你認爲這是問題? – Almo 2014-12-06 16:58:21
因爲當我只是使用touch.deltaPosition來檢測刷卡它以相同的速度工作@Almo – 2014-12-06 18:06:31