RenderingLibrary.Graphics.SpriteRenderer.Draw C# (CSharp) Method

Draw() private method

private Draw ( Microsoft.Xna.Framework.Graphics.Texture2D textureToUse, Rectangle destinationRectangle, Rectangle sourceRectangle, Color color, float rotation, Vector2 vector2, SpriteEffects effects, int layerDepth, object objectRequestingChange ) : void
textureToUse Microsoft.Xna.Framework.Graphics.Texture2D
destinationRectangle Microsoft.Xna.Framework.Rectangle
sourceRectangle Microsoft.Xna.Framework.Rectangle
color Color
rotation float
vector2 Vector2
effects SpriteEffects
layerDepth int
objectRequestingChange object
return void
        internal void Draw(Texture2D textureToUse, Rectangle destinationRectangle, Rectangle? sourceRectangle, Color color, float rotation, Vector2 vector2, SpriteEffects effects, int layerDepth, object objectRequestingChange)
        {
            mSpriteBatch.Draw(textureToUse, destinationRectangle, sourceRectangle, color, rotation, vector2, effects, layerDepth, objectRequestingChange);
        }

Same methods

SpriteRenderer::Draw ( Microsoft.Xna.Framework.Graphics.Texture2D texture2D, Rectangle destinationRectangle, Rectangle sourceRectangle, Color color, object objectRequestingChange ) : void
SpriteRenderer::Draw ( Microsoft.Xna.Framework.Graphics.Texture2D textureToUse, Vector2 position, Rectangle sourceRectangle, Color color, float rotation, Vector2 vector22, Vector2 scale, SpriteEffects effects, float depth, object objectRequestingChange ) : void

Usage Example

        public void DrawTextLines(IEnumerable <string> lines, HorizontalAlignment horizontalAlignment, object objectRequestingChange, int requiredWidth, List <int> widths, SpriteRenderer spriteRenderer,
                                  Color color,
                                  float xOffset = 0, float yOffset = 0, float rotation = 0, float scaleX = 1, float scaleY = 1)
        {
            Point point = new Point();

            int lineNumber = 0;

            int xOffsetAsInt = MathFunctions.RoundToInt(xOffset);
            int yOffsetAsInt = MathFunctions.RoundToInt(yOffset);

            if (Renderer.NormalBlendState == BlendState.AlphaBlend)
            {
                // this is premultiplied, so premulitply the color value
                float multiple = color.A / 255.0f;

                color.R = (byte)(color.R * multiple);
                color.G = (byte)(color.G * multiple);
                color.B = (byte)(color.B * multiple);
            }

            foreach (string line in lines)
            {
                // scoot over to leave room for the outline
                point.X = mOutlineThickness;

                if (horizontalAlignment == HorizontalAlignment.Right)
                {
                    point.X = requiredWidth - widths[lineNumber];
                }
                else if (horizontalAlignment == HorizontalAlignment.Center)
                {
                    point.X = (requiredWidth - widths[lineNumber]) / 2;
                }

                foreach (char c in line)
                {
                    Rectangle destRect;
                    int       pageIndex;
                    var       sourceRect = GetCharacterRect(c, lineNumber, ref point, out destRect, out pageIndex, scaleX);



                    // todo: rotation, because that will impact destination rectangle too
                    if (Text.TextRenderingPositionMode == TextRenderingPositionMode.FreeFloating)
                    {
                        spriteRenderer.Draw(mTextures[pageIndex], new Vector2(destRect.X + xOffset, destRect.Y + yOffset), sourceRect, color, 0, Vector2.Zero, Vector2.One, SpriteEffects.None, 0, this);
                    }
                    else
                    {
                        // position:
                        destRect.X += xOffsetAsInt;
                        destRect.Y += yOffsetAsInt;
                        spriteRenderer.Draw(mTextures[pageIndex], destRect, sourceRect, color, this);
                    }
                }
                point.X = 0;
                lineNumber++;
            }
        }
All Usage Examples Of RenderingLibrary.Graphics.SpriteRenderer::Draw