I'm attempting to write a function that returns a SpriteBase.Direction indicating what direction, if any, the sprite has just been stopped from going. For example, if they hit a wall, floor, or ceiling:
public int DirectionStop()
{
Debug.Assert(this.isActive, "Attempted to execute DirectionStop on an inactive sprite");
if (Blocked(Direction.Down) || IsRidingPlatform())
if (oldY < y && dy == 0)
return (int)Direction.Down;
if (Blocked(Direction.Up))
if (oldY > y && dy == 0)
return (int)Direction.Up;
if (Blocked(Direction.Left))
if (oldX > x && dx == 0)
return (int)Direction.Left;
if (Blocked(Direction.Right))
if (oldX < x && dx == 0)
return (int)Direction.Right;
return -1;
}
This works in most cases (not counting dx-y/LocalDX-Y problems w/ platforms right now) except when moving along slopes. It seems to consider whenever you're moving along a slope to be blocked. Any idea why? It's called after ReactToSolid and SnapToGround.