Saturday, August 10, 2019

c# - Issue with Monogame resizing


I've converted my XNA project into a MonoGame one.


Whenever I start the application and resize the game manually (ie - dragging the window)...


this.Window.AllowUserResizing = true;

...the game scales in a weird manner.


Namely instead of scaling as it should do, it scales to the point where it looks fuzzy and the mouse clicks aren't working correctly.


The main game map has a hard coded "component size" which means that when the screen gets larger, its supposed to show more of the game - but instead I'm getting poorly scaled components.



Part of my code looks as follows:


const int TILEWIDTH = 50;
const int TILEHEIGHT = 50;
//......
Rectangle rec = new Rectangle(0, 0, TILEWIDTH, TILEHEIGHT);
spriteBatch.Draw(this.game.Content.Load(tileGraphic.path), rec, Color.White);

So theoretically the pixels are becoming larger. This was working correctly in XNA.


I am in no way handling or overriding the resize command, it was 'just working'.


I found some threads with similar problems, but no solution. Anything I could do ?




Answer



Fixing the issue was easier than expected


public override void Update(GameTime gameTime)
{
graphics.ApplyChanges();
}

It doesn't seem to impact framerate in any way (still getting 120)


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...