ポーズと終了 - Siv3D/Reference-JP GitHub Wiki

ポーズ画面(背景ぼかし)

# include <Siv3D.hpp>

void Main()
{
	Graphics::SetBackground(Palette::White);

	const Texture texture(L"Example/siv3d-kun.png");

	const Font font(36, Typeface::Light);

	Stopwatch stopwatch(true);

	DynamicTexture texturePause;

	while (System::Update())
	{
		if (stopwatch.isPaused())
		{
			if (ScreenCapture::HasNewFrame())
			{
				texturePause.fill(ScreenCapture::GetFrame().gaussianBlurred(16, 16));
			}

			if (Input::KeyP.clicked)
			{
				stopwatch.resume();
			}

			texturePause.draw(AlphaF(0.5));

			RoundRect(Rect(300, 200).setCenter(Window::Center()), 20).draw(ColorF(0.2, 0.6, 0.8, 0.8));

			font(L"PAUSE").drawCenter(Window::Center());
		}
		else
		{
			if (Input::KeyP.clicked)
			{
				ScreenCapture::Request();

				stopwatch.pause();
			}

			for (auto i : step(18))
			{
				const double radian = Radians(i * 20 + stopwatch.ms() / 100.0);

				Circle(Circular(200, radian) + Window::Center(), 10).draw(HSV(i * 20));
			}

			texture.drawAt(Window::Center());
		}
	}
}

Esc 長押しで終了

# include <Siv3D.hpp>

void Main()
{
	System::SetExitEvent(WindowEvent::CloseButton);

	const Font font(20);

	while (System::Update())
	{
		const int32 t = Input::KeyEscape.pressedDuration;

		if (t > 0)
		{
			font(L"Quitting", String(Min(t / 300, 3), L'.'))
				.draw(20, 20, AlphaF(Min(t / 300.0, 1.0)));

			if (t >= 1200)
			{
				System::Exit();
			}
		}
	}
}
⚠️ **GitHub.com Fallback** ⚠️