actionscript 3 - How to determine primary swipe direction (using MultiTouch) in AS3? -
i'm trying implement simple swipe recognition on touch screen using as3. need know whether swipe left, right, top, or bottom.
first question: easier using simple mouse_down , mouse_up, , calculate distance(s) moved?
or easier using multitouch?
i see code multitouch showing how implement swipe detection , getting direction thus:
if (e.offsety == 1) { //user swiped towards bottom square_mc.y += 100; } if (e.offsety == -1) { //user swiped towards top square_mc.y -= 100; } if (e.offsetx == 1) { //user swiped towards right square_mc.x += 100; } if (e.offsetx == -1) { //user swiped towards left square_mc.x -= 100; }
but if need resolve 1 direction (that left or up, right or bottom, etc), how do (and if offsetx , offsety true offsets, why checking +1 , -1 only? or function called during swipe? i'm trying 1 complete swipe).
i'm thinking skipping multitouch might simpler, welcome feedback. thanks!
you can answer own question(s) doing 2 things...
1 re-read tutorial code came from.. section headed "coding gesture" http://www.republicofcode.com/tutorials/flash/as3swipegesture/
2 experiment , learn observing results. example...
but if need resolve 1 direction (that left or.... how do that?
well what's wrong line in code provided if (e.offsetx == -1) { square_mc.x -= 100; }
. did test it? did square_mc not move left 100 pixels when swiped towards left direction? if worked have "resolved" 1 direction, guess. can add other if
statements other directions needed.
Comments
Post a Comment