I had this same issue, I was using sprites with 8 different directions of movement. Here's how I detected which direction they were moving in:
The way the sprite is facing depends on the direction they were last moving in.
You can find the direction of sprite movement by performing some calculations on their original coordinates, and the coordinates of their destination.
First, imagine there are four quadrants around your sprite. NorthWest, SouthWest, SouthEast and NorthEast. You can detect which one the sprite is moving towards by comparing the X and Y coordinates of their current position to those of their destination.
For example, if X is less, and Y is more than their current point, we know that they are moving in a SouthEastern direction.
Next, you need to use some trigonometry.
To find the angle that your sprite is moving, draw an imaginary right-angled triangle between the sprite and the destination. The length and width of this triangle are found by comparing the coordinates.
For example, currentXPosition - destinationXPosition. Sometimes the result will be a negative value. This can't be used, so you have to convert it to a positive, or find its absolute value.
In this triangle, we know the length of the two sides (they are called the opposite and adjacent), so to find the angle you use ArcTan in the calculation. This will return an angle in radians, all you have to do then is convert it into degrees.
So now you have a movement angle. It will never be more than 45 degrees.
Now you need to place this angle in a 360 degree space to find which direction your sprite is facing.
Because you know which quadrant the destination coordinates are in, you know one of four possible directions. This tells you how much angle you should add.
For example, if I know the sprite is facing toward the North West quadrant, I have to add 270 degrees to my current angle.
If they are moving toward the North East, I add zero. If they are moving toward the South East, I add 90 degrees to my angle. And so on.
The rest is easy, just using conditions to find out which of the eight different animations should be played based on if they are moving N, NW, W, SW, S, SE, E or NE.
Eg. They're moving toward the South East quadrant, so you add 90 to the angle.
-If they are moving South East but the angle is less than 120, they are moving East.
-If the angle is greater than 120 but less than 150, they are moving South East.
-If they are doing neither of these things, they must be moving South.
I hope this is easy to understand and that it helps.
You can also find the distance that they move by calculating the hypotenuse side of the triangle.