I’m working on a prototype, and for debug tools, I want to have q activate and deactivate fullscreen
However, even though it works turning fullscreen ON, it’s unable to turn it off again. Pressing q with fullscreen activated will just disable it for a moment, then re-enable it instantly after
Is there a fix to this?
1 frame of a 60 fps game is 16 ms. It is very unlikely you are fast enough to stop pressing Q in less than 16 ms.
Because of this, you are constantly activating that event, so it is rapidly detecting full screen and non full screen. To avoid endless loops, it does nothing.
You need to use a toggle variable: How to toggle states using Variables [GDevelop wiki]
Besides what Silver-Streak suggested, you could also just assign two different keys for fullscreen and for escaping from fullscreen. That’s what a lot of games actually do (I know you want to use that for debugging and not for the actual game).
Along with what @Drona said, you can also use a boolean variable and toggle that instead. Something like this:
If q key is pressed:
Toggle the fullscreen variable
If fullscreen is True, Trigger Once:
Activate fullscreen: Yes
If fullscreen is False, Trigger Once:
Activate fullscreen: No
You have 2 issues at play here :
- you have no trigger once on the q key pressed condition.
- your logic is flawed - you set fullscreen to off in the first subevent. But then in the next subevent you check if it’s not fullscreen (which it won’t be because of the first subevent) and set it back to fullscreen.
Thank you all, there are great suggestions. I got it to work now
Thanks for the help