我正在使用Monogame和C#开发游戏。我有一个用于菜单的WPF应用程序,它以全屏模式启动。当我在菜单上点击播放按钮时,我进入了Monogame项目。如何像WPF菜单一样在全屏模式下启动Monogame解决方案?
您可以将IsFullscreen
属性设置为true
。
//you likely already have this line (or similar)
graphics = new GraphicsDeviceManager(this);
//set the GraphicsDeviceManager's fullscreen property
graphics.IsFullScreen = true;
GraphicsDeviceManager graphics;
graphics = new GraphicsDeviceManager(this);
graphics.ToggleFullScreen();
有两种方法可以使应用程序全屏。一种是通过设置 IsFullScreen
属性,另一种是通过调用 ToggleFullScreen
方法。
请注意,根据 文档, 如果在初始化期间更改属性,则会自动设置全屏模式。但是当在初始化之外更改属性时,您需要调用 ApplyChanges
方法。
// probably already defined
graphics = new GraphicsDeviceManager(this);
// ...
graphics.IsFullScreen = true;
// don't forget to call ApplyChanges, if you are not in the Initialize method
graphics.ApplyChanges();
// probably already defined
graphics = new GraphicsDeviceManager(this);
// ...
graphics.ToggleFullScreen();