Hello! I'm starting with Godot. I want to know how can i change a button texture at a function. I have button at my Game scene. And I want that at func game_over() my button changes the texture to another image. Some idea for coding this? Thanks in advance!
Change button texture at function
- Edited
- Best Answerset by retroshark
If it's a TextureButton, you should be able to do this:
# Untested code
texture_normal = load("res://image.png")
https://docs.godotengine.org/en/4.1/classes/class_texturebutton.html
It's more efficient to have the textures preloaded into variables, so that the image file doesn't have to be loaded at run time.
This tutorial might be helpful. Generally, you would want to use a signal to change something on your UI.
https://kidscancode.org/godot_recipes/4.x/basics/node_communication/index.html
DaveTheCoder It works! Thanks a lot!!