简体   繁体   English

unity C# IOS 滑动检测

[英]Unity C# IOS Swipe detection

In my current Game, I am detecting the swipe but the player must release their finger from the screen to register each swipe direction.在我当前的游戏中,我正在检测滑动,但玩家必须从屏幕上松开手指才能注册每个滑动方向。 What do I need to do in order for the player to not have to lift their finger from the screen?我需要做什么才能让玩家不必从屏幕上抬起手指?

For example, I want the player to be able to swipe up "Which will move my player up" then swipe right "moving my player to the right" all without lifting their finger off the screen.例如,我希望播放器能够向上滑动“这将使我的播放器向上移动”,然后向右滑动“将我的播放器向右移动”,所有这些操作都无需将手指从屏幕上移开。 My current way of doing it doesn't work for this and the player has to take their finger off the screen between each swipe.我目前的做法对此不起作用,玩家必须在每次滑动之间将手指从屏幕上移开。

You can use oldPositionX and newPositionX finger do detect it您可以使用 oldPositionX 和 newPositionX 手指来检测它

    if ((oldPositionX - newPositionX).magnitude > minOffcetFinger)
    {
       // Some code
       oldPositionX = newPositionX;
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM