How do you create a cooldown | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How do you create a cooldown

Im making a game and I need help. Say you click a button that gives you gold, and you cant click it again for 1 minute. you call a function, but cant call it for 1 minute afterwards and the cooldown doesnt start unless you click the function... Thanks :)

1st Sep 2017, 2:21 AM
koala 🐨
koala 🐨 - avatar
3 Answers
+ 3
Here I created a button to run a function with timeout control, I set it to 5sec timeout, you can change to any time period you need. https://code.sololearn.com/WwGec9nx324a/?ref=app
1st Sep 2017, 2:35 AM
Calviղ
Calviղ - avatar
+ 1
Upon running the function, trigger a timer flag to control the cooldown.
1st Sep 2017, 2:26 AM
Calviղ
Calviղ - avatar
+ 1
@Calvin how
1st Sep 2017, 2:27 AM
koala 🐨
koala 🐨 - avatar