InputMap
继承: Object
管理所有 InputEventAction 的单例。
描述
管理所有的 InputEventAction,可以通过项目设置菜单项目 > 项目设置 > 输入映射或在代码中用 add_action 和 action_add_event 创建/修改。请参阅 Node._input。
教程
方法
void | action_add_event ( StringName action, InputEvent event ) |
void | action_erase_event ( StringName action, InputEvent event ) |
void | action_erase_events ( StringName action ) |
action_get_deadzone ( StringName action ) | |
action_get_events ( StringName action ) | |
action_has_event ( StringName action, InputEvent event ) | |
void | action_set_deadzone ( StringName action, float deadzone ) |
void | add_action ( StringName action, float deadzone=0.5 ) |
void | erase_action ( StringName action ) |
event_is_action ( InputEvent event, StringName action, bool exact_match=false ) const | |
get_actions ( ) | |
has_action ( StringName action ) const | |
void |
方法说明
void action_add_event ( StringName action, InputEvent event )
给某个动作添加一个 InputEvent。这个 InputEvent 将触发这个动作。
void action_erase_event ( StringName action, InputEvent event )
从某个动作中删除一个 InputEvent。
void action_erase_events ( StringName action )
从某个动作中删除所有事件。
float action_get_deadzone ( StringName action )
返回该操作的死区值。
InputEvent[] action_get_events ( StringName action )
返回与给定动作关联的 InputEvent 的数组。
注意:在编辑器中使用时(例如在工具脚本或 EditorPlugin 中使用),这个方法返回的是编辑器动作对应的事件。如果你想要在编辑器中访问你的项目的输入绑定,请读取 ProjectSettings 的 input/*
设置。
bool action_has_event ( StringName action, InputEvent event )
如果该动作有给定的 InputEvent 与之相关,则返回 true
。
void action_set_deadzone ( StringName action, float deadzone )
为该动作设置死区值。
void add_action ( StringName action, float deadzone=0.5 )
在 InputMap 上添加空的动作,死区可使用 deadzone
配置。
然后可以用 action_add_event 给这个动作添加 InputEvent。
void erase_action ( StringName action )
从 InputMap 中删除一个动作。
bool event_is_action ( InputEvent event, StringName action, bool exact_match=false ) const
如果给定的事件是现有动作的一部分,返回 true
。如果给定的 InputEvent 没有被按下,这个方法会忽略键盘(为了正确地检测释放)。如果你不想要这种行为,请参阅 action_has_event。
如果 exact_match
是 false
,它会忽略 InputEventKey 和 InputEventMouseButton 事件的额外输入修饰键,以及 InputEventJoypadMotion 事件的方向。
StringName[] get_actions ( )
返回 InputMap 中所有动作的数组。
bool has_action ( StringName action ) const
如果 InputMap 有一个给定名称的注册动作,返回 true
。
void load_from_project_settings ( )
清除 InputMap 中的所有 InputEventAction,并从 ProjectSettings 项目设置中重新加载它。
© 版权所有 2014-present Juan Linietsky, Ariel Manzur and the Godot community (CC BY 3.0). Revision b1c660f7
.
Built with Sphinx using a theme provided by Read the Docs.