当前位置: 首页>>代码示例>>C#>>正文


C# ISpriteBatch.DrawText方法代码示例

本文整理汇总了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);
        }
开发者ID:zakvdm,项目名称:Frenetic,代码行数:17,代码来源:BubbleTextDrawer.cs

示例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;
            }
        }
开发者ID:zakvdm,项目名称:Frenetic,代码行数:17,代码来源:ScoreHudView.cs


注:本文中的ISpriteBatch.DrawText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。