[Solved] Sprite is offset incorrectly after window resize.

I’ve been messing about with Monogame.Extended and have found a problem - in the demo for Sprites, after a window resize the spikey ball sprite is incorrectly offset from the mouse. At position 0,0 it is fine, but as you move the mouse cursor to the right or bottom of the client window, the sprite becomes more and more offset from the cursor.

EDIT: Never mind. After messing some more, I found out that

  1. This is a monogame behavior, not just limited to .Extended.

  2. After a window resize, the following code fixes the problem

    graphics.PreferredBackBufferWidth = Window.ClientBounds.Width;
    graphics.PreferredBackBufferHeight = Window.ClientBounds.Height;
    graphics.ApplyChanges();

Whoops. Simple. :slightly_smiling: This post can be deleted.

1 Like

Glad you got it working.

No need to delete the post. It might be helpful to someone else one day. Thanks for updating it with the solution :smile: