Animation is sketchy after scaling game

When I animate my object with a spritesheet texture after scaling the game from 1920 x 1080 to a 960 x 540 window, it doesn’t look right… Here’s what it looks like:

If you take a close look, you can see the messy stuff at the top animating(probably from the other frames?)

But here’s the thing, if I scale it up back to 1920x1080, it doesn’t do that. It’s perfect, here’s what THAT looks like:

Here’s my source code for the animation in the player class:

 public class Player
    Texture2D Texture;
    Vector2 Position;
    public int Rows { get; set; }
    public int Columns { get; set; }
    public int currentFrame = 0;
    float interval;
  public int Width
            return Texture.Width / Columns;
    public int Height
            return Texture.Height / Rows;
 public void Update(GameTime gameTime)
        if (interval < 0.1f)
            interval += timer;
        if (interval >= 0.1f)
            interval = 0f;
        if (currentFrame > 11)
            currentFrame = 0;

 public void Draw(SpriteBatch spriteBatch)
        int width = Texture.Width / Columns;
        int height = Texture.Height / Rows;
        int row = (int)((float)currentFrame / (float)Columns);
        int column = currentFrame % Columns;

        Rectangle sourceRectangle = new Rectangle(width * column, height * row, width, height);
        Rectangle destinationRectangle = new Rectangle((int)Position.X, (int)Position.Y, Width, Height);

       spriteBatch.Draw(Texture, destinationRectangle, sourceRectangle, color, 0f, Vector2.Zero, SpriteEffects.None, layer);

here’s the scaling stuff in the main Game1.cs class:
public class Game1 : Game
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;

Vector2 virtualScreen = new Vector2(1920, 1080);
Vector3 scaleFactor;
Matrix Scale;
    public Game1()
        graphics = new GraphicsDeviceManager(this);
        Content.RootDirectory = "Content";
        this.Window.Title = "VOID";
        graphics.PreferredBackBufferWidth = 960;
        graphics.PreferredBackBufferHeight = 540;
   protected override void Update(GameTime gameTime)
        float widthScale = GraphicsDevice.PresentationParameters.BackBufferWidth / virtualScreen.X;
        float heightScale = GraphicsDevice.PresentationParameters.BackBufferHeight / virtualScreen.Y;
        scaleFactor = new Vector3(widthScale, heightScale, 1);

        Scale = Matrix.CreateScale(scaleFactor);

 protected override void Draw(GameTime gameTime)

        spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, Scale);


Thanks for your help, I appreciate your time.

Well … have you set a breakpoint for your source rectangle? Check what’s different (something with the y coordinate) and step back and find out why.

I am fairly optimistic that there’s no monogame error in here, but let’s find out together ok?

Okay so I just figured out what triggers it.

  k = keyboard.GetState();
  fa += (float)gameTime.ElapsedGameTime.TotalSeconds; //fa is a float starting at 0f.

  if (k.IsKeyUp(Keys.Up) && k.IsKeyUp(Keys.Down) && k.IsKeyUp(Keys.Left) && k.IsKeyUp(Keys.Right))
            Position.Y = (int)(Math.Cos(fa) * 2) + Position.Y; //Code that makes the ghosts swoosh up and down slowly

It triggers under THESE circumstances:

  • The ghost is swooshing up and down
  • The game is scaled to 960x540

When I scale back up to 1920x1080 it still works just fine without the messiness. Although this has occurred before without the Position.Y being played with.

Not sure how to fix it though.

This same issue happens with me. What I did was increase the y-axis from the source rectangle by 1 pixel on the problematic frames of the animations, but this solution only worked on specific window scales (what was sufficient to me), but the problem still happens on the background. I guess the problem is on the draw instead of the sprite position, because even casting it to integer the issue happens.

The problem is with filtering. This is not an issue with MonoGame. KonajuGames’ comments in this topic explain the issue. You can try passing SamplerState.PointClamp in your spritebatch.Begin() call since you have a pixelated look anyway. The alternative is to add padding in the spritesheet.