How can I combine several textures and sprites and save them to disk as a PNG image file

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

I’m working on the character creation scene for my game. I have designed some controls to let the user customize the character avatar a little bit:

The 4 controls load images from 3 different PNG files (loaded as atlas textures, since each file has 160 images). I want to store the player selection and I think the most efficient way would be to combine what they can see (including the frame, which I’m loading as a TextureRect) and save it into a PNG file that I can then load into the level scene.

This is the Node structure:

    CharacterBanner (TextureRect)
      CharacterBg (TextureRect)
      CharacterFrame (TextureRect)
      CharacterFace (Sprite)
      CharacterEyes (Sprite)
      CharacterHair (Sprite)

The question is: how can I combine the images?

I’ve seen how to save a Texture as a PNG file, but I need to save several textures and I need them to work like layers in a PSD file.

PS: It seems that images are not working here, that’s why I posted the link directly…

:bust_in_silhouette: Reply From: uniquegamesofficial

Click on the Editor and the click Toogle Screenshot while having open the scene with the textures. You can also use the shortcut Control+F12. Then the screenshot will open on another window. Now you can crop it! If the image isn’t .PNG, you can convert it online!

That’s not what I want…

What I want is, once the game is running and someone is playing it, and they choose the appearance they want for their character, I want to be able to combine all of those images into a single PNG file, so that it’s easier and more efficient to show later in the game.

danielhernandez | 2021-08-06 10:01

Convert the scene to tileset. Then you can use Tilemaps for your character’s appearance. Try to change the visibility of tilemaps, as you change the character’s appearance!

uniquegamesofficial | 2021-08-06 15:42

That’s an interesting idea, but I don’t see a way to get the texture from the TileMap, which is what I want in the end: to save the whole image to a PNG file.

danielhernandez | 2021-08-09 07:40

Hi, I’m in a similar situation, did you find a way to merge multiple images in one texture?