How to clear texture of sprite

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By exuin

I can use set_texture() to set the texture to another image, but how do I get rid of the texture? Should I just be hiding the sprite instead when I don’t want to see it?

:bust_in_silhouette: Reply From: Adam_S

To remove the texture:

$Sprite.texture = null

or

$Sprite.set_texture(null)

If you are sure that you don’t need the sprite anymore you should use queue_free() to delete it, otherwise hide it.

But if you want to use the sprite again later with another texture, just remove the texture.

Neither $Sprite.texture = null nor $Sprite.set_texture(null) seem to be working for me (When I replace the line with $Sprite.hide() it does hide the sprite, so I guess it is getting the sprite node correctly).

Edit: Nevermind, it works, I just forgot to clear a variable.

exuin | 2020-03-15 19:29