i am developing a mobile game using XNA and have an on and off switch which changes the state whenever tapped on. My problem is that it changes rapidly and multiple times from a single tap. How do i stop this?
Store a time the in-game switch was last used and calculate the timespan passed
if(buttonPressed && (Datetime.Now - timeLastInGameSwitchActivated).Milliseconds > 1000)
{
ToggleIngameSwitch();
timeLastInGameSwitchActivated = Datetime.Now;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With