DrawString() public method

Draws a string.
public DrawString ( string text, Font font, Rectangle rectangle, Color color ) : void
text string The Text.
font Font The Font.
rectangle Sharpex2D.Math.Rectangle The Rectangle.
color Color The Color.
return void
Esempio n. 1
0
 public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
 {
     p1Bounds = new Rectangle(new Vector2(0, 0), spriteBatch.MeasureString(scoreBoardPlayer1, Font));
     p2Bounds = new Rectangle(new Vector2(GraphicsDevice.BackBuffer.Width - spriteBatch.MeasureString(scoreBoardPlayer2, Font).X, 0), spriteBatch.MeasureString(scoreBoardPlayer2, Font));
     spriteBatch.DrawString(scoreBoardPlayer1, Font, p1Bounds, Color);
     spriteBatch.DrawString(scoreBoardPlayer2, Font, p2Bounds, Color);
 }
Esempio n. 2
0
 /// <summary>
 /// Draws the MenuButton.
 /// </summary>
 /// <param name="spriteBatch">The spriteBatch.</param>
 public override void OnDraw(SpriteBatch spriteBatch)
 {
     Vector2 dim = spriteBatch.MeasureString(Text, _font);
     spriteBatch.DrawString(Text, _font,
         new Vector2(Position.X - (dim.X/2) + (Size.Width/2), Position.Y - (dim.Y/2) + (Size.Height/2)),
         IsMouseHoverState ? Color.DarkOrange : Color.White);
 }
Esempio n. 3
0
 public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
 {
     if (AnimationComplete)
     {
         return;
     }
     spriteBatch.DrawString(Text, Font, Position, Color.FromArgb((int)currentAlpha, 255, 255, 255));
 }
Esempio n. 4
0
 /// <summary>
 /// Draws the Scene.
 /// </summary>
 /// <param name="spriteBatch">The spriteBatch.</param>
 /// <param name="gameTime">The GameTime.</param>
 public override void Draw(SpriteBatch spriteBatch, GameTime gameTime)
 {
     spriteBatch.DrawTexture(_background, _backgroundPosition);
     Vector2 dim =
         spriteBatch.MeasureString(
             string.Format("score: {0}", _finalScore), _font);
     Vector2 dim2 = spriteBatch.MeasureString("Press {Enter} to continue", _font2);
     Vector2 dim3 = spriteBatch.MeasureString(
         string.Format("(Achievement multiplier {0}x)", _achievmentMultiplier), _font3);
     spriteBatch.DrawString(
         string.Format("score: {0}", _finalScore), _font,
         new Vector2(400 - dim.X/2, 300), Color.White);
     spriteBatch.DrawString(string.Format("(Achievement multiplier {0}x)", _achievmentMultiplier), _font3,
         new Vector2(400 - dim3.X/2, 350), Color.White);
     spriteBatch.DrawString("Press {Enter} to continue", _font2, new Vector2(400 - dim2.X/2, 420), Color.White);
     _blackBlend.Draw(spriteBatch, gameTime);
 }
Esempio n. 5
0
        public override void OnDraw(SpriteBatch spriteBatch)
        {
            if (this.IsMouseHoverState)
            {
                this.Pen.Color = Color.Yellow;
            }
            else
            {
                this.Pen.Color = Color.White;
            }

            float x = (float)(this.Position.X + (double)(this.Size.Width / 2) - spriteBatch.MeasureString(this.Text, this.Font).X / 2.0);
            float y = (float)(this.Position.Y + (double)(this.Size.Height / 2) - spriteBatch.MeasureString(this.Text, this.Font).Y / 2.0);
            Vector2 center = new Vector2(x, y);

            spriteBatch.DrawRectangle(this.Pen, Sharpex2D.Common.Extensions.UIBoundsExtension.ToRectangle(this.Bounds));
            spriteBatch.DrawString(this.Text, this.Font, center, Color.White);
        }
Esempio n. 6
0
        public override void OnDraw(SpriteBatch spriteBatch)
        {
            //if (AnimationComplete)
            //    return;

            if (this.IsMouseHoverState)
            {
                this.Pen.Color = Color.FromArgb((int)currentAlpha, 255, 255, 0);
            }
            else
            {
                this.Pen.Color = Color.FromArgb((int)currentAlpha, 255, 255, 255);
            }

            float x = (float)(this.Position.X + (double)(this.Size.Width / 2) - spriteBatch.MeasureString(this.Text, this.Font).X / 2.0);
            float y = (float)(this.Position.Y + (double)(this.Size.Height / 2) - spriteBatch.MeasureString(this.Text, this.Font).Y / 2.0);
            Vector2 center = new Vector2(x, y);

            spriteBatch.DrawRectangle(this.Pen, Sharpex2D.Common.Extensions.UIBoundsExtension.ToRectangle(this.Bounds));
            spriteBatch.DrawString(this.Text, this.Font, center, Color.FromArgb((int)currentAlpha, 255, 255, 255));
        }
Esempio n. 7
0
        /// <summary>
        /// Zeichnen der Elemente
        /// </summary>
        /// <param name="spriteBatch"></param>
        /// <param name="gameTime"></param>
        public override void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            switch (SceneMode)
            {
                case SceneMode.FirstStart:
                    text = "Bereit?";
                    gameScene.Draw(spriteBatch, gameTime);
                    break;

                case SceneMode.Paused:
                    text = "Pausiert";
                    break;

                case SceneMode.WonLost:
                    break;

                case SceneMode.Scored:
                    text = "Bereit?";
                    gameScene.Draw(spriteBatch, gameTime);
                    break;

                default:
                    break;
            }
            font = new Font("Arial", 50, TypefaceStyle.Bold);
            position = new Vector2()
            {
                X = (graphicsDevice.BackBuffer.Width - spriteBatch.MeasureString(text, font).X) / 2,
                Y = 100
            };
            color = Color.White;
            spriteBatch.DrawString(text, font, position, color);
        }
Esempio n. 8
0
        /// <summary>
        /// Draws the DebugDisplay.
        /// </summary>
        /// <param name="spriteBatch">The spriteBatch.</param>
        /// <param name="gameTime">The GameTime.</param>
        public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            if (!Visible) return;

            foreach (Enemy enemy in _currentEntityComposer.Enemies)
            {
                spriteBatch.DrawRectangle(_pen, enemy.Bounds);
            }

            foreach (Projectile projectile in _currentEntityComposer.Projectiles)
            {
                spriteBatch.DrawRectangle(_pen2, projectile.Bounds);
            }

            spriteBatch.DrawRectangle(_pen3, _currentEntityComposer.Player.Bounds);

            spriteBatch.DrawString(_debugMessage, _font, _display, Color.White);
        }
Esempio n. 9
0
 /// <summary>
 /// Draws the score board.
 /// </summary>
 /// <param name="spriteBatch">The spriteBatch.</param>
 /// <param name="gameTime">The GameTime.</param>
 public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
 {
     spriteBatch.DrawString(string.Format("score: {0}", CurrentScore), _scoreFont, _scorePosition, Color.White);
     spriteBatch.DrawString(string.Format("health: {0}", CurrentHealth), _healthFont, _healthPosition, Color.White);
 }
Esempio n. 10
0
        /// <summary>
        /// Draws the DamageIndicator.
        /// </summary>
        /// <param name="spriteBatch">The spriteBatch.</param>
        /// <param name="gameTime">The GameTime.</param>
        public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            if (!IsVisible) return;

            spriteBatch.DrawString(string.Format("+ {0}", Score), _font, Position, Color);
        }