本文整理汇总了C#中ISpriteBatch.DrawString方法的典型用法代码示例。如果您正苦于以下问题:C# ISpriteBatch.DrawString方法的具体用法?C# ISpriteBatch.DrawString怎么用?C# ISpriteBatch.DrawString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISpriteBatch
的用法示例。
在下文中一共展示了ISpriteBatch.DrawString方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public virtual void Draw(ISpriteBatch spriteBatch)
{
string scoreString = DisplayScore.ToString();
Vector2 measure = Font.MeasureString(scoreString);
Vector2 origin = new Vector2(measure.X, measure.Y * 0.5f);
spriteBatch.DrawString(Font, scoreString, ScorePosition.WorldPosition, Color.White, WorldRotation, origin, WorldScale, SpriteEffects.None, 0);
}
示例2: Draw
/// <summary>
/// Draws the <see cref="StyledText"/> to the <paramref name="spriteBatch"/>.
/// </summary>
/// <param name="spriteBatch"><see cref="ISpriteBatch"/> to draw the <see cref="StyledText"/> to.</param>
/// <param name="font"><see cref="Font"/> to use for drawing the characters.</param>
/// <param name="position">Top-left corner of where to begin drawing the <see cref="StyledText"/>.</param>
/// <param name="defaultColor">The default color to use for drawing the text. Only used if the
/// <see cref="Color"/> is equal to <see cref="ColorForDefault"/>.</param>
public void Draw(ISpriteBatch spriteBatch, Font font, Vector2 position, Color defaultColor)
{
var colorToUse = (Color == ColorForDefault ? defaultColor : Color);
spriteBatch.DrawString(font, Text, position, colorToUse);
}
示例3: DrawText
/// <summary>
/// Draws the text for the control.
/// </summary>
/// <param name="spriteBatch"><see cref="ISpriteBatch"/> to draw to.</param>
/// <param name="position">Position relative to the Control to draw the text.</param>
protected virtual void DrawText(ISpriteBatch spriteBatch, Vector2 position)
{
// Ensure the font is valid
if (string.IsNullOrEmpty(Text) || Font == null || Font.IsDisposed)
return;
// Draw the text
spriteBatch.DrawString(Font, Text, ScreenPosition + position, ForeColor);
}
示例4: Render
public void Render(ISpriteBatch spriteBatch, V2 cameraPosition)
{
spriteBatch.Begin();
for (int i = 0; i < positionedWorldCells.Length; i++)
{
if (positionedWorldCells[i] == null)
continue;
for (int j = 0; j < positionedWorldCells[i].Count; j++)
{
var cell = positionedWorldCells[i][j];
if (cell.Tile == null)
continue;
spriteBatch.Draw(cell.Tile.Texture,
new Rect(0, 0, TileWidth, TileHeight),
new Rect((int)cell.Position.X, (int)cell.Position.Y, TileWidth, TileHeight),
0f,
baseDepth - ((i * 100) + j) * HeightRowDepthMod);
spriteBatch.DrawString(SysCore.SystemFont, cell.Position.X + ", " + cell.Position.Y, new V2(cell.Position.X, cell.Position.Y), new V4(255), 0f, 1f, 1f);
}
}
spriteBatch.End();
}
示例5: Draw
/// <summary>
/// Draws the InfoBox.
/// </summary>
/// <param name="sb"><see cref="ISpriteBatch"/> to draw with.</param>
public void Draw(ISpriteBatch sb)
{
ThreadAsserts.IsMainThread();
// Remove dead items
while (_items.Count > 0 && _items[0].CreatedTime + _messageLife < TickCount.Now)
{
_items.RemoveAt(0);
}
// Loop through all items
var i = 0;
foreach (var item in _items)
{
// Set the position
var pos = _position;
pos.Y -= _font.GetLineSpacing() * (i++ + 1);
pos.X -= item.Width;
// Set the color
var lifeLeft = (item.CreatedTime + _messageLife) - TickCount.Now;
var alpha = (byte)Math.Min(255, lifeLeft);
var color = new Color(item.Color.R, item.Color.G, item.Color.B, alpha);
// Draw
sb.DrawString(_font, item.Message, pos, color);
}
}
示例6: DrawName
private void DrawName(ISpriteBatch spriteBatch)
{
Vector2 measure = Font.MeasureString(Score.Name);
Vector2 origin = new Vector2(0, measure.Y * 0.5f);
spriteBatch.DrawString(Font, Score.Name, NamePosition.WorldPosition, Color.White, WorldRotation, origin, WorldScale, SpriteEffects.None, 0);
}
示例7: DoRender
protected override void DoRender(
Moment now,
GraphicsDevice graphicsDevice,
ISpriteBatch spriteBatch,
TextureContent content,
HolofunkView view,
Transform parentTransform,
int depth)
{
Transform combinedTransform = parentTransform.CombineWith(LocalTransform);
spriteBatch.Begin();
Vector2 textSize = content.SpriteFont.MeasureString(m_text);
Vector2 origin = Vector2.Zero;
if (Alignment == Alignment.Centered) {
origin = textSize / 2;
}
else if (Alignment == Alignment.TopRight) {
origin = new Vector2(textSize.X, 0);
}
spriteBatch.DrawString(
content.SpriteFont,
m_text,
combinedTransform.Translation,
Color,
Rotation,
origin,
combinedTransform.Scale.X,
SpriteEffects.None,
0);
spriteBatch.End();
}
示例8: DrawControlText
/// <summary>
/// Draws the text to display for the <see cref="TextBox"/>.
/// </summary>
/// <param name="spriteBatch">The <see cref="ISpriteBatch"/> to draw to.</param>
/// <param name="offset">The offset to draw the text at.</param>
protected override void DrawControlText(ISpriteBatch spriteBatch, Vector2 offset)
{
var numChars = NumCharsToDraw - LineCharBufferOffset;
if (numChars > 0)
spriteBatch.DrawString(Font, new string(MaskChar, numChars), offset, ForeColor);
}
示例9: Draw
/// <summary>
/// Draws the <see cref="DamageText"/>.
/// </summary>
/// <param name="sb"><see cref="ISpriteBatch"/> to draw to.</param>
/// <param name="font"><see cref="Font"/> to draw with.</param>
public void Draw(ISpriteBatch sb, Font font)
{
sb.DrawString(font, _text, _pos, new Color(255, 255, 255, (byte)_alpha));
}
示例10: Draw
public override void Draw(ISpriteBatch spriteBatch, GameTime gameTime)
{
spriteBatch.DrawString(_font, "Score: " + score, new Vector2(100, 100), Color.Black);
}
示例11: Draw
public void Draw(ISpriteBatch batch)
{
if (needsUpdate)
Update();
batch.DrawString(font, Text, position, Color.Black, 0, Vector2.Zero, scale, SpriteEffects.None, 0);
}