Edit
I have improved it
TheIt seems the key thing I changed is to deal with your AABB's in terms of Left and Right, and stop thinking about X and Yclassifying the intersections.
Intersections are either:
You want to "push" only in the direction to allieviate the greatest number of pixel overlap (ie cancel it out by pushing the player back.
- Ceiling bumps
- Ground hits (push out of the floor)
- Mid-air wall collisions
- Grounded wall collisions
and I broke it down into 4 intersection cases: (p=player, t=some other tile/object)resolve them in that order
Define a ground collision as player being at least 1/4 way on the tile
So in case 1, for example, pthis is falling down onto ta ground collision and the player (landing, or case of rising floorblue). In case 2, p has hit t will sit on top of the tile (the ceilingblack) with his head. 
In case 1, I will pushBut this is NOT a ground collision and the player up. In case 3, I will push"slip" on the player left. In all cases, only pushright side of the player exactly enough so thattile when he and the object are no longer overlapping.
The meat oflands on it is here, where we check for: 
The depth (or encroachment) of pixel overlap in x and y (encrX, encrY) between the 2 tiles
The number of pixels overlapped in x and y (numPxOverlapX, numPxOverlapY)
See this link forBy this method the code (XNA 4.0) (copy and paste into VS 2010).player will no longer get caught on the sides of walls
- This code may break down if objects are moving too fast.
