1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-31 18:41:20 +00:00

Updated tutorial_input_events (markdown)

reduz
2014-11-02 19:05:30 -08:00
parent 613e11e752
commit 42565d3d28

@@ -27,7 +27,7 @@ Example of changing event type.
```python
# create event
var ev = InputEvent.new()
var ev = InputEvent()
# set type index
ev.type=InputEvent.MOUSE_BUTTON
# button_index is only available for the above type
@@ -49,10 +49,28 @@ There are several types of InputEvent, described in the table below:
|[InputEventAction](class_inputeventaction)|SCREEN_ACTION|Contains a generic action. These events are often generated by the programmer as feedback. (more on this below)|
### Actions
An InputEvent may or may not represent a pre-defined action. Actions are useful because they abstract the input device when programming the game logic. This allows for:
* The same code to work on different devices with different inputs (ie: keyboard on PC, Joypad on console)
* Input to be reconfigured at run-time.
Actions can be created from the Project Settings menu in the Actions tab. If you read the [2D Game Tutorial](tutorial_2d), there is an explanation on how does the action editor work.
Any event has the methods [InputEvent.is_action()](class_inputevent#is_action), [InputEvent.is_pressed()](class_inputevent#is_pressed) amd [InputEvent.is_echo()](class_inputevent#is_echo).
Alternatively, it may be desired to supply the game back with an action from the game code (a good example of this is detecting gestures). SceneTree (derived from MainLoop) has a method for this: [MainLoop.input_event(ev)](class_mainloop#input_event). You would normally use it like this:
```python
var ev = InputEvent()
ev.type=InputEvent.ACTION
#set as move_left, pressed
ev.set_as_action("move_left",true)
#feedback
get_tree().input_event(ev)
```
### InputMap
-explain input event
-explain input editor
-explain as actions
-explain InputMap and how to map to user-events.