InputMap

Inherits: Object

管理 InputEventAction 的单例。

描述

管理所有的 InputEventAction,可以通过项目设置菜单项目 > 项目设置 > 键位映射或在代码中用 add_actionaction_add_event 创建/修改。请参阅 Node._input

教程

方法

void

action_add_event ( String action, InputEvent event )

void

action_erase_event ( String action, InputEvent event )

void

action_erase_events ( String action )

float

action_get_deadzone ( String action )

bool

action_has_event ( String action, InputEvent event )

void

action_set_deadzone ( String action, float deadzone )

void

add_action ( String action, float deadzone=0.5 )

void

erase_action ( String action )

bool

event_is_action ( InputEvent event, String action, bool exact_match=false ) const

Array

get_action_list ( String action )

Array

get_actions ( )

bool

has_action ( String action ) const

void

load_from_globals ( )

方法说明

给一个动作添加一个InputEvent。这个InputEvent将触发这个动作。


从一个动作中删除一个InputEvent


  • void action_erase_events ( String action )

从动作中删除所有事件。


返回该操作的死区值。


如果该动作有给定的InputEvent与之相关,则返回true


  • void action_set_deadzone ( String action, float deadzone )

为该动作设置死区值。


InputMap上添加一个空的动作,有一个可配置的死区deadzone

然后可以用action_add_event给这个动作添加一个InputEvent


  • void erase_action ( String action )

InputMap中删除一个动作。


如果给定的事件是现有动作的一部分,返回true。如果给定的InputEvent没有被按下,这个方法会忽略键盘(为了正确地检测释放)。如果你不想要这种行为,请参阅action_has_event

如果exact_matchfalse,它会忽略InputEventKeyInputEventMouseButton事件的输入修饰符,以及InputEventJoypadMotion事件的方向。


返回与给定操作关联的 InputEvent 数组。


返回InputMap中所有动作的数组。


如果InputMap有一个给定名称的注册动作,返回true


  • void load_from_globals ( )

清除InputMap中的所有InputEventAction,并从ProjectSettings项目设置中重新加载它。