summaryrefslogtreecommitdiff
path: root/demos/gui/input_mapping/controls.gd
diff options
context:
space:
mode:
Diffstat (limited to 'demos/gui/input_mapping/controls.gd')
-rw-r--r--demos/gui/input_mapping/controls.gd4
1 files changed, 4 insertions, 0 deletions
diff --git a/demos/gui/input_mapping/controls.gd b/demos/gui/input_mapping/controls.gd
index 6ca059c812..7420053ef1 100644
--- a/demos/gui/input_mapping/controls.gd
+++ b/demos/gui/input_mapping/controls.gd
@@ -11,10 +11,12 @@
extends Control
+# member variables
var player_actions = [ "move_up", "move_down", "move_left", "move_right", "jump" ]
var action # To register the action the UI is currently handling
var button # Button node corresponding to the above action
+
func wait_for_input(action_bind):
action = action_bind
# See note at the beginning of the script
@@ -22,6 +24,7 @@ func wait_for_input(action_bind):
get_node("contextual_help").set_text("Press a key to assign to the '" + action + "' action.")
set_process_input(true)
+
func _input(event):
# Handle the first pressed key
if (event.type == InputEvent.KEY):
@@ -39,6 +42,7 @@ func _input(event):
# Add the new key binding
InputMap.action_add_event(action, event)
+
func _ready():
# Initialise each button with the default key binding from InputMap
var input_event