如何在XNA中调整窗口的大小.
默认以800x600分辨率开始.
从XNA 4.0开始,此属性现在可以在GraphicsDeviceManager
.IE浏览器.这段代码将放在你游戏的构造函数中.
graphics = new GraphicsDeviceManager(this);
graphics.IsFullScreen = false;
graphics.PreferredBackBufferHeight = 340;
graphics.PreferredBackBufferWidth = 480;
// if changing GraphicsDeviceManager properties outside
// your game constructor also call:
// graphics.ApplyChanges();
我发现你需要设置
GraphicDevice.PreferredBackBufferHeight = height;
GraphicDevice.PreferredBackBufferWidth = width;
当你在游戏类的构造函数中执行此操作时,它可以工作,但是当您尝试在构造函数外部执行此操作时,您还需要调用它
GraphicsDevice.ApplyChanges();
此外,您可以使用全屏(在调试时无法正常工作)
if (!GraphicsDevice.IsFullScreen)
GraphicsDevice.ToggleFullScreen();