Hello Monogame community,
I wanted to add a way to completely freeze my game to make debugging easier, but when I stop drawing the screen, the display keeps alternating between two frames.
Is there some constraints to what we can do with the Draw function?
Also, I think I should still call the base.Update and base.Draw even if the game is freezed, what do you think?
Update
//Freezing the screen on F12 input
KeyboardState keyboardState = Keyboard.GetState();
if (keyboardState.IsKeyDown(Keys.F12))
{
if (!freezeToggled)
{
freezed = !freezed;
freezeToggled = true;
}
}
else
freezeToggled = false;
if (!freezed)
{
//Just making the texture move
X += Vx;
if (X > 800 - 256) { Vx = -8; }
if (X < 0) { Vx = 8; }
}
base.Update(gameTime);
Draw
if (!freezed)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin(samplerState: SamplerState.PointClamp);
spriteBatch.Draw(Grass, new Rectangle(X, 0, 256, 256), Color.White);
spriteBatch.End();
}
base.Draw(gameTime);