Question about yvel with canvas.flung (trying to do four way swipes)

144 views
Skip to first unread message
Assigned to scottfr...@gmail.com by me

horsefacec...@gmail.com

unread,
Apr 2, 2014, 4:51:28 AM4/2/14
to mitappinv...@googlegroups.com
Hello :)

I am using canvas.flung to call different procedures and am having trouble with finding information about the way yvel works. I am making a book and by using "if xvel is greater than 0 then call.next" else if " xvel is less than 0 then call.last" for left to right swiping. It works great. To implement up or down I check if yvel is greater than xvel than if it is I check to see if yvel is greater than or less than 0.  

The weird thing is it sometimes works for swiping down and then other times it perceives the down swipe as a left or right swipe....

My question is: what is the start point for yvel? It seems like for xwhere you touch is zero and if you go right it increases and if you go left it decreases, is that right? I am sorry if I am asking the wrong questions, but my googlefu is failing me and I can't find documentation/examples for this.

I added a screenshot here, thanks for taking the time.


Scott Ferguson

unread,
Apr 2, 2014, 6:16:41 AM4/2/14
to mitappinv...@googlegroups.com, horsefacec...@gmail.com
Fling up and yvel < 0 
Fling down and yvel > 0 
I think your problem is tying yvel to xvel.
I don't think you need to connect the two.
Just treat up and down flings just like you do for left, right flings.
You should not need to compare yvel to xvel at all, I wouldn't think.
---
Scott

horsefacec...@gmail.com

unread,
Apr 2, 2014, 6:40:16 AM4/2/14
to mitappinv...@googlegroups.com, horsefacec...@gmail.com
Hi Scott,

Thanks for the reply. When I do that it is only reacting to the xvel. I made something much simpler to test it out just in case and it doesn't work.

Scott Ferguson

unread,
Apr 2, 2014, 7:32:33 AM4/2/14
to mitappinv...@googlegroups.com, horsefacec...@gmail.com
OK I see the problem.
Comparing  xvel or yvel to 0 in this case will not work.

You need to have a minimum value other than zero to compare it to to indicate the the user did in fact intend to swipe in that direction.
That would be called a threshold value.
If the swipe exceeds the threshold value then the user was swiping in that direction.
If not then ignore it.
This threshold value looks like it could be around +1 or -1 for flinging in any direction.
if xvel > 1 then flinging right
if xvel < -1 then flinging left
if vvel > 1 then flinging down
if yvel < -1 then flinging up

You may need to adjust the threshold value for the anticipated swipe speed.
---
Scott

horsefacec...@gmail.com

unread,
Apr 2, 2014, 7:54:28 AM4/2/14
to mitappinv...@googlegroups.com, horsefacec...@gmail.com
Thank you so much!

Here is what I finally did and it works almost perfectly






Reply all
Reply to author
Forward
0 new messages