Is there anyway limit fps without forceSetTimeOut=True

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()
        }
    }
}

The 3.60 (will be part of beta 10, not yet out) supports fps: { limit: 30 }, which should behave the way you want.

1 Like

thx!