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
Issue:
At run time, from a system, I'm calling engine.stop() but the timer doesn't stop.
Expected behavior:
The timer and subsequently all the systems should stop.
Digging into this problem I found that this.loopId in stop() and this.loopId in loop() were exactly one apart, ie. 2047 in stop and 2048 in loop.
There's some issue with the callback passed into requestAnimationFrame. It seems to preserve the state from one iteration before, and thus, even though we set loopId to null in stop, the previous state is executed on the next call of 'loop' and loopId is reset at the end of the function.
You can see this by setting breakpoints in stop and loop and watching the loopId.
Remedy:
I added a flag called this.stopOnNextFrame. Code below:
Thanks for submitting this bug.. I'll try reproduce this over the weekend.. In the mean time, if you haven't already done do, you can replace the default timer with your own implementation:
<GameEngine /* Other props */ timer={new CustomTimer()} />
I have an unrelated question, and I'm sorry if I should be asking this somewhere else, but using the timer code you have written is there a way to manually set how often it fires? I'm having an issue with a game I've written where it works as intended on most devices, but on my iPad or a phone with a 120 hz screen everything on screen moves twice as fast.
Issue:
At run time, from a system, I'm calling
engine.stop()
but the timer doesn't stop.Expected behavior:
The timer and subsequently all the systems should stop.
Digging into this problem I found that
this.loopId
instop()
andthis.loopId
inloop()
were exactly one apart, ie. 2047 instop
and 2048 inloop
.There's some issue with the callback passed into
requestAnimationFrame
. It seems to preserve the state from one iteration before, and thus, even though we set loopId to null in stop, the previous state is executed on the next call of 'loop' and loopId is reset at the end of the function.You can see this by setting breakpoints in stop and loop and watching the loopId.
Remedy:
I added a flag called
this.stopOnNextFrame
. Code below:The text was updated successfully, but these errors were encountered: