I'm developing an RPG for iOS. Currently, I plan my controls to look like this:
So the user can interact with objects, people, etc. by tapping on the right side of the screen, and moves by swiping in the direction they want to go in on the left side of the screen. Right now, I'm having a problem with the movement controls. What I want is for there not to be a fixed d-pad; I want the user to be able to tap anywhere on the left side of the screen and swipe in the direction they want (within a range, demonstrated in the below image), and it seems easy enough to implement this.
However, I'm having a bit of a math problem. Since I'm developing for iOS, how I planned to implement this was to subclass UIView and have two properties,
endTouch that represented where the user began his/her swipe and where the user lifted his/her finger. Then, I could do a bit of math and discern which direction the swipe was in. But I'm having a bit of trouble doing the math, and that's what my question's about: given two points, how can I figure out if the swipe was going up, down, left, or right? Keep in mind that the user could tap anywhere on the screen and that tap is the center of the imaginary d-pad, like so: