Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do i create a delay between tap gestures in XNA on wp7

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?

like image 259
user1865560 Avatar asked Dec 02 '25 15:12

user1865560


1 Answers

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;
}
like image 148
Kaido Avatar answered Dec 04 '25 07:12

Kaido



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!