예제 #1
0
 void CompleteCurrentSprite()
 {
     if (current != null)
     {
         GraphicsDevice.DrawSprite(current);
         current = null;
     }
 }
예제 #2
0
        public void LineTo(Vector2 position, Color color, float width)
        {
            int encodedWidth = LineSprite.EncodeWidth(width);

            if (current == null || current.Color != color || current.EncodedWidth != encodedWidth)
            {
                StartNewSprite(color, encodedWidth);
                current.Add(lastPosition);
            }

            current.Add(position);
            lastPosition = position;
        }
예제 #3
0
        void StartNewSprite(Color color, int encodedWidth)
        {
            if (current != null)
            {
                CompleteCurrentSprite();
            }

            // Where to get sprite from
            int i;
            List <LineSprite> list;

            if (hasTransform)
            {
                i    = transformedBufferPosition;
                list = transformedBuffer;
            }
            else
            {
                i    = untransformedBufferPosition;
                list = untransformedBuffer;
            }

            // Get sprite or create it
            if (i == list.Count)
            {
                current = new LineSprite(hasTransform);
                list.Add(current);
                GraphicsDevice.AddSprite(current);
            }
            else
            {
                current = list[i];
            }

            // Set the style, transform
            // And advance the position in the list of lines
            current.SetStyle(color, encodedWidth);
            if (hasTransform)
            {
                current.SetTransform(ref transform);
                transformedBufferPosition++;
            }
            else
            {
                untransformedBufferPosition++;
            }

            // Remove old data from the sprite
            current.Clear();
        }