Project_Starfighter.MenuComponent.MeasureMenu C# (CSharp) Method

MeasureMenu() public method

Measures the game menu screen and finds the center.
public MeasureMenu ( ) : void
return void
        public void MeasureMenu()
        {
            height = 0;
            width = 0;
            foreach (string item in menuItems)
            {
                Vector2 size = spriteFont.MeasureString(item);
                if (size.X > width)
                    width = size.X;
                height += spriteFont.LineSpacing + 5;
            }

            position = new Vector2(
                (Game.Window.ClientBounds.Width - width) / 2,
                (Game.Window.ClientBounds.Height - height) / 2);
        }