gamepad buttons

This commit is contained in:
Haze Weathers 2024-03-15 19:00:59 -04:00
parent 35b757cd22
commit 85a331ed37
5 changed files with 51 additions and 6 deletions

View file

@ -2,16 +2,18 @@ extends Button
const BLINK_SPEED: int = 150
const GAMEPAD_BUTTONS: AtlasTexture = preload("res://objects/hud/gamepad_buttons.atlastex")
export var action: String
export var options_screen: NodePath
var listen := false
var gamepad_buttons := GAMEPAD_BUTTONS.duplicate()
func _init() -> void:
icon_align = Button.ALIGN_CENTER
connect("pressed", self, "_on_pressed")
@ -28,7 +30,14 @@ func _process(delta: float) -> void:
func _update_text() -> void:
text = str(Controls.get_button(action))
var button = Controls.get_button(action)
if button >= 0:
gamepad_buttons.region.position.x = float(button % 8) * 12.0
gamepad_buttons.region.position.y = float(button / 8) * 10.0
icon = gamepad_buttons
text = ""
else:
text = "-"
modulate.a = 1.0