Переглянути джерело

Merge pull request #4649 from Calinou/controllers-add-is-action-just-pressed

Mention `Input.is_action_just_pressed()` on the Controllers page
Nathan Lovato 4 роки тому
батько
коміт
65bdac51d7
1 змінених файлів з 9 додано та 0 видалено
  1. 9 0
      tutorials/inputs/controllers_gamepads_joysticks.rst

+ 9 - 0
tutorials/inputs/controllers_gamepads_joysticks.rst

@@ -121,6 +121,15 @@ use ``Input.is_action_pressed()``:
     // `jumping` will be a boolean with a value of `true` or `false`.
     bool jumping = Input.IsActionPressed("jump");
 
+.. note::
+
+    If you need to know whether an input was *just* pressed in the previous
+    frame, use ``Input.is_action_just_pressed()`` instead of
+    ``Input.is_action_pressed()``. Unlike ``Input.is_action_pressed()`` which
+    returns ``true`` as long as the input is
+    held,``Input.is_action_just_pressed()`` will only return ``true`` for one
+    frame after the button has been pressed.
+
 In Godot versions before 4.0, such as 3.2, ``Input.get_vector()`` and
 ``Input.get_axis()`` aren't available. Only ``Input.get_action_strength()``
 and ``Input.is_action_pressed()`` are available in Godot 3.2.