Reputation: 563
i'm making a simple game to show as final project. It will display a .bmp frame within the window and i have no intention of resizing the window while the game is running so i want to fix the window's size. The issue is that when i run the project created by choosing monogame game in visual studio 2012 it start in full screen mode. I tried to fix it with this code:
_graphics.IsFullScreen = false;
_graphics.PreferredBackBufferWidth = 640;
_graphics.PreferredBackBufferHeight = 480;
_graphics.Applychanges();
I've put it in the constructor of the main game class and in the initialize function but it does nothing. i'm using monogame 3.0.
Upvotes: 10
Views: 13691
Reputation: 777
Try putting it in the Initialize method instead of the constructor.
Should do the trick:
protected override void Initialize()
{
_graphics.IsFullScreen = false;
_graphics.PreferredBackBufferWidth = 640;
_graphics.PreferredBackBufferHeight = 480;
_graphics.ApplyChanges();
base.Initialize();
}
Upvotes: 6
Reputation: 11
The best way to resize the window is using the "GraphicsDeviceManager". Set up the graphics like that
private GraphicsDeviceManager _graphics;
then write your code into the initialize method (pay attention to capital letters):
protected override void Initialize()
{
_graphics.PreferredBackBufferWidth = 640;
_graphics.PreferredBackBufferHeight = 480;
_graphics.ApplyChanges();
base.Initialize();
}
Upvotes: 1