LE CHANGEMENT DE TOUCHES REMARCHE ! LOUE SOIT LES SAINT PARAMETRES
This commit is contained in:
parent
ef0b911b9c
commit
713a03c6be
3 changed files with 17 additions and 12 deletions
|
@ -5,7 +5,7 @@ extends Control
|
|||
@onready var button = $HBoxContainer/Button as Button
|
||||
|
||||
@export var nom_action : String = "BOUGER_HAUT"
|
||||
var nom_touche : String = OS.get_keycode_string(InputMap.action_get_events(nom_action)[0].physical_keycode)
|
||||
@onready var nom_touche : String = OS.get_keycode_string(InputMap.action_get_events(nom_action)[0].physical_keycode)
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
|
@ -28,9 +28,9 @@ func set_texte_label() -> void :
|
|||
"BOUGER_BAS":
|
||||
label.text = "descendre"
|
||||
"BOUGER_DROITE":
|
||||
label.text = "droite"
|
||||
label.text = "aller à droite"
|
||||
"BOUGER_GAUCHE":
|
||||
label.text = "gauche"
|
||||
label.text = "aller à gauche"
|
||||
"PAUSE":
|
||||
label.text = "Pause"
|
||||
|
||||
|
@ -39,6 +39,7 @@ func set_texte_bouton() -> void:
|
|||
button.text = "%s" % nom_touche
|
||||
|
||||
func definir_touche(touche)-> void:
|
||||
|
||||
var old = InputMap.action_get_events(nom_action)[0]
|
||||
var action_keycode=touche.physical_keycode
|
||||
|
||||
|
@ -46,11 +47,14 @@ func definir_touche(touche)-> void:
|
|||
InputMap.action_add_event(nom_action, touche)
|
||||
set_texte_bouton()
|
||||
|
||||
print(nom_action, "deviens ", nom_touche)
|
||||
|
||||
for i in get_tree().get_nodes_in_group("changer_touches"):
|
||||
if i.nom_action != self.nom_action :
|
||||
if i.nom_touche==self.nom_touche :
|
||||
i.definir_touche(old)
|
||||
if i.nom_action != self.nom_action and i.nom_touche==self.nom_touche :
|
||||
InputMap.action_erase_events(i.nom_action)
|
||||
InputMap.action_add_event(i.nom_action, old)
|
||||
i.set_texte_bouton()
|
||||
print(i.nom_action, "deviens ", i.nom_touche, "car échange")
|
||||
|
||||
func _on_button_pressed():
|
||||
button.text = "Appuyez sur une touche..."
|
||||
|
@ -63,5 +67,5 @@ func _unhandled_key_input(event):
|
|||
|
||||
|
||||
func _on_hidden():
|
||||
set_process_unhandled_key_input(true)
|
||||
set_process_unhandled_key_input(false)
|
||||
set_texte_bouton()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue