forked from team-sg/hero-mark-2
gamepad buttons
This commit is contained in:
parent
35b757cd22
commit
85a331ed37
5 changed files with 51 additions and 6 deletions
BIN
objects/hud/gamepad_buttons.atlastex
Normal file
BIN
objects/hud/gamepad_buttons.atlastex
Normal file
Binary file not shown.
|
@ -83,11 +83,12 @@ margin_bottom = 32.0
|
|||
unique_name_in_owner = true
|
||||
margin_top = 36.0
|
||||
margin_right = 218.0
|
||||
margin_bottom = 64.0
|
||||
margin_bottom = 146.0
|
||||
focus_mode = 2
|
||||
tabs_visible = false
|
||||
|
||||
[node name="Game" type="VBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs"]
|
||||
visible = false
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
focus_next = NodePath("Rumble/SelectRumble")
|
||||
|
@ -446,7 +447,6 @@ script = ExtResource( 3 )
|
|||
options = [ "off", "on" ]
|
||||
|
||||
[node name="Input" type="VBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs"]
|
||||
visible = false
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
focus_next = NodePath("Left/Keyboard")
|
||||
|
@ -509,6 +509,7 @@ margin_right = 218.0
|
|||
margin_bottom = 10.0
|
||||
size_flags_horizontal = 3
|
||||
text = "-"
|
||||
icon_align = 1
|
||||
script = ExtResource( 9 )
|
||||
action = "move_left"
|
||||
options_screen = NodePath("../../../../../../../..")
|
||||
|
@ -675,9 +676,9 @@ options_screen = NodePath("../../../../../../../..")
|
|||
|
||||
[node name="DefaultControls" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input"]
|
||||
margin_left = 81.0
|
||||
margin_top = 32.0
|
||||
margin_top = 100.0
|
||||
margin_right = 137.0
|
||||
margin_bottom = 42.0
|
||||
margin_bottom = 110.0
|
||||
size_flags_horizontal = 4
|
||||
text = "defaults"
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue