0
$\begingroup$

My 'FullScreen' script occurs an error.
Each time the object is clicked it activates the 'FullScreen' and then deactivates.

import bge
from bge import render

# Functions
def main():

    cont = bge.logic.getCurrentController()
    own = cont.owner

    # Action    
    if bge.render.getFullScreen() == False:
        bge.render.setFullScreen(True)
        return
    else:
        bge.render.setFullScreen(False)
        return

# Action        
main()
$\endgroup$
  • $\begingroup$ You are trying this in standalone player not in Blender-embedded player, correct? if you try in blender will not work. $\endgroup$ – Strapicarus Nov 8 '17 at 0:23
  • $\begingroup$ I'm clicking the Standard Player on Blender itself. When I run the game and click on the object it activates the full screen and then deactivates. $\endgroup$ – Júnior Nov 8 '17 at 0:25
  • $\begingroup$ Please include a image of your logic editor. $\endgroup$ – Strapicarus Nov 8 '17 at 4:37
  • $\begingroup$ While your snippet contains unnecessary and distracting code it is not the cause of that issue as it does what you mentioned it should do. You issue is the timing when to run this code. As Strapicarus asked you should provide the logic that shows when this code gets executed. What is the "object"? What is the "error"? What do you mean with "deactivates"? $\endgroup$ – Monster Nov 8 '17 at 6:12
0
$\begingroup$

I test it and yeah it enter 'FullScreen' and then deactivates.

I assume that you was using a always sensor wich will trigger twice combined with a mouse click sensor.

To make it work the logic:

enter image description here

The script:

from bge import logic, render

left_click = logic.getCurrentController().sensors['MouseLC']
mouse_over = logic.getCurrentController().sensors['MouseOver']

if mouse_over.hitObject and left_click.positive:
    if render.getFullScreen():
        render.setFullScreen(False)
    else:
        render.setFullScreen(True)

If you want bge in front all instuctions.

import bge

left_click = bge.logic.getCurrentController().sensors['MouseLC']
mouse_over = bge.logic.getCurrentController().sensors['MouseOver']

if mouse_over.hitObject and left_click.positive:
    if bge.render.getFullScreen():
        bge.render.setFullScreen(False)
    else:
        bge.render.setFullScreen(True)

if you dont want left_clikc and mouse_over

import bge

if bge.logic.getCurrentController().sensors['MouseOver'].hitObject and bge.logic.getCurrentController().sensors['MouseLC'].positive:
    if bge.render.getFullScreen():
        bge.render.setFullScreen(False)
    else:
        bge.render.setFullScreen(True)
$\endgroup$
  • $\begingroup$ Can you explain the importance of this command? left_click = logic.getCurrentController().sensors['MouseLC'] mouse_over = logic.getCurrentController().sensors['MouseOver'] $\endgroup$ – Júnior Nov 8 '17 at 15:13
  • $\begingroup$ logic.getCurrentController().sensors['MouseLC'] is the Left Button mouse sensor. Will trigger the script but you want to click an object so need an mouse over sensor to make sure that you are clicking an object. $\endgroup$ – Strapicarus Nov 8 '17 at 15:54
  • $\begingroup$ Why you need bge.render.getFullScreen() render.getFullScreen() is the same, $\endgroup$ – Strapicarus Nov 8 '17 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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