1
0
Fork 0

Move fullscreen toggle from _process to _input

For whatever reason, the check being in _process prevented it from
working consistently.
This commit is contained in:
under 2024-03-20 13:07:30 -07:00
parent 65414609bc
commit 23f77441bc
1 changed files with 10 additions and 10 deletions

View File

@ -1,29 +1,29 @@
extends Node
# Called when the node enters the scene tree for the first time.
func _ready():
#InputMap.action_get_events()
var hotkey = ProjectSettings.get_setting("input/HotKey_ToggleFullscreen")
print(InputMap.action_get_events("character_forwards"))
print(InputMap.action_get_events("HotKey_ToggleFullscreen"))
#print(InputMap.action_get_events("character_forwards"))
#print(InputMap.action_get_events("HotKey_ToggleFullscreen"))
if hotkey == null:
print("PLEASE GO Project->Project Settings... , Input Map, and add HotKey_ToggleFullscreen")
InputMap.add_action("HotKey_ToggleFullscreen")
#InputMap.action_add_event()
print(hotkey)
#print(hotkey)
var temporarl_deadzone : float = 0
var temporal_deadzone : float = 0
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if temporal_deadzone > 0.0:
temporal_deadzone -= delta
func _input(event: InputEvent) -> void:
#Returns true when the user has started pressing the action event in the current frame or physics tick. It will only return true on the frame or tick that the user pressed down the button.
#This is useful for code that needs to run only once when an action is pressed, instead of every frame while it's pressed.
if Input.is_action_just_pressed("HotKey_ToggleFullscreen") and temporarl_deadzone <= 0.0:
if event.is_action_pressed("HotKey_ToggleFullscreen") and temporal_deadzone <= 0.0:
if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
else:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
temporarl_deadzone = 0.5
if temporarl_deadzone > 0.0:
temporarl_deadzone -= delta
temporal_deadzone = 0.5