Пример #1
0
        public override void Draw(MenuScreenBase screen, Vector2 position, bool isSelected, GameTime gameTime)
        {
            // Draw the selected entry in yellow, otherwise white.
            Color color = isSelected ? Color.Yellow : Color.White;

            // Pulsate the size of the selected menu entry.
            double time = gameTime.TotalGameTime.TotalSeconds;

            float pulsate = (float)Math.Sin(time * 6) + 1;

            float scale = 1 + pulsate * 0.05f * selectionFade;

            // Modify the alpha to fade text out during transitions.
            color = screen.TransitionColor(color);

            var spriteBatch = screen.ScreenManager.SpriteBatch;
            var font = screen.ScreenManager.SharedSmallFont;

            Vector2 origin = new Vector2(0, font.LineSpacing / 2);

            string text = typedText;
            if (isPassword)
                text = "".PadRight(text.Length, '*');

            if (isSelected) text += "_";

            spriteBatch.DrawString(font, text, position + new Vector2(300, 0), color, 0.0f, origin, scale, SpriteEffects.None, 0);

            base.Draw(screen, position, isSelected, gameTime);
        }
Пример #2
0
        public virtual void Draw(MenuScreenBase screen, Vector2 position, bool isSelected, GameTime gameTime)
        {
            // Draw the selected entry in yellow, otherwise white.
            Color color = isSelected ? Color.Yellow : Color.White;

            // Pulsate the size of the selected menu entry.
            double time = gameTime.TotalGameTime.TotalSeconds;

            float pulsate = (float)Math.Sin(time * 6) + 1;

            float scale = 1 + pulsate * 0.05f * selectionFade;

            // Modify the alpha to fade text out during transitions.
            color = screen.TransitionColor(color);

            var spriteBatch = screen.ScreenManager.SpriteBatch;
            var font = screen.ScreenManager.SharedHeaderFont;

            Vector2 origin = new Vector2(0, font.LineSpacing / 2);

            spriteBatch.DrawString(font, _text, position, color, 0.0f, origin, scale, SpriteEffects.None, 0);
        }