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


C# SpriteBatch.DrawStringOutlined方法代码示例

本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.SpriteBatch.DrawStringOutlined方法的典型用法代码示例。如果您正苦于以下问题:C# SpriteBatch.DrawStringOutlined方法的具体用法?C# SpriteBatch.DrawStringOutlined怎么用?C# SpriteBatch.DrawStringOutlined使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Xna.Framework.Graphics.SpriteBatch的用法示例。


在下文中一共展示了SpriteBatch.DrawStringOutlined方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Draw

 public virtual void Draw(SpriteBatch spriteBatch, GameTime gameTime, Vector2 origin, float alpha)
 {
     Vector2 offset = new Vector2(36, 0);
     Vector2 imageOffset = new Vector2(0, 12);
     if (IsSelected) {
         if (Selected != null) spriteBatch.Draw(InputState.InputMethod == InputMethods.Gamepad ? GameSession.Current.ButtonImages[Buttons.A] : GameSession.Current.KeyImages["X"], new Rectangle((int)origin.X + (int)imageOffset.X, (int)origin.Y + (int)imageOffset.Y, 32, 32), Color.White);
         if (InputState.InputMethod == InputMethods.KeyboardMouse) { // TODO: Remove this once we get images for the gamepad left and right buttons
             if (SwipeLeft != null) spriteBatch.Draw(InputState.InputMethod == InputMethods.Gamepad ? GameSession.Current.ButtonImages[Buttons.DPadLeft] : GameSession.Current.KeyImages["Left"], new Rectangle((int)origin.X + (int)imageOffset.X, (int)origin.Y + (int)imageOffset.Y, 32, 32), Color.White);
             if (SwipeRight != null) spriteBatch.Draw(InputState.InputMethod == InputMethods.Gamepad ? GameSession.Current.ButtonImages[Buttons.DPadRight] : GameSession.Current.KeyImages["Right"], new Rectangle((int)origin.X + (Text2 == null ? (int)imageOffset.X + (int)offset.X + 4 + (int)GenericMenu.Font.MeasureString(Text).X : GenericMenu.EntriesWidth - (int)imageOffset.X - 32), (int)origin.Y + (int)imageOffset.Y, 32, 32), Color.White);
         }
     }
     spriteBatch.DrawStringOutlined(GenericMenu.Font, Text, origin + offset, Enabled ? (IsSelected ? Color.White : new Color(192, 192, 192)) : new Color(96, 96, 96) * alpha);
     if (Text2 != null) spriteBatch.DrawStringOutlined(GenericMenu.Font, Text2, origin - offset + new Vector2(GenericMenu.EntriesWidth - GenericMenu.Font.MeasureString(Text2).X, 0), Enabled ? (IsSelected ? Color.White : new Color(192, 192, 192)) : new Color(96, 96, 96) * alpha);
 }
开发者ID:adamrezich,项目名称:LootShop2012,代码行数:14,代码来源:GenericMenu.cs

示例2: Draw

        public void Draw(SpriteBatch spriteBatch, SpriteFont font, Vector2 position, TextAlign align, int? width, float alpha)
        {
            Vector2 offset = new Vector2(0, 0);
            //foreach (Word w in Words) {
            for (int i = 0; i <= (FullyTyped ? Words.Count - 1 : CurrentWordIndex); i++) {
                Word w = Words[i];
                switch (w.Type) {
                    case Word.WordType.Newline:
                        offset.X = 0;
                        offset.Y += font.LineSpacing;
                        break;
                    case Word.WordType.Text:
                        if (offset.X + font.MeasureString(w.Text + " ").X > width) {
                            offset.X = 0;
                            offset.Y += font.LineSpacing;
                        }
                        spriteBatch.DrawStringOutlined(font, w.Text + " ", position + offset, w.Color * alpha);
                        offset.X += font.MeasureString(w.Text + " ").X;
                        break;
                    case Word.WordType.Icon:
                        int iconHeight = (int)font.LineSpacing;

                        if (w.Icon == GameSession.Current.Pixel) {
                            spriteBatch.DrawStringOutlined(GameSession.Current.KeyboardFont, w.Text, position + offset, w.Color * alpha);
                            offset.X += GameSession.Current.KeyboardFont.MeasureString(w.Text).X + font.MeasureString(" ").X;
                        }
                        else {
                            int iconWidth = w.Icon.Width / w.Icon.Height * iconHeight;
                            if (offset.X + w.Icon.Width > width) {
                                offset.X = 0;
                                offset.Y += font.LineSpacing;
                            }
                            spriteBatch.Draw(w.Icon, new Rectangle((int)(position.X + offset.X), (int)(position.Y + offset.Y), iconWidth, iconHeight), Color.White * alpha);
                            offset.X += iconWidth + font.MeasureString(" ").X;
                        }
                        break;
                }
            }
        }
开发者ID:adamrezich,项目名称:LootShop2012,代码行数:39,代码来源:TextBlock.cs


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