Simon game help

Simon game help
0.0 0

#1

So this problem really sucks for me because i barely even know how to explain my problem. I need to get the code that is executing (game function) to exit out if the start button is clicked a second time. That way it also serves as a restart button basically. I have thought of a few different ways to do this but im really stumped. Ive tried finding somewhere to put a .clearTimeout() but everything i tried didn’t work and also i don’t think it will work because there is multiple instances of this running at the same time from what i understand. The other thing i tried was adding a click event to call a return or break statement but the return statement only left the function it was nested in and the break statement was throwing an illegal break error. I dont want you guys to complete my code for me, just lead me down the right path. I put an alert in there for testing. I want to be able to click the start button twice or 3 or more times in a row and click one of the colored buttons and only get one alert. Thank you for any help, it is much appreciated.

Also if needed i can post the code here but i thought it would be easier to put up a link cause last time i tried to post code here i screwed up big time.


#2

Sorry, I don’t have time to get deep into your code, but once the game stats can’t you reassign the click handler for that button? Then I’d clear out the variables and recall keygen. That would be my approach.


#3

@bggillmore

You can use the following to detect the OnOff slider event.
In your code, you have the OnOff slider event only raised if the Start button has been clicked.
Let me know if this at least points you in the right direction.

  $("#onoff").on("click", function(){
    if($("#onoff").is(":checked")){
      alert("TRUE");
    }
    else{
      alert("FALSE");
    }    
  });