WarTornLands.Infrastructure.ResolutionIndependence.MagicSprite.MagicSprite C# (CSharp) Method

MagicSprite() public method

Initializes a new instance of the MagicSprite class. It is possible to pass null for either relWidth or relHeight. In this case the respective other value is calculated in respect to the sprites aspect ratio to ensure a non-warped presentation.
Sprite dimensions not specified. Called in case both width and height are passed as null.
public MagicSprite ( SpriteBatch sb, Microsoft.Xna.Framework.Graphics.Texture2D sprite, Vector2 relPosition, float relWidth, float relHeight, float Xpan, float Ypan ) : System
sb Microsoft.Xna.Framework.Graphics.SpriteBatch The SpriteBatch used to draw the sprite.
sprite Microsoft.Xna.Framework.Graphics.Texture2D The sprite texture.
relPosition Vector2 The relative position.
relWidth float The relative width.
relHeight float The relative height.
Xpan float The pan in X-direction.
Ypan float The pan in Y-direction.
return System
        public MagicSprite(SpriteBatch sb, Texture2D sprite, Vector2 relPosition, float? relWidth, float? relHeight, float Xpan = 0, float Ypan = 0)
        {
            if (relWidth == null && relHeight == null)
                throw new Exception("Sprite dimensions not specified.");

            _sb = sb;
            _sprite = sprite;
            _relPosition = relPosition;
            _relWidth = relWidth;
            _relHeight = relHeight;
            _panning = new Vector2(Xpan, Ypan);
            _grahpics = Game1.Instance.GraphicsDevice;

            GetDrawingRec();
        }