Example #1
0
        public override void DrawFrame(SpriteBatch spriteBatch, int index, Vector2 position, float scale, float angle,
                                       XYBool flip, Depth layerDepth, Color tintColor, bool isCentered = true)
        {
            Debug.Assert(index >= 0 && index <= this.frameCount, "Index out of range");

            var sourceRect = GetSourceRectForFrame(index);

            var adjustedFrameSize = this.frameSize.ToVector2() * scale;
            var destRect          = new Rectangle(position.ToPoint(), adjustedFrameSize.ToPoint());

            var offset = Vector2.Zero;

            if (isCentered)
            {
                offset = this.frameSize.ToVector2() / 2;
            }

            spriteBatch.Draw(this.texture, destRect, sourceRect, tintColor, angle, offset,
                             (flip.x ? SpriteEffects.FlipHorizontally : SpriteEffects.None) |
                             (flip.y ? SpriteEffects.FlipVertically : SpriteEffects.None), layerDepth.AsFloat);

            if (this.DebugMe)
            {
                spriteBatch.Draw(this.texture, new Vector2(0, 0), Color.White);
                spriteBatch.DrawRectangle(new Rectangle(0, 0, this.texture.Width, this.texture.Height), Color.Red);
                spriteBatch.DrawRectangle(sourceRect, Color.White);
            }
        }
Example #2
0
 public void Draw(SpriteBatch spriteBatch, Vector2 position, float scale, float angle, XYBool flip, Depth depth, Color color, bool isCentered = true)
 {
     this.spriteSheet.DrawFrame(spriteBatch, this.frame, position, scale, angle, flip, depth, color, isCentered);
 }
Example #3
0
 public void DrawFrame(SpriteBatch spriteBatch, int index, Transform transform, float scale = 1f,
                       XYBool flip = default)
 {
     DrawFrame(spriteBatch, index, transform.Position, scale, transform.Angle, flip, transform.Depth,
               Color.White);
 }
Example #4
0
 public abstract void DrawFrame(SpriteBatch spriteBatch, int index, Vector2 position, float scale, float angle,
                                XYBool flip, Depth layerDepth, Color tintColor, bool isCentered = true);
Example #5
0
 public void Draw(SpriteBatch spriteBatch, Vector2 position, float scale, float angle, XYBool flip,
                  Depth layerDepth, Color color)
 {
     this.spriteSheet.DrawFrame(spriteBatch, this.frame, position, scale, angle, flip, layerDepth, color);
 }