/// <summary> /// Screen graphic drawing function. /// </summary> protected override void OnDraw(SpriteBatch batch) { base.OnDraw(batch); batch.Start(true); // batch.Draw(this.texture, Vector2.Zero, Color.White * (down ? 1.0f : 0.5f)); batch.Draw(this.font.Texture, Vector2.Zero, Color.White); batch.DrawFont(this.font, new Vector2(-40, -20), "abcdefghijklmnopqrstuvxyz"); batch.DrawFont(this.font, new Vector2(-40, -30), "ABCDEFGHIJKLMNOPQRSTUVXYZ"); batch.End(); }
/// <summary> /// Called when drawing the HUD component. /// </summary> /// <param name="batch">The sprite batch instance.</param> /// <param name="position"></param> protected override void OnDraw(SpriteBatch batch, Vector2 position) { if (this.Visible) { batch.DrawFont(this.font.Content, position, this.Alignment, this.Color, this.Text); } }
/// <summary> /// Screen graphic drawing function. /// </summary> protected override void OnDraw(SpriteBatch batch) { if (font != null) { batch.Begin(); batch.DrawFont(font, Vector2.Zero, "The quick brown fox jumps over the lazy dog"); font.Color = Color.Blue; batch.DrawFont(font, new Vector2(0, font.FontHeight + 10), "À noite, vovô Kowalsky vê o ímã cair no pé do pinguim queixoso e vovó põe açúcar\n no chá de tâmaras do jabuti feliz"); font.Color = Color.OrangeRed; batch.DrawFont(font, new Vector2(0, font.FontHeight * 3 + 10), "The\nquick\nbrown\nfox\njumps\nover\nthe\nlazy\ndog"); font.Color = Color.White; batch.DrawFont(font, new Vector2(300, font.FontHeight * 3 + 10), FontAlignment.Right, "The\nquick\nbrown\nfox\njumps\nover\nthe\nlazy\ndog"); batch.DrawFont(font, new Vector2(600, font.FontHeight * 3 + 10), FontAlignment.Center, "The\nquick\nbrown\nfox\njumps\nover\nthe\nlazy\ndog"); batch.End(); } }
/// <summary> /// Draws the scene. /// </summary> protected override void OnDraw(SpriteBatch batch) { var resources = AlmiranteEngine.Resources; var settings = AlmiranteEngine.Settings; batch.Start(); batch.Draw(this.black, new Rectangle(0, 0, settings.Resolution.BaseWidth, settings.Resolution.BaseHeight), Color.White); batch.DrawFont(resources.DefaultFont, this.pos, FontAlignment.Left, Color.White, string.Format("Loading resources... {0}", resources.PendingResources)); batch.End(); }
/// <summary> /// Called when drawing the HUD component. /// </summary> /// <param name="batch">The sprite batch instance.</param> /// <param name="position"></param> protected override void OnDraw(SpriteBatch batch, Vector2 position) { var resources = AlmiranteEngine.Resources; var textSize = resources.DefaultFont.MeasureString(this.Text); batch.Draw(this.texture, new Rectangle((int)position.X, (int)position.Y, (int)this.Size.X, (int)this.Size.Y), this.color); var textPosition = position + ((this.Size / 2) - (textSize / 2)); batch.DrawFont(resources.DefaultFont, textPosition, FontAlignment.Left, Color.White, this.Text); }
/// <summary> /// Called when drawing the HUD component. /// </summary> /// <param name="batch">The sprite batch instance.</param> /// <param name="position"></param> protected override void OnDraw(SpriteBatch batch, Vector2 position) { if (this.Visible) { // Background batch.Draw(this.texture, new Rectangle((int)position.X, (int)position.Y, (int)this.Size.X, (int)this.Size.Y), this.color); // Borders batch.DrawLine(position, position + new Vector2(this.Size.X, 0), Color.Black); // topl -> topr batch.DrawLine(position + new Vector2(this.Size.X, 0), position + new Vector2(this.Size.X, this.Size.Y), Color.Black); // topr -> botr batch.DrawLine(position + new Vector2(this.Size.X, this.Size.Y), position + new Vector2(0, this.Size.Y), Color.Black); // botr -> botl batch.DrawLine(position + new Vector2(0, this.Size.Y), position, Color.Black); // botl -> topl // Font var size = this.font.Content.MeasureString(this.Text); batch.DrawFont(this.font.Content, position + (this.Size / 2) - new Vector2(0, size.Y / 2), FontAlignment.Center, Color.White, this.Text); } }
/// <summary> /// Screen graphic drawing function. /// </summary> protected override void OnDraw(SpriteBatch batch) { base.OnDraw(batch); batch.Start(true); var background = AlmiranteEngine.Resources.DefaultBackground; batch.Draw(background, Vector2.Zero - new Vector2(background.Width / 2, background.Height / 2), Color.White); this.entities.Draw(); batch.End(); string text = "FPS: {0}\n" + "Camera Position: {1}\n" + "Camera Rotation: {3}\n" + "Camera Zoom: {2}\n"; var font = AlmiranteEngine.Resources.DefaultFont; batch.Start(); batch.Draw(this.texture, new Rectangle(20, 20, 400, 120), Color.White); batch.DrawFont(font, new Vector2(25, 25), Color.White, text, AlmiranteEngine.Time.Fps.ToString(), AlmiranteEngine.Camera.Position, AlmiranteEngine.Camera.Zoom, AlmiranteEngine.Camera.Rotation); batch.End(); }
/// <summary> /// Screen graphic drawing function. /// </summary> protected override void OnDraw(SpriteBatch batch) { var input = AlmiranteEngine.Input; var resources = AlmiranteEngine.Resources; batch.Start(); batch.Draw(resources.DefaultBackground, new Vector2(0, 0), Color.White); batch.DrawFont(resources.DefaultFont, new Vector2(50, 50), FontAlignment.Left, Color.DarkMagenta, string.Format("Mouse: {0}, {1}", input.Mouse.Position.X, input.Mouse.Position.Y)); batch.End(); }
/// <summary> /// Screen graphic drawing function. /// </summary> protected override void OnDraw(SpriteBatch batch) { var input = AlmiranteEngine.Input; var resources = AlmiranteEngine.Resources; var background = resources.DefaultBackground; batch.Start(true); batch.Draw(background, Vector2.Zero - new Vector2(background.Width / 2, background.Height / 2), Color.White); batch.Draw(dot.Content, Vector2.Zero - new Vector2(dot.Content.Width / 2, dot.Content.Height / 2), Color.White); batch.End(); batch.Start(); batch.DrawFont(resources.DefaultFont, new Vector2(25, 25), FontAlignment.Left, Color.White, this.strings.ToString()); batch.DrawFont(resources.DefaultFont, new Vector2(250, 25), FontAlignment.Left, Color.White, string.Format("Mouse wheel: {0}", input.Mouse.ScrollValue)); batch.DrawFont(resources.DefaultFont, new Vector2(250, 50), FontAlignment.Left, Color.White, string.Format("Mouse position: {0}", input.Mouse.Position)); batch.DrawFont(resources.DefaultFont, new Vector2(250, 75), FontAlignment.Left, Color.White, string.Format("Mouse world position: {0}", input.Mouse.WorldPosition)); batch.End(); }
/// <summary> /// Called when [draw]. /// </summary> /// <param name="batch">The batch.</param> /// <param name="position">The position.</param> protected override void OnDraw(SpriteBatch batch, Vector2 position) { var size = resources.DefaultFont.MeasureString(this.strings.ToString()); size += new Vector2(20, 20); if (size.Y < this.Size.Y) { size.Y = this.Size.Y; } if (size.X < this.Size.X) { size.X = this.Size.X; } if (this.Active) { batch.Draw(this.texture, new Rectangle((int)position.X, (int)position.Y, (int)size.X, (int)size.Y), Color.Blue); } else { batch.Draw(this.texture, new Rectangle((int)position.X, (int)position.Y, (int)size.X, (int)size.Y), Color.White); } batch.DrawFont(resources.DefaultFont, position + new Vector2(10, 10), this.strings.ToString()); }
/// <summary> /// OnDraw text on scene /// </summary> /// <param name="batch">The batch.</param> /// <param name="font">The font.</param> /// <param name="position">Position to begin drawing</param> /// <param name="alignment">The alignment.</param> /// <param name="input">A formated string</param> /// <param name="args">Optional parameters for the formated string</param> public static void DrawFont(this SpriteBatch batch, BitmapFont font, Vector2 position, FontAlignment alignment, string input, params object[] args) { batch.DrawFont(font, position, alignment, font.Color, String.Format(CultureInfo.CurrentCulture, input, args)); }
/// <summary> /// OnDraw text on scene using default orientation (Left) /// </summary> /// <param name="batch">The batch.</param> /// <param name="font">The font.</param> /// <param name="position">Position to begin drawing</param> /// <param name="color">The color.</param> /// <param name="input">A formated string</param> /// <param name="args">Optional parameters for the formated string</param> public static void DrawFont(this SpriteBatch batch, BitmapFont font, Vector2 position, Color color, string input, params object[] args) { batch.DrawFont(font, position, FontAlignment.Left, color, input, args); }