• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Android flick event, how to restric movement to 4 directions?

anselm

Member
I want to add gesture base movement to my character, but i want to restrict the movement to just 4 directions. when i use the flick or drag end event, the character end up moving in all directions. can someone help? ;_;
 
Code:
var 4_way_dir = ((dir_you_flicked+45) div 90)*90;
Obviously dir_you_flicked is whatever direction you are getting from the flick. This code will return 0, 90, 180 or 270, depending what is the closest direction to the flick.
 
Top