Make when you press a key like p go to full screen?

Ok so Im trying to make it so when you press a key such as p that the window goes to fullscreen automatically I tried it but the script isnt working.

var RenderAi = pc.createScript('renderAi');

//Im adding the fullscreen mode//
RenderAi.prototype.intalize = function() {
    //will have key//
if(this.app.keyboard.isPressed(pc.KEY_P)) {
    this.app.keyboard.isPressed(pc.KEY_P,this.screen.fullscreen);
}

    
    };


Fullscreen meaning the page takes up the whole screen?

Yes obviously

There’s already a built in option for that. Press the F11 key or press FN + F11.

No I want it to be custom for matrexball by pressing p I want it to go to fullscreen

Somethings wrong with the Fullscreen code it keeps saying this and idk what to tweak at I dont want to mess up anything or make it worse

I’ll check it out later. I got an online class rn.

online class I thought you went to that tech school?

I got an online class for a different language

Nice lol but nvm I fixed it It was the returnFullscreen code that I made haha

k

Im in so much stress and I wanna do so much with matrexball also so how we gonna fixed the score system? unless you have a copy of the old script

lol nvm again I fixed the scoresystem ez

Does anyone know how I could have a full screen option for mobile? And make it automatic?

On works on Android I’m afraid. iOS doesn’t support fullscreen.

Set this property to true: https://developer.playcanvas.com/en/api/pc.GraphicsDevice.html#fullscreen

this.app.graphicsDevice.fullscreen = true

I recommend not making it automatic (I’m not 100% that you can) as it’s a bad user experience. At least do it when the user presses a button to start the game.

1 Like

Thanks, Yaustar! I will try to put this to the test :slight_smile: