- Home /
Detect swipe up gesture IOS
I know that there is a way to detect the swipe up gesture, but how do I detect a swipe up gesture. I don't care how long the swipe up gesture is, I just want to do an if statement like this:
public bool nextswipe = false;
if (swipe up gesture) {
if (nextswipe == false) {
nextswipe = true;
//do something
}
} else if (!swipe up gesture) { // no swipe gesture
nextswipe = false;
}
Answer by Nanofication · Feb 05, 2016 at 02:49 AM
I recommend writing your own boolean function to check if you swiped up on the screen. Then just put that function into your if statement and check if that's true.
In my custom function, I calculated the difference between where I pressed on the screen and where I released. If the difference is greater than zero, I considered it as a swipe up gesture.
Well, how do I detect a swipe up gesture from a tap? But thank you very much for the answer :D
Where do I find the y-axis for swipes? For me, I will calculate if the difference and if the difference is greater than 0.5 (for accuracy) then I will consider it swipe up.
touch.deltaposition.y came from heaven :D Here is my code: if (touch.deltaposition.y >= (touch.position.y + 10)) { //+10 px for accuracy xD jump(); }
Your answer
Follow this Question
Related Questions
Detect the swipe and add force respective to it? 3 Answers
IOS GUI slider 1 Answer
Delta touch trembling 0 Answers
Reproducing the "spin" effect of Flick Kick Football 1 Answer
Turning touch to rotation 1 Answer