You can always detect the sprite's angle of movement, so then it is just a matter of selecting the animation that goes with that angle. If you have four animations which you name left, right, up, down, and the sprite's angle is 180, then you set the animation "left" for the sprite. If the sprite's angle is 90, then you set the animation to "down" and so on.