Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

InputEventAction

繼承: InputEvent < Resource < RefCounted < Object

動作的輸入事件型別。

說明

包含一個通用動作,該動作可以被多種型別的輸入作為目標。動作及其事件可以在項目 > 專案設定輸入對應分頁中設定,也可以使用 InputMap 類設置。

注意:與對應到唯一物理事件的其他 InputEvent 子類別不同,這個虛擬事件不是由引擎發出的。這個類可以用來使用 Input.parse_input_event() 手動發出動作,這樣就能夠在 Node._input() 中接收到這些動作。要檢查物理事件是否與“輸入對應”中的動作相配對,請使用 InputEvent.is_action()InputEvent.is_action_pressed()

教學

屬性

StringName

action

&""

int

event_index

-1

bool

pressed

false

float

strength

1.0


屬性說明

StringName action = &"" 🔗

The action's name. This is usually the name of an existing action in the InputMap which you want this custom event to match.


int event_index = -1 🔗

  • void set_event_index(value: int)

  • int get_event_index()

The real event index in action this event corresponds to (from events defined for this action in the InputMap). If -1, a unique ID will be used and actions pressed with this ID will need to be released with another InputEventAction.


bool pressed = false 🔗

  • void set_pressed(value: bool)

  • bool is_pressed()

true 時該動作處於被按下的狀態。為 false 時該動作處於被釋放狀態。


float strength = 1.0 🔗

  • void set_strength(value: float)

  • float get_strength()

動作的強度,介於 0 和 1 之間。當 pressed 為 false 時,該值被視為等於 0。通過將事件強度設定為手柄軸的彎曲或按壓強度,可以仿造模擬手柄的移動事件。