Node BUTTON cómo cambiar el color por código

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ariel

simplemente quiero cambiar el color al boton cuando pasa un acción pero nose como hacerlo

Lo estoy haciendo en godot 2.14

english:
I just want to change the color of the button when an action happens but I do not know how to do it

I’m doing it in godot 2.14

Encontré una forma de hacerlo. Para que no haya barreras de lenguaje, dejé la respuesta en ambos idiomas. Quizás podrías usar el traductor para que tu pregunta esté tmb en ambos idiomas, tanto en el título como en la respuesta. No se me ocurre otra forma de que todos entiendan y aún así no se te aumente la curva de aprendizaje por usar otro idioma.

p7f | 2018-11-29 13:45

:bust_in_silhouette: Reply From: p7f

English Answer below

Encontré una forma que funciona para mí.

var style = StyleBoxFlat.new()
var color = Color(1,0,0)
style.set_bg_color(color)
$Button.set("custom_styles/normal", style)

Primero, creo un estilo, y un color. Luego, seteo el color de background al estilo. Por último, seteo el estilo normal de los custom_style con el estilo recién creado.
En tu caso deberías poner ese código en la función que se dispara cuando sucede la acción que querés que cambie el color del boton. Avisame si es suficiente con eso.

English Answer
I found a way that works for me.

var style = StyleBoxFlat.new()
var color = Color(1,0,0)
style.set_bg_color(color)
$Button.set("custom_styles/normal", style)

First, i create a style and a color. Then i set the background color to the style. Last, y set the normal style of custom_style with the recently created style. In your case, you shoud put that code in the function that runs when the the action you want to change the color triggers.

ok,gracias lo voy a probar y te cuento
ok, thanks I’ll try it and I’ll tell you

ariel | 2018-11-30 12:50