I want to change a boolean when I click the left mouse button, but it doesn't work as expected. I use this method:
if (m.LeftButton == ButtonState.Released && m_Old.LeftButton == ButtonState.Pressed)
{
if (second)
{
second = false; // Boolean changes
} else
{
second = true; // Boolean changes
}
}
I need a way to tell the code that I only want one change. When I click the left mousebutton, the second boolean changes constantly. The reason for this is that the code keeps executing until m_Old (the old mousestate) is updated. (m & m_Old must be different for this code to run)
An example (when I click the left mouse button once| these are the results for the second boolean):
My mouse update code:
// Mouse stuff
oldMouse = mouse;
mouse = Mouse.GetState();