Timer configuration startAt not working.

Hi.

I’m using a simple timer like this:

        this.time.addEvent({
            delay: 5000,
            startAt: 0,
            loop: true,
            callback: () => {
                clog("main callback fired");
            }
        });

The timer does not start right away. It honors only the delay params. From the docs the startAt are the ms before the first callback fire. But it’s not gonna happen.

Anyone found the same problem?

:waving_hand:

The timer starts running right away, but it doesn’t fire until the first delay elapses.

Use startAt: 5000 to skip the first delay interval.

1 Like

thanks. I solved understanding the real meaning of the docs, but I couldn’t believe the startAt was dependent from the loop delay time.

So the startAt is the time already considered as elapsed inside the timer, so, nearer to delay time is the better to make it start sooner. I’ll try to remember this trick. :sweat_smile: