You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Prior to Phaser ~3.60, using a delay value of 0 seemed to be a way to "allow this to run every frame." Post Phaser 3.60, there seems to be logic to make sure the callback gets called (on average) once every delay value. So the callback might get called multiple times per frame. This happens here in the Clock.js file. There is some logic in the TimerEvent reset function to check for delay of 0 and loop/repeats, but it doesn't check for repeat === -1. I think it may make more sense for the check to be in Clock.js, in the update loop - something like this:
// Very short delay
if (remainder >= event.delay && event.delay > 0)
{
while ((remainder >= event.delay) && (event.repeatCount > 0))
{
if (event.callback)
{
event.callback.apply(event.callbackScope, event.args);
}
remainder -= event.delay;
event.repeatCount--;
}
}
This allows you to have repeating frame based events just like you could in Phaser 3.55.2, while also protecting against delays that are 0 to prevent infinite loops. The check in TimerEvent.js could then be removed since it would be a valid config again.
The text was updated successfully, but these errors were encountered:
Hi @Stever1388. Thanks for submitting this issue. Thanks @samme for creating a PR to fix this issue. It has been merged with the master branch. It will be part of the next release. Do test it out and let us know if you encounter any issues.
Version
Description
Setting the delay property to 0 and the repeat property to -1 in an TimerEvent causes an infinite loop.
Example Test Code
Note - the following code will cause your browser tab to lock up.
Additional Information
Prior to Phaser ~3.60, using a delay value of 0 seemed to be a way to "allow this to run every frame." Post Phaser 3.60, there seems to be logic to make sure the callback gets called (on average) once every
delay
value. So the callback might get called multiple times per frame. This happens here in the Clock.js file. There is some logic in the TimerEventreset
function to check for delay of 0 and loop/repeats, but it doesn't check forrepeat === -1
. I think it may make more sense for the check to be inClock.js
, in theupdate
loop - something like this:This allows you to have repeating frame based events just like you could in Phaser 3.55.2, while also protecting against delays that are 0 to prevent infinite loops. The check in
TimerEvent.js
could then be removed since it would be a valid config again.The text was updated successfully, but these errors were encountered: