vendredi 7 août 2020

Number counts up before using an if statement to pause?

I want the number to stop when the variable "num" reaches a whole number. The pausing works correctly, but it goes up by 0.01 then pauses. The statement is ran every frame (via requestAnimationFrame)

if (Math.floor(num * 100) / 100 == Math.floor(num) && pause < 50) {
        pause += 1;
    } else {
        pause = 0;
        num += 0.01;
}

Aucun commentaire:

Enregistrer un commentaire