SunsetHigh.Character.setDirection C# (CSharp) Method

setDirection() public method

Sets the direction of this Character and updates which row on the spritesheet to animate
public setDirection ( Direction dir ) : void
dir Direction Direction of this Character
return void
        public void setDirection(Direction dir)
        {
            if (dir.Equals(Direction.Undefined)) return;

            //we should have a standard convention for spritesheets
            //i.e. each row is a direction
            if (this.getImageRows() >= 4)
            {
                switch (dir)
                {
                    case Direction.NorthEast:
                    case Direction.NorthWest:
                    case Direction.North: this.setFrameRow(3);
                        this.direction = Direction.North; break;
                    case Direction.SouthEast:
                    case Direction.SouthWest:
                    case Direction.South: this.setFrameRow(0);
                        this.direction = Direction.South; break;
                    case Direction.East: this.setFrameRow(2);
                        this.direction = Direction.East; break;
                    case Direction.West: this.setFrameRow(1);
                        this.direction = Direction.West; break;
                    default: break;
                }
            }
        }