Multiples textures in one sprite

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

How can I add multiples textures in one sprite?

:bust_in_silhouette: Reply From: Gabriel

What are you trying to achieve?

You can not add multiple image textures to a single ‘Sprite’ node, but you can swap them in gdscript:

extends Node2D

var image1 = load("res://icon.png")
var image2 = load("res://test_sprite.png")

func _ready():
    $Sprite.texture = image2 # set the texture you want

On the other hand, if you are just trying to make an animation, you have two options:

1 - Use an AnimatedSprite node if your animation frames are spread in a bunch of different images files.
2 - Use a Sprite node and change the “Hframes”, “Vframes” and “Frame” properties in the Inspector if you are using a spritesheet.

For more information on 2d animation: 2D Sprite animation

Look the tree of the player:
enter image description here

Below I have 3 animations and here its my code to show one animation:


But nothing happens, still showing the main sprite. What im doing wrong?

DarlesLSF | 2019-10-10 21:18