DylanD Posted June 25, 2018 Share Posted June 25, 2018 (edited) Hello everyone, I was wondering if you could help me figure out a way to turn a button of for say 3 seconds that way if someone tried spamming(very quick repeated clicking) my button it would only hit one time/time them out. Here is my attempt, I use the boolean as a switch, when the button is hit it check if the switch is on if it is I does the button stuff then it turns the switch to false and then wait 300 ms then turns the switch back on, except in the example the switch doesn't turn back on for some reason and when I try to do this if I click fast enough I sometimes get and extra click or two, any ideas? So I had a variable in the wrong place in my code and it works now... but it still doesn't work in the playground so not sure why, so I guess solved? I don't know. Should work in the playground... Edited June 25, 2018 by DylanD It works? Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted June 25, 2018 Share Posted June 25, 2018 add a flag that turns 'off' the button and on your callback skip the buttons behavior if the flag is there. Then set a timeout that resets the flag after a set time so that the callback behavior turns back on. DylanD 1 Quote Link to comment Share on other sites More sharing options...
DylanD Posted June 25, 2018 Author Share Posted June 25, 2018 1 minute ago, Pryme8 said: add a flag that turns 'off' the button and on your callback skip the buttons behavior if the flag is there. Then set a timeout that resets the flag after a set time so that the callback behavior turns back on. this is what I have. at least I think, it doesn't work in the playground but does in my code ? Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted June 25, 2018 Share Posted June 25, 2018 https://playground.babylonjs.com/#FP9RYZ#2 Just some error in your scopes. Quote Link to comment Share on other sites More sharing options...
DylanD Posted June 25, 2018 Author Share Posted June 25, 2018 2 minutes ago, Pryme8 said: https://playground.babylonjs.com/#FP9RYZ#2 Just some error in your scopes. Ahhh ok, thanks Pryme8 ! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.