this is my code that decreases the percentage countdown more quickly every 10 seconds. I wanted to make a button that when clicked will trigger the function cure(), which stop the decreasing process, not permanently but until the first function is triggered again after another 10 seconds. This is what I have tried to do, but it seems not working
var disease = true;
var onDisease = setTimeout(function(){
setInterval( function(){
disease = true;
if (Math.random()> 0.1 && disease){
//gives it 90% of decreasing the percentage faster every
0.5 second ( 3%/sec rather than the normal 1%/sec)
countdown.extendTimer(-3)
console.log("im dying")}
}, 500)}, 10000);
function cure(){
disease = false;
clearTimeout(onDisease);
console.log("cure")
}
Aucun commentaire:
Enregistrer un commentaire