InputEvent
Inherits: Resource < Reference < Object
Inherited By: InputEventAction, InputEventJoypadButton, InputEventJoypadMotion, InputEventMIDI, InputEventScreenDrag, InputEventScreenTouch, InputEventWithModifiers
通用输入事件。
描述
各种输入事件的基类。请参阅 Node._input。
教程
属性
|
方法
accumulate ( InputEvent with_event ) | |
as_text ( ) const | |
get_action_strength ( String action, bool exact_match=false ) const | |
is_action_pressed ( String action, bool allow_echo=false, bool exact_match=false ) const | |
is_action_released ( String action, bool exact_match=false ) const | |
is_action_type ( ) const | |
is_echo ( ) const | |
is_pressed ( ) const | |
shortcut_match ( InputEvent event, bool exact_match=true ) const | |
xformed_by ( Transform2D xform, Vector2 local_ofs=Vector2( 0, 0 ) ) const |
属性说明
- int device
Default |
|
Setter | set_device(value) |
Getter | get_device() |
该事件的设备 ID。
注意:对于来自触摸屏的模拟鼠标输入,该设备 ID 将总是 -1
。可用于区分模拟鼠标输入和物理鼠标输入。
方法说明
- bool accumulate ( InputEvent with_event )
如果给定的输入事件和这个输入事件可以相加,则返回 true
(只针对 InputEventMouseMotion 类型的事件)。
给定输入事件的位置、全局位置和速度将被复制。产生的 relative
是两个事件的总和。两个事件的修饰符必须是相同的。
- String as_text ( ) const
返回事件的 String 字符串表示。
根据给定的动作的状态,返回0.0到1.0之间的值。对于获取InputEventJoypadMotion类型的事件值时,很有用。
如果exact_match
是false
,它将忽略InputEventKey和InputEventMouseButton事件的输入修饰符,以及InputEventJoypadMotion事件的方向。
如果这个输入事件与任何类型的预定义动作匹配,则返回true
。
如果exact_match
是false
,它将忽略InputEventKey和InputEventMouseButton事件的输入修饰符,以及InputEventJoypadMotion事件的方向。
如果给定的动作被按下,则返回true
,并且不是 InputEventKey 事件的回显事件,除非 allow_echo
是 true
。与InputEventMouseMotion或InputEventScreenDrag类型的事件无关。
如果exact_match
是false
,它将忽略InputEventKey和InputEventMouseButton事件的输入修饰符,以及InputEventJoypadMotion事件的方向。
如果给定的动作被释放,即未被按下,则返回true
。与InputEventMouseMotion或InputEventScreenDrag类型的事件无关。
如果exact_match
是false
,它将忽略InputEventKey和InputEventMouseButton事件的输入修饰符,以及InputEventJoypadMotion事件的方向。
- bool is_action_type ( ) const
如果此输入事件的类型是可以分配给输入动作的类型,则返回 true
。
- bool is_echo ( ) const
如果此输入事件是回显事件(仅适用于 InputEventKey 类型的事件),则返回 true
。
- bool is_pressed ( ) const
如果此输入事件为按下,则返回 true
。与类型 InputEventMouseMotion 或 InputEventScreenDrag 的事件无关。
- bool shortcut_match ( InputEvent event, bool exact_match=true ) const
如果指定的 event
与此事件匹配,则返回 true
。仅对动作事件有效,即键 (InputEventKey)、按钮 (InputEventMouseButton 或 InputEventJoypadButton)、轴 InputEventJoypadMotion 或动作 (InputEventAction) 事件。
如果 exact_match
是 false
,它会忽略 InputEventKey 和 InputEventMouseButton 事件的输入修饰符,以及 InputEventJoypadMotion 事件的方向。
- InputEvent xformed_by ( Transform2D xform, Vector2 local_ofs=Vector2( 0, 0 ) ) const
返回给定输入事件的副本,该事件已由 local_ofs
偏移并由 xform
转换。与 InputEventMouseButton、InputEventMouseMotion、InputEventScreenTouch、InputEventScreenDrag、InputEventMagnifyGesture 和 InputEventPanGesture 类型的事件相关。