/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); fps += 1; spriteBatch.Begin(); for (int i = 0; i < fontNum; i++) { renderer.DrawString(spriteBatch, subText, fonts[i], new Vector2(0, i * 160), Color.White); } //renderer.DrawBuffer(spriteBatch); spriteBatch.End(); base.Draw(gameTime); }
internal void Render(float x, float y, float width, float height, SpriteFont font, TextAlignHorizontal align, Color textColor, Color hotKeyColor) { Vector2 fullSize = font.MeasureString(text1 + hotkeyText + text2); Vector2 size1 = font.MeasureString(text1); Vector2 size2 = font.MeasureString(hotkeyText); Vector2 position = new Vector2(0, y - 3); if (height > 0) { position.Y = y + ((float)height / 2.0f - fullSize.Y / 2.0f); } switch (align) { case TextAlignHorizontal.Center: position.X = x + ((float)width / 2.0f - fullSize.X / 2.0f); break; case TextAlignHorizontal.Left: position.X = x; break; case TextAlignHorizontal.Right: position.X = x + ((float)width - fullSize.X); break; } MainGame.SpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, RasterizerState.CullCounterClockwise); FontRenderer.DrawString(font, text1, position.X, position.Y, textColor); if (string.IsNullOrEmpty(hotkeyText) == false) { FontRenderer.DrawString(font, hotkeyText, (position.X + size1.X), position.Y, hotKeyColor); } if (string.IsNullOrEmpty(text2) == false) { FontRenderer.DrawString(font, text2, (position.X + size1.X + size2.X), position.Y, textColor); } MainGame.SpriteBatch.End(); }