[Solved] Phaser 3 Request fullscreen, not working

Hi everyone

Currently i still don’t get a solution to make fullscreen working.

Mostly I use a fullscreen library (screenfull.js) that i used on my previous games (createjs), and this library are not working with phaser 3, so, i try using default request fullscreen fuction, but still not working.

Is there any built-in fullscreen function for Phaser 3 ?

As the error indicates, you need to do the request from inside user gesture callback. Phaser doesn’t have that handled very well, but it does provide you with addUpCallback.

How to implement this with a sprite on click/pointerdown?

Something like:

button.on('pointerdown', function() {
    this.input.addUpCallback(function() {
        //user-gesture handling here (open links, request fullscreen, ...)
    }, true);
}, this);

It’s not perfect though, given how Phaser works, it could miss the up callback if the user is fast enough (and/or fps too low). Then the action will happen on the next up callback, which works but could be weird for the user.
But it shouldn’t happen much, only if the user releases the button faster than the next frame is rendered, which is usually between 7-40ms, which is very fast compared to speed of clicking.

1 Like

Thanks! it’s working! my fullscreen button are working now.