It's rare, but for power or processor concerns, some game applications may wish to suspend all game functionality until an event triggers fresh updates. To do this, we should call stop() on the RAF.
However, this logic doesn't work inside KiwiJS.
The reason: Kiwi logic is all evaluated during Game._loop(). This is executed during the RAF method RAFUpdate(). Later in RAFUpdate(), a new RAF is made, with a new _rafId value. The RAF method stop() will cancel the current RAF, but has no way of interrupting the creation of the new RAF.
When stop() is called from a non-KiwiJS logic path, such as the browser console, it is not evaluated during RAFUpdate(), so the current RAF is cancelled and a new RAF is not created.
I've added isRunning checks to the new RAF process. This way, stoppage will genuinely interrupt the flow. It is now possible to stop the RAF from the inside.
It's rare, but for power or processor concerns, some game applications may wish to suspend all game functionality until an event triggers fresh updates. To do this, we should call
stop()
on the RAF.However, this logic doesn't work inside KiwiJS.
The reason: Kiwi logic is all evaluated during
Game._loop()
. This is executed during the RAF methodRAFUpdate()
. Later inRAFUpdate()
, a new RAF is made, with a new_rafId
value. The RAF methodstop()
will cancel the current RAF, but has no way of interrupting the creation of the new RAF.When
stop()
is called from a non-KiwiJS logic path, such as the browser console, it is not evaluated duringRAFUpdate()
, so the current RAF is cancelled and a new RAF is not created.We should make
stop()
actually work.