Godot 入力処理
InputMap
入力を管理するシングルトン。通常はこれを使うことになるだろう。
1 extends Node
2
3 func _input(event: InputEvent) -> void:
4 var v = get_viewport();
5 if event is InputEventMouseButton:
6 print("mouse click/unclick: %s", v.get_mouse_position())
7
8 if event is InputEventMouseMotion:
9 print("mouse move: %s",v.get_mouse_position())
10
11 func _process(delta: float) -> void:
12 if Input.is_action_pressed("ui_left"):
13 print("left\n")
14
15 if Input.is_action_pressed("ui_right"):
16 print("right\n")
17
18 if Input.is_action_pressed("ui_up"):
19 print("up\n")
20
21 if Input.is_action_pressed("ui_down"):
22 print("down\n")
23
24 if Input.is_action_just_pressed("ui_left"):
25 print("just left\n")
26
27 if Input.is_action_just_pressed("ui_right"):
28 print("just right\n")
29
30 if Input.is_action_just_pressed("ui_up"):
31 print("just up\n")
32
33 if Input.is_action_just_pressed("ui_down"):
34 print("just down\n")
35
36 func _ready() -> void:
37 var x = InputMap.get_actions()
38 for i in x:
39 print(i)
40