godot-plateformer/__settings/input/InputSchema.gd

36 lines
594 B
GDScript3
Raw Normal View History

2026-01-15 17:43:58 +08:00
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,
}