# How to make a fullscreen toggle button in the BGE?

I am making an options menu in the BGE and I want to know how to make a button that toggles fullscreen on and off for the blender game?

• Would it be acceptable to just have the cam move into a closer position that would make it appear that the menu was fullscreen? – Scalia Dec 18 '14 at 16:03

This is simply done with a small python script using the bge.render.setFullScreen() function.

cont = bge.logic.getCurrentController()

if cont.sensors['MouseOver'].hitObject.name == 'Cube' and cont.sensors['Lclick'].getButtonStatus(bge.events.LEFTMOUSE) == bge.logic.KX_INPUT_JUST_ACTIVATED:
if bge.render.getFullScreen() == True:
bge.render.setFullScreen(False)
else:
bge.render.setFullScreen(True)


You then add the script to your button with these logic bricks.

The MouseOver and Lclick mouse sensors are used to start the script when the button is clicked.
Look through the Blend file for a full working example.
(*Note* you will need to start the Standalone player for full screen to work.)

• Thank you this worked i just needed to rename some of my stuff to make it work i had a plane named Fullscreen so i changed the part of the script that said cube to Fullscreen and as for my sensers i just renamed them to what you already had in the script which was Lclick and MouseOver – sketcherskt Dec 19 '14 at 5:41

In order to do exactly that and not quickly toggle back to windowed, with a keyboard sensor named keyboard:

from bge import render
def fullScreenMode(cont):
if cont.sensors["keyboard"].getKeyStatus(events.F11KEY) == logic.KX_INPUT_ACTIVE:
if render.getFullScreen() == False:
render.setFullScreen(True)
else:
render.setFullScreen(False)