3
$\begingroup$

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?

$\endgroup$
1
  • $\begingroup$ Would it be acceptable to just have the cam move into a closer position that would make it appear that the menu was fullscreen? $\endgroup$
    – ruckus
    Commented Dec 18, 2014 at 16:03

2 Answers 2

2
$\begingroup$

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.
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.)

$\endgroup$
1
  • 1
    $\begingroup$ 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 $\endgroup$ Commented Dec 19, 2014 at 5:41
2
$\begingroup$

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)
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .