Increasing number once per mouse click/key press in XNA
- by DMan
This has been bothering me lately- when I use some code like below to increase selection every mouse click:
if (m.LeftButton == ButtonState.Pressed)
currentSelection++;
Then currentSelection increases by a ton, simply because this code is in my Update() function and by design, runs every frame and so increases currentSelection. There is almost no chance you can click and release fast enough to prevent currentSelection from increasing more than one.
Now my question is what I should do to make it so everytime I click the mouse down once, it only increases currentSelection once until the next time I click down again.