Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i set a fixed window size in monogame?

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.

like image 321
Mario Gil Avatar asked Nov 23 '13 00:11

Mario Gil


1 Answers

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();
}
like image 101
daglundberg Avatar answered Oct 09 '22 21:10

daglundberg