本文整理汇总了C#中ISpriteBatch.DrawText方法的典型用法代码示例。如果您正苦于以下问题:C# ISpriteBatch.DrawText方法的具体用法?C# ISpriteBatch.DrawText怎么用?C# ISpriteBatch.DrawText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISpriteBatch
的用法示例。
在下文中一共展示了ISpriteBatch.DrawText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawText
public void DrawText(ISpriteBatch spriteBatch, float elapsedSeconds)
{
foreach (var bubbleText in this.BubbleTexts)
{
float transitionOffset = 1 - (bubbleText.TimeRemaining / bubbleText.TotalTime);
// Modulate size:
float scale = MathHelper.SmoothStep(0f, 1f, transitionOffset) + 0.5f;
// Modulate alpha:
var color = new Color(bubbleText.Color.R, bubbleText.Color.G, bubbleText.Color.B, MathHelper.SmoothStep(1f, 0f, transitionOffset));
spriteBatch.DrawText(this.Font, bubbleText.Text, bubbleText.Position, color, scale);
bubbleText.TimeRemaining -= elapsedSeconds;
}
this.BubbleTexts.RemoveAll((bubbleTxt) => bubbleTxt.TimeRemaining < 0);
}
示例2: Draw
public void Draw(ISpriteBatch spritebatch)
{
Vector2 currentTextPosition = new Vector2(this.Window.Left + OverlaySetView.TEXT_OFFSET.X, this.Window.Top + OverlaySetView.TEXT_OFFSET.Y);
spritebatch.DrawText(_font, ScoreOverlayView.PLAYER, currentTextPosition, HEADING_COLOR, 1);
spritebatch.DrawText(_font, ScoreOverlayView.SCORE, currentTextPosition + SCORE_OFFSET, HEADING_COLOR, 1);
spritebatch.DrawText(_font, ScoreOverlayView.DEATHS, currentTextPosition + DEATHS_OFFSET, HEADING_COLOR, 1);
currentTextPosition.Y += _font.LineSpacing;
foreach (IPlayer player in _playerList.Players.OrderByDescending((p) => p.PlayerScore))
{
string name = player.PlayerSettings.Name;
spritebatch.DrawText(_font, name.Substring(0, name.Length > MAX_NAME_LENGTH ? MAX_NAME_LENGTH : name.Length), currentTextPosition, VALUES_COLOR, 1);
spritebatch.DrawText(_font, player.PlayerScore.Kills.ToString(), currentTextPosition + SCORE_OFFSET, VALUES_COLOR, 1);
spritebatch.DrawText(_font, player.PlayerScore.Deaths.ToString(), currentTextPosition + DEATHS_OFFSET, VALUES_COLOR, 1);
currentTextPosition.Y += _font.LineSpacing;
}
}