I have plenty of solutions laying around as there are many but my favorite way is the following:
ObjectCollider = the object that collides with solids and is the object that is moved around
ObjectState = The object that determines what direction collisions are occurring from. The size of the sprite should be one pixel greater on all sides as the objectCollider, with the same origin as well. The collision polygon should then be adjusted so that it is only on the right of the Sprite. Depending on the scenario, you will need to adjust the relative sizes of the boxes based on your needs. Also, the Object state needs the following instance variables: Up, Down, Left, and Right (they are booleans). This way will work if the object is square or round. (if other then see note below)
Whenever you create an ObjectCollider it creates an Object State (you can put these in containers so it happens automatically, but if you need them in families it gets a little more difficult as you would need to track UIDs and use parents)
Every Frame, ObjectState needs to be updated in the following ways:
1. Set its position to the parent ObjectCollider
2. If it is overlapping an object that is Solid set "Right" to true, else set it to false.
3. rotate ObjectState 90 degrees (now it is facing down) and test for overlapping solids...
4... I think you can figure out the rest...
If you are not using a round or square object, then you will need to create an ObjectStateUp, ObjectStateDown, and so on and attach them to respective image points on the ObjectCollider.
Any Questions? Overall, this is a pretty basic need in games and I am supprised their has not been made a behavior to get that data. I need this in every game I make so I created a blank project that uses families and does it all automatically when I create an object and put it in family SpriteColliders.