setTimeout query

Hello everyone,

Is there a simple way to easily clear all setTimeouts? Rather than, upon destruction of the entity, clearing each timeout manually?

Because at the moment, if I have a timeout in my game, upon pressing the back button, all sort of issues are caused as a result, as the timeout method is called after the scene is destroyed and the next scene has loaded.

Thank you and kind regards,

Adam Burgess

you can use clearTimeOut()

const timeoutId = setTimeout(function(){
    console.log("Hola Mundo");
}, 2000);

console.log(`Tiempo de espera ID ${timeoutId} ha sido limpiado`);
1 Like