36 lines
594 B
GDScript
36 lines
594 B
GDScript
extends RefCounted
|
|
class_name InputSchema
|
|
|
|
static func defaults() -> Dictionary:
|
|
return {
|
|
"move_left": [
|
|
_key(KEY_A),
|
|
_key(KEY_LEFT),
|
|
],
|
|
"move_right": [
|
|
_key(KEY_D),
|
|
_key(KEY_RIGHT),
|
|
],
|
|
"jump": [
|
|
_key(KEY_SPACE),
|
|
],
|
|
"attack": [
|
|
_mouse(MOUSE_BUTTON_LEFT),
|
|
],
|
|
}
|
|
|
|
## ===============================
|
|
## Helpers (序列化友好)
|
|
## ===============================
|
|
static func _key(keycode: int) -> Dictionary:
|
|
return {
|
|
"type": "key",
|
|
"keycode": keycode,
|
|
}
|
|
|
|
static func _mouse(button: int) -> Dictionary:
|
|
return {
|
|
"type": "mouse",
|
|
"button": button,
|
|
}
|