當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。