Пример #1
0
        private void DrawStringEx(XnaFont font, IEnumerable <char> text, Vector2 location, Color color, Vector2 origin, float layerDepth)
        {
            if (font == null || text == null)
            {
                return;
            }

            float dx = location.X, dy = location.Y;

            foreach (char c in text)
            {
                if (c == '\r')
                {
                    continue;
                }
                else if (c == '\n') //换行符
                {
                    dy += font.Height;
                    dx  = location.X;
                    continue;
                }
                else
                {
                    Rectangle rect = font.TryGetRect(c);
                    base.Draw(font.TextureBuffer, new Vector2(dx, dy), rect, color, 0f, origin, 1f, SpriteEffects.None, layerDepth);
                    dx += rect.Width;
                }
            }
            location.X = dx;
            location.Y = dy;
        }
Пример #2
0
        public void DrawStringEx(XnaFont xnaFont, StringBuilder stringBuilder, int startIndex, int length, Vector2 location, Color color, Vector2 origin)
        {
            IEnumerable <char> e = TextUtils.CreateCharEnumerator(stringBuilder, startIndex, length);

            DrawStringEx(xnaFont, e, location, Vector2.Zero, color, origin, 0);
        }
Пример #3
0
 public void DrawStringEx(XnaFont xnaFont, StringBuilder stringBuilder, int startIndex, int length, Vector2 location, Color color)
 {
     DrawStringEx(xnaFont, stringBuilder, startIndex, length, location, color, Vector2.Zero);
 }
Пример #4
0
 public void DrawStringEx(XnaFont xnaFont, StringBuilder stringBuilder, Vector2 location, Color color, Vector2 origin)
 {
     DrawStringEx(xnaFont, stringBuilder, 0, stringBuilder == null ? 0 : stringBuilder.Length, location, color, origin);
 }
Пример #5
0
        private void DrawStringEx(XnaFont xnaFont, string text, int startIndex, int length, Vector2 location, Vector2 size, Color color)
        {
            IEnumerable <char> e = TextUtils.CreateCharEnumerator(text, startIndex, length);

            DrawStringEx(xnaFont, e, location, size, color, Vector2.Zero, 0);
        }
Пример #6
0
 public void DrawStringEx(XnaFont xnaFont, string text, Vector2 location, Vector2 size, Color color)
 {
     DrawStringEx(xnaFont, text, 0, text == null ? 0 : text.Length, location, size, color);
 }
Пример #7
0
 public void DrawStringEx(XnaFont xnaFont, string text, Vector2 location, Color color, Vector2 origin)
 {
     DrawStringEx(xnaFont, text, 0, text == null ? 0 : text.Length, location, color, origin);
 }