jeudi 26 décembre 2019

How to clear an interval in an if statement

So, I'm working on a game called Mini Arcade which features a bunch of different minigames. I found a way to create a fade effect after I click a button to go to another page. The fade effect seems to work properly, but after going to the console of the page, the fade interval doesn't clear like it's supposed to when the opacity variable hits 0, which makes the opacity of the object go into the negatives. This is a problem because once I begin making buttons that fade back to the homepage, the homepage will still be fading out, while fading in at the same time, which is a big problem.

if(opacity == 0){
clearInterval(fadeOut);
}

As you can tell, it's just a simple if statement within my fade out function. Sorry if I didn't explain this well, but I could really use some help. Thanks.

Aucun commentaire:

Enregistrer un commentaire