if i wanna limit fps to 30. i can only set forceSetTimeOut=True。But it’s not good as using requestAnimationFrame and count elapsed.
Is there anyway in phaser to perform like the code below?
let fps = 30
let fpsInterval = 1000 / fps
let fpsLast
let transport = undefined
function setFps() {
fpsLast = new Date().getTime()
}
function setScreen() {
canvas.width = ctxWidth;
canvas.height = ctxHeight;
}
function render() {
frameId = window.requestAnimationFrame(render)
let now = new Date().getTime()
let elapsed = now - fpsLast;
if (elapsed > fpsInterval) {
fpsLast = now - (elapsed % fpsInterval);
if(gameRunning){
main()
}
}
}