Draw() public method

Draws the menu entry. This can be overridden to customize the appearance.
public Draw ( MenuScreen screen, bool isSelected, GameTime gameTime ) : void
screen MenuScreen
isSelected bool
gameTime Microsoft.Xna.Framework.GameTime
return void
Beispiel #1
0
        /// <summary>
        /// Draws the menu.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            // make sure our entries are in the right place before we draw them
            UpdateMenuEntryLocations();

            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

            spriteBatch.Begin();

            // Draw each menu entry in turn.
            for (var i = 0; i < menuEntries.Count; i++)
            {
                var menuEntry = menuEntries[i];
                if (menuEntry.Visible)
                {
                    menuEntry.Draw(this, gameTime);
                }
            }

            if (ShowBackMenuEntry && backMenuEntry.Visible)
            {
                backMenuEntry.Draw(this, gameTime);
            }

            DrawTitle();

            spriteBatch.End();
        }
Beispiel #2
0
        /// <summary>
        /// Draws the menu.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
            SpriteFont  font        = ScreenManager.Font;

            Vector2 position = new Vector2(100, 150);

            // 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);

            if (ScreenState == ScreenState.TransitionOn)
            {
                position.X -= transitionOffset * 256;
            }
            else
            {
                position.X += transitionOffset * 512;
            }

            spriteBatch.Begin();

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

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

                menuEntry.Draw(this, position, isSelected, gameTime);

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

            // Draw the menu title.
            Vector2 titlePosition = new Vector2(640 / 2, 80);
            Vector2 titleOrigin   = font.MeasureString(menuTitle) / 2;
            Color   titleColor    = new Color(192, 192, 192, TransitionAlpha);
            float   titleScale    = 1.25f;

            titlePosition.Y -= transitionOffset * 100;

            spriteBatch.DrawString(font, menuTitle, titlePosition, titleColor, 0,
                                   titleOrigin, titleScale, SpriteEffects.None, 0);


            spriteBatch.End();
        }
        /// <summary>
        /// Draws the menu
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            // Aligns the menu entry locations before drawing
            UpdateMenuEntryLocations();

            // Define the graphics and sprite batch
            GraphicsDevice graphics    = ScreenManager.GraphicsDevice;
            SpriteBatch    spriteBatch = ScreenManager.SpriteBatch;
            SpriteFont     font        = ScreenManager.Font;

            // Begin drawing
            spriteBatch.Begin();

            // Draw each menu entry in turn
            for (int i = 0; i < menuEntries.Count; i++)
            {
                // Store the current menu entry
                MenuEntry menuEntry = menuEntries[i];

                // Check to see if it is selected
                bool isSelected = IsActive && (i == selectedEntry);

                // Draw the menu
                menuEntry.Draw(this, isSelected, gameTime);
            }

            // 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);

            // Draw the menu title centered on the screen
            Vector2 titlePosition = new Vector2(graphics.Viewport.Width / 2, 90);
            Vector2 titleOrigin   = font.MeasureString(menuTitle) / 2;

            // Define the colour based on the state of the animation we are in
            Color titleColor = new Color(255, 255, 255) * TransitionAlpha;

            // Set a title scale
            float titleScale = 1.25f;

            // Set the title position to the transition offset for the animation
            titlePosition.Y -= transitionOffset * 100;

            // Draw the menu title at the top
            spriteBatch.DrawString(font, menuTitle, titlePosition, titleColor, 0, titleOrigin, titleScale, SpriteEffects.None, 0);
            spriteBatch.End();
        }
Beispiel #4
0
        /// <summary>
        /// Draws the menu.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            // make sure our entries are in the right place before we draw them
            UpdateMenuEntryLocations();

            GraphicsDevice graphics    = ScreenManager.GraphicsDevice;
            SpriteBatch    spriteBatch = ScreenManager.SpriteBatch;
            SpriteFont     font        = ScreenManager.Font;

            spriteBatch.Begin();



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

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

                menuEntry.Draw(this, isSelected, gameTime);
            }

            // 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);



            //don't want menu title for now
            // Draw the menu title centered on the screen
            Vector2 titlePosition = new Vector2(graphics.Viewport.Width / 2, graphics.Viewport.Height / 2 - 60);
            Vector2 titleOrigin   = font.MeasureString(menuTitle) / 2;
            Color   titleColor    = new Color(38, 106, 46) * TransitionAlpha;
            float   titleScale    = 1.25f;

            titlePosition.Y -= transitionOffset * 100;
            //don't want menu title
            spriteBatch.DrawString(font, menuTitle, titlePosition, titleColor, 0,
                                   titleOrigin, titleScale, SpriteEffects.None, 0);

            spriteBatch.End();
        }
Beispiel #5
0
        /// <summary>
        /// Draws the menu.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            // make sure our entries are in the right place before we draw them
            UpdateMenuEntryLocations();

            GraphicsDevice graphics    = ScreenManager.GraphicsDevice;
            SpriteBatch    spriteBatch = ScreenManager.SpriteBatch;
            SpriteFont     font        = styleFont;

            spriteBatch.Begin();

            // Draw each menu entry in turn
            Vector2 firstEntryPosition = Vector2.Zero;
            int     width  = graphics.Viewport.Width / 3;
            int     offset = (int)(graphics.Viewport.Width * 0.025f);

            for (int i = 0; i < menuEntries.Count; i++)
            {
                MenuEntry menuEntry = menuEntries[i];

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

                int height = (int)menuEntry.GetHeight(this);
                rect.X     = (int)menuEntry.Position.X - offset;
                rect.Y     = (int)menuEntry.Position.Y - height / 2;
                rect.Width = width + ((ActivePlayer.FullHDEnabled) ? 0 :
                                      (int)(ScreenManager.GraphicsDevice.Viewport.Width * 0.025f));
                rect.Height = height;

                if (isSelected)
                {
                    spriteBatch.Draw(selectedBackground, rect,
                                     Color.White * (TransitionAlpha - 0.2f));
                }
                else
                {
                    spriteBatch.Draw(menuBackground, rect,
                                     Color.White * (TransitionAlpha - 0.2f));
                }

                menuEntry.Draw(this, isSelected, gameTime);

                if (i == 0)
                {
                    firstEntryPosition = menuEntry.Position;
                }
            }

            // 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);

            // Draw the menu title centered on the screen
            float   titleScale    = 1.25f;
            Vector2 titleSize     = font.MeasureString(menuTitle) * titleScale;
            Vector2 titlePosition = new Vector2(rect.X + ((width - titleSize.X) / 2),
                                                firstEntryPosition.Y - (titleSize.Y * 1.5f));

            titlePosition.Y -= transitionOffset * 100;
            Vector2 titlePosition2 = titlePosition + new Vector2(graphics.Viewport.Width * 0.0025f,
                                                                 graphics.Viewport.Height * 0.0025f);

            // Print menu title
            spriteBatch.DrawString(font, menuTitle, titlePosition, Color.White * TransitionAlpha,
                                   0.0f, Vector2.Zero,
                                   titleScale, SpriteEffects.None, 0.0f);


            spriteBatch.End();

            base.Draw(gameTime);
        }