public override void Render(float deltaTime) { base.Render(deltaTime); _spriteBatch.Begin(Game.Camera.GetViewMatrix()); _bitmapFont.Draw(_spriteBatch, string.Format("Position: {0:0.0}, {1:0.0}", _position.X, _position.Y), 2, 2, Color.White); _bitmapFont.Draw(_spriteBatch, "This is\nMultiline text", 100, 100, Color.Red); _bitmapFont.Draw(_spriteBatch, "This text is wrapped to a fixed width of two hundred and fifty pixels.", 200, 300, 250, Color.Green); _spriteBatch.End(); }
public override void Render(float deltaTime) { base.Render(deltaTime); _tiledMap.Draw(Game.Camera); _spriteBatch.Begin(Game.Camera.GetViewMatrix()); for (int y = 0; y < _tiledMap.Height; y++) { for (int x = 0; x < _tiledMap.Width; x++) { var tileInfo = _tiledMap.GetTileAt(1, x, y); var text = tileInfo.Id.ToString(); var tx = (int)tileInfo.Centre.X; var ty = (int)tileInfo.Centre.Y; var rectangle = _font.MeasureText(text, tx, ty); var color = new Color(Color.Black, 0.5f); _font.Draw(_spriteBatch, text, tx - rectangle.Width / 2, ty - rectangle.Height / 2, color); } } _blob.Draw(_spriteBatch); _spriteBatch.End(); }
static void Postfix(LSItem __instance, ref bool __state, BitmapFont ____font, bool ____selected) { if (__state) { float xDraw = __instance.x + 10 + 10; ____font.Draw(GetName(____selected ? 0.5f : 0.7f), xDraw, __instance.y, Color.White, 0.8f); __instance._name = modItemName; }
public override void Render(float deltaTime) { GraphicsDevice.Clear(Color.CornflowerBlue); _spriteBatch.Begin(); _spriteBatch.Draw(_texture, _position, _color, new Vector2(0.5f, 0.5f), 0, Vector2.One); _bitmapFont.Draw(_spriteBatch, string.Format("Position: {0:0.0}, {1:0.0}", _position.X, _position.Y), 2, 2, Color.White); _spriteBatch.End(); }
private void DrawPlayerModel() { for (int i = 0; i < _playerModel.Lives; i++) { _font.Draw("/", new Vector2(i * 8, 30 * 8), Color.White); } _font.Draw("TIME", new Vector2(24 * 8, 31 * 8), Color.Yellow); }
public override void Draw(SpriteBatch spriteBatch) { base.Draw(spriteBatch); if (Text != null) { var rectangle = _font.MeasureText(Text, 0, 0); var x = GetHorizontalPosition((int)Position.X, rectangle.Width); var y = GetVerticalPosition((int)Position.Y, rectangle.Height); _font.Draw(spriteBatch, Text, x, y, TextColor); } }
public override void Draw(GdxSpriteBatch spriteBatch, float parentAlpha) { ISceneDrawable background; if (_list != null && _list.Parent != null && _style.BackgroundOpen != null) { background = _style.BackgroundOpen; } else if (IsDisabled && _style.BackgroundDisabled != null) { background = _style.BackgroundDisabled; } else if (_pointerIsOver && _style.BackgroundOver != null) { background = _style.BackgroundOver; } else { background = _style.Background; } BitmapFont font = _style.Font; Color fontColor = _style.FontColor; if (IsDisabled && _style.FontColorDisabled != null) { fontColor = _style.FontColorDisabled.Value; } float x = (int)X; float y = (int)Y; float width = Width; float height = Height; spriteBatch.Color = Color.MultiplyAlpha(parentAlpha); background.Draw(spriteBatch, x, y, width, height); if (_items.Length > 0) { float availableWidth = width - background.LeftWidth - background.RightWidth; int numGlyphs = font.ComputeVisibleGlyphs(_itemsText[SelectionIndex], 0, _itemsText[SelectionIndex].Length, availableWidth); _bounds = font.GetBounds(_itemsText[SelectionIndex]); height -= background.BottomHeight + background.TopHeight; float textY = (int)(height / 2 + background.BottomHeight + _bounds.Height / 2); font.Color = fontColor.MultiplyAlpha(parentAlpha); font.Draw(spriteBatch, _itemsText[SelectionIndex], x + background.LeftWidth, y + textY, 0, numGlyphs); } }
/// <summary> /// Draw the score. /// </summary> public override void Draw() { _font.Draw("1-UP", new Vector2(40, 0), Color.White); _font.Draw(_model.Score.ToString(), new Vector2(40, 8), Color.Red); _font.Draw("HI-SCORE", new Vector2(88, 0), Color.White); _font.Draw(_model.HiScore.ToString(), new Vector2(96, 8), Color.Red); for (int i = 0; i < _model.Lives; i++) { _font.Draw("/", new Vector2(i * 8, 30 * 8), Color.White); } _font.Draw("TIME", new Vector2(24 * 8, 31 * 8), Color.Yellow); }
public override void Draw(GdxSpriteBatch spriteBatch, float parentAlpha) { BitmapFont font = _style.Font; ISceneDrawable selectedDrawable = _style.Selection; Color fontColorSelected = _style.FontColorSelected; Color fontColorUnselected = _style.FontColorUnselected; spriteBatch.Color = Color.MultiplyAlpha(parentAlpha); float x = X; float y = Y; font.Color = fontColorUnselected.MultiplyAlpha(parentAlpha); float itemY = Height; for (int i = 0; i < _items.Length; i++) { if (_cullingArea.IsEmpty || (itemY - _itemHeight <= _cullingArea.Y + _cullingArea.Height && itemY >= _cullingArea.Y)) { if (_selectedIndex == i) { selectedDrawable.Draw(spriteBatch, x, y + itemY - _itemHeight, Width, ItemHeight); font.Color = fontColorSelected.MultiplyAlpha(parentAlpha); } font.Draw(spriteBatch, _itemsText[i], x + _textOffsetX, y + itemY - _textOffsetY); if (_selectedIndex == i) { font.Color = fontColorUnselected.MultiplyAlpha(parentAlpha); } } else if (itemY < _cullingArea.Y) { break; } itemY -= ItemHeight; } }
/// <summary> /// Draw the debug view. /// </summary> public override void Draw() { var msg = _model.Position.ToString().Replace("{", "(").Replace("}", ")"); _font.Draw(msg, new Vector2(4, 16), Color.Orange); }
public static void DrawText(this SpriteBatch spriteBatch, BitmapFont font, Vector2 position, string text, Color color) { font.Draw(spriteBatch, position, text, color); }
public override void Draw() { _font.Draw("GAME OVER!", new Vector2(100, 50), Color.Red); _font.Draw("PRESS SPACE TO PLAY AGAIN", new Vector2(100, 100), Color.White); }
public override void Draw(GdxSpriteBatch spriteBatch, float parentAlpha) { bool focused = IsKeyboardFocused; BitmapFont font = _style.Font; Color? fontColor = (IsDisabled) ? _style.DisabledFontColor ?? _style.FontColor : (focused) ? _style.FocusedFontColor ?? _style.FontColor : _style.FontColor; ISceneDrawable selection = _style.Selection; ISceneDrawable cursorPatch = _style.Cursor; ISceneDrawable background = (IsDisabled) ? _style.DisabledBackground ?? _style.Background : (focused) ? _style.FocusedBackground ?? _style.Background : _style.Background; float x = (int)X; float y = (int)Y; float width = Width; float height = Height; float textY = _textBounds.Height / 2 + font.Descent; spriteBatch.Color = Color.MultiplyAlpha(parentAlpha); float bgLeftWidth = 0; if (background != null) { background.Draw(spriteBatch, x, y, width, height); bgLeftWidth = background.LeftWidth; float bottom = background.BottomHeight; textY = (int)(textY + (height - background.TopHeight - bottom) / 2 + bottom); } else { textY = (int)(textY + height / 2); } CalculateOffsets(); if (focused && _hasSelection && selection != null) { selection.Draw(spriteBatch, x + _selectionX + bgLeftWidth + _renderOffset, y + textY - _textBounds.Height - font.Descent, _selectionWidth, _textBounds.Height + font.Descent / 2); } float yOffset = font.IsFlipped ? -_textBounds.Height : 0; if (_displayText.Length == 0) { if (!focused && MessageText != null) { if (_style.MessageFontColor != null) { font.Color = _style.MessageFontColor.Value.MultiplyAlpha(parentAlpha); } else { font.Color = new Color(.7f, .7f, .7f, parentAlpha); } BitmapFont messageFont = _style.MessageFont ?? font; messageFont.Draw(spriteBatch, MessageText, x + bgLeftWidth, y + textY + yOffset); } } else { font.Color = fontColor.Value.MultiplyAlpha(parentAlpha); font.Draw(spriteBatch, _displayText, x + bgLeftWidth + _textOffset, y + textY + yOffset, _visibleTextStart, _visibleTextEnd); } if (focused && !IsDisabled) { Blink(); if (_cursorOn && cursorPatch != null) { cursorPatch.Draw(spriteBatch, x + bgLeftWidth + _textOffset + _glyphPositions[_cursor] - _glyphPositions[_visibleTextStart] - 1, y + textY - _textBounds.Height - font.Descent, cursorPatch.MinWidth, _textBounds.Height + font.Descent / 2); } } }