glennmark
glennmark

Reputation: 543

godot - how to change sprite of a child node dynamically

Screenshot of 'Tao' node:

enter image description here

I can't find a tutorial or a guide on how to change the sprite of a child node dynamically. I need to change the sprite of 'baba' which is a child of 'Tao.

Here's my code and it's not working:

var tao = Tao.instance()
var spr = str("res://assets/tao", i+1)
tao.get_child("baba") = load(spr)

Upvotes: 0

Views: 2371

Answers (1)

glennmark
glennmark

Reputation: 543

I got the solution. Just wanna share.

var tao = Tao.instance()
var spr = str("res://assets/tao", i+1, ".png")
tao.get_node("baba").get_node("itsura").texture = load(spr)

Upvotes: 1

Related Questions