Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | tproper |
Why doesn’t this work? I call the ‘set_color’ from another node and I see that the right match statement is executed but the sprite does not change from it’s default
extends RigidBody2D
var Drop_Color
var Green_Sprite
var Brown_Sprite
var Purple_Sprite
var Tan_Sprite
var Yellow_Sprite
func _ready():
Green_Sprite = load("res://Images/green_drop.png")
Brown_Sprite = load("res://Images/brown_drop.png")
Purple_Sprite = load("res://Images/purple_drop.png")
Tan_Sprite = load("res://Images/tan_drop.png")
Yellow_Sprite = load("res://Images/yellow_drop.png")
set_physics_process(true)
func set_color(c):
Drop_Color = c
match Drop_Color:
Common.Color_Green:
get_node("Sprite").set_texture(Green_Sprite)
Common.Color_Brown:
get_node("Sprite").set_texture(Brown_Sprite)
Common.Color_Purple:
get_node("Sprite").set_texture(Purple_Sprite)
Common.Color_Tan:
get_node("Sprite").set_texture(Tan_Sprite)
Common.Color_Yellow:
get_node("Sprite").set_texture(Yellow_Sprite)
Did you try swapping the load
method with preload
? Maybe that could change something? :-/
SIsilicon | 2018-10-14 20:56
Just tired it, still doesn’t work.
tproper | 2018-10-14 22:24