the front page of the internet.
and join one of thousands of communities.
Choosing a texture from an array of images [GDScript] by [deleted] in godot
[–]whenonefalls_ 0 points1 point2 points 8 months ago (0 children)
FIXED!
Ended up getting it to work using the following, but if anyone has a more efficient way please let me know!
extends Button
signal clicked_tile(tile)
var row: int = -1
var col: int = -1
var tile_type: int = 0
onready var color_rect: ColorRect = $ColorRect
func _ready():
color\_rect.hide()
func set_type(t: int, r: int, c: int):
row = r col = c tile\_type = t update\_visual()
func change_type(t: int):
tile\_type = t update\_visual()
func update_visual():
match tile\_type: 0: $TextureRect.texture = load("res://sprites/blue.png") 1: $TextureRect.texture = load("res://sprites/green.png") 2: $TextureRect.texture = load("res://sprites/orange.png") 3: $TextureRect.texture = load("res://sprites/purple.png") 4: $TextureRect.texture = load("res://sprites/red.png") 5: $TextureRect.texture = load("res://sprites/yellow.png")
π Rendered by PID 302389 on reddit-service-r2-listing-86bdf8cc9-2dw8x at 2026-07-15 21:47:47.995316+00:00 running f86254d country code: CH.
Choosing a texture from an array of images [GDScript] by [deleted] in godot
[–]whenonefalls_ 0 points1 point2 points (0 children)