SFML C# 如何在全屏之间切换?

SFML C# How do I switch between fullscreen?

我想在全屏和窗口模式之间切换。有什么方法可以在不重新启动整个游戏的情况下做到这一点吗?

我建议在您的 window 上调用创建方法(C++,但我确信它在 C# 中也适用):

yourWindow->create(sf::VideoMode::getDesktopMode(), "Title", sf::Style::Fullscreen);

在 C# 下,您无法像 C 一样访问 ->create。您必须关闭旧的 RenderWindows 并创建一个新的。

if (Keyboard.IsKeyPressed(Keyboard.Key.Enter) && Keyboard.IsKeyPressed(Keyboard.Key.LAlt) && !auxChangeStyle)
{
  auxStyle = (auxStyle == Styles.Default)? Styles.Fullscreen: Styles.Default;
  window.Close();
  window = new RenderWindow(new VideoMode(800, 600), "Title", auxStyle);
  window.Closed += (_, __) => window.Close(); //reassign the event handlers 
}