Exemplo n.º 1
0
        /// <summary>
        /// Draws the menu.  Tweaked a bit from the sample so that it draws menus on the bottom left corner and transitions
        /// on and off from the bottom.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            if (menuEntries.Count > 0)
            {
                SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
                SpriteFont  font        = ScreenManager.Font;

                Vector2 position = new Vector2(40, 290 - menuEntries[0].GetHeight(this));

                // Make the menu slide into place during transitions, using a
                // power curve to make things look more interesting (this makes
                // the movement slow down as it nears the end).
                float transitionOffset = (float)Math.Pow(TransitionPosition, 2);

                position.Y += transitionOffset * 512;

                spriteBatch.Begin();

                // Draw each menu entry in turn.
                for (int i = menuEntries.Count - 1; i >= 0; --i)
                {
                    MenuEntry menuEntry = menuEntries[i];

                    bool isSelected = IsActive && (i == selectedEntry);

                    position.X = 120 - font.MeasureString(menuEntry.Text).X / 2;
                    menuEntry.Draw(this, position, isSelected, gameTime);

                    position.Y -= menuEntry.GetHeight(this);
                }

                spriteBatch.End();
            }
        }