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$
  • $\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$ – Scalia Dec 18 '14 at 16:03
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
    $\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$ – sketcherskt Dec 19 '14 at 5:41
1
$\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$

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.