summaryrefslogtreecommitdiff
path: root/demos/gui/input_mapping
diff options
context:
space:
mode:
Diffstat (limited to 'demos/gui/input_mapping')
-rw-r--r--demos/gui/input_mapping/controls.gd9
-rw-r--r--demos/gui/input_mapping/controls.scnbin2686 -> 2698 bytes
2 files changed, 7 insertions, 2 deletions
diff --git a/demos/gui/input_mapping/controls.gd b/demos/gui/input_mapping/controls.gd
index 6ca059c812..3cee6e6871 100644
--- a/demos/gui/input_mapping/controls.gd
+++ b/demos/gui/input_mapping/controls.gd
@@ -1,3 +1,6 @@
+
+extends Control
+
# Note for the reader:
#
# This demo conveniently uses the same names for actions and for the container nodes
@@ -9,12 +12,12 @@
# action and the node, e.g.:
# button.connect("pressed", self, "wait_for_input", [ button, action ])
-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 +25,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 +43,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
diff --git a/demos/gui/input_mapping/controls.scn b/demos/gui/input_mapping/controls.scn
index 276712ba22..98cbbca464 100644
--- a/demos/gui/input_mapping/controls.scn
+++ b/demos/gui/input_mapping/controls.scn
Binary files differ