Beispiel #1
0
        /// <summary>
        /// Draws the menu entry. This can be overridden to customize the appearance.
        /// </summary>
        /// <param name="screen">The screen.</param>
        /// <param name="isSelected">if set to <c>true</c> [is selected].</param>
        /// <param name="gameTime">Time passed since the last call to Draw.</param>
        public virtual void Draw(QuizGameScreen screen, bool isSelected, GameTime gameTime)
        {
            // Draw the selected entry in yellow, otherwise white.
            Color color = isSelected ? this.SelectedColor : this.UnselectedColor;

            // Modify the alpha to fade text out during transitions.
            color *= screen.TransitionAlpha;

            // Draw text, centered on the middle of each line.
            ScreenManager screenManager = screen.ScreenManager;
            SpriteBatch   spriteBatch   = screenManager.SpriteBatch;
            SpriteFont    font          = screenManager.Font;

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

            spriteBatch.DrawString(font, this._text, this.Position, color, 0,
                                   origin, 1, SpriteEffects.None, 0);
        }
Beispiel #2
0
 /// <summary>
 /// Gets the width.
 /// </summary>
 /// <param name="screen">The screen.</param>
 /// <returns></returns>
 public int GetWidth(QuizGameScreen screen)
 {
     return((int)screen.ScreenManager.Font.MeasureString(Text).X);
 }
Beispiel #3
0
        /// <summary>
        /// Gets the height.
        /// </summary>
        /// <param name="screen">The screen.</param>
        /// <returns></returns>
        public int GetHeight(QuizGameScreen screen)
        {
            int lineNumbers = _text.Count(c => c == '\n') + 1;

            return(screen.ScreenManager.Font.LineSpacing * lineNumbers);
        }