如何在Monogame中全屏启动?

11

我正在使用Monogame和C#开发游戏。我有一个用于菜单的WPF应用程序,它以全屏模式启动。当我在菜单上点击播放按钮时,我进入了Monogame项目。如何像WPF菜单一样在全屏模式下启动Monogame解决方案?

3个回答

11

您可以将IsFullscreen属性设置为true

//you likely already have this line (or similar)
graphics = new GraphicsDeviceManager(this);

//set the GraphicsDeviceManager's fullscreen property
graphics.IsFullScreen = true;

1
keyboardP 是正确的。如果这不起作用,请在 MonoGame 问题页面 上输入错误报告。 - Tom Spilman
2
切换全屏模式的方法是设置isFullScreen标志,然后调用graphics.ApplyChanges()函数。 - Esa
1
Monogame 显然存在一个已知问题,即全屏模式尚未正常工作。在 XNA 中设置 IsFullScreen 可以正常工作,但在 Monogame 中立即被设置为 false。已知的解决方法似乎是使用无边框全屏窗口,我仍在努力让它正常工作。据说这取决于使用的 Windows 版本。 - Nightmare Games

4
这是使用Monogame的正确方式。
GraphicsDeviceManager graphics;
graphics = new GraphicsDeviceManager(this);
graphics.ToggleFullScreen();

1

有两种方法可以使应用程序全屏。一种是通过设置 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();

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接