Increasing number once per mouse click/key press in XNA

Posted by DMan on Stack Overflow See other posts from Stack Overflow or by DMan
Published on 2010-03-07T03:51:29Z Indexed on 2010/04/02 22:13 UTC
Read the original article Hit count: 317

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about XNA

Related posts about c#