How to change the button sprite in a clicker on Godot

Godot Version

4.6.2

QuestionHow to change the button sprite in the clicker on Godot

I need to change the button sprite to a different image when I reach 20 clicks. I don’t understand how to do this. I have already created 2 TouchScreenButtons and set a picture for them when I click on the button. However, I need to make it so that 1 TouchScreenButton changes to 2 TouchScreenButtons when I reach 20 clicks.

extends Node2D
var clic = 0
var lv1 = 20

func _on_touch_screen_button_pressed() -> void:
	clic += 1
	print(clic)
func _physics_process(delta):
	$Label.text = "СЧЁТ: " + str(clic)

if clic == 20:
	???

Similar to how you change the label’s .text you can change your touch screen button’s .texture_normal

func _on_touch_screen_button_pressed() -> void:
	clic += 1
	if clic == 20:
		$TouchScreenButton1.texture_normal = load("res://your_new_image_file.png")
1 Like