Merging Two Sprites for a Crafting System

Godot Version

4.2.2

Question

I have a crafting system set up where you combine Items to create new ones. Each item is a resource called ItemData. Combining all the in-game stats is fine but what I have a problem with is combining the texture sprite of the items. I need to create a new texture somehow that is made up of the combined item’s textures, and then save that resource using the ResourceSaver. Is there a way to do this?

Note: I do have the position offsets such that I can combine the sprites in the correct locations.

If you are only doing this to create new resources in the editor, you can do a lot of this with this class:

you can use the blend functions to combine sprites and then save to the format you want, if you want something more complex with how you combine them, doing your own combine pixel math is pretty easy too, then save in the same way, etc.

If you want to do any of this in game, where it just visually combines two sprites but never creates a totally new image asset (or stacking sprites which is an option but depending on the layers it can get tricky), you can use a canvas shader to do some of that too.

2 Likes