SFML community forums

Help => Graphics => Topic started by: Doodler on August 08, 2019, 09:02:17 pm

Title: Merging two textures/images
Post by: Doodler on August 08, 2019, 09:02:17 pm
So basically sorry if this is obvious to do, but what I’m trying to figure out is to combine two textures I have(both 80 by 80 pixels) into one before putting it on a sprite.

My player has two separate moving components the bottom that animates based on the direction of the player, and the top which switches textures to point in the direction the player is facing.

I don’t want to combine them because it would increase my images from 2 spritemaps of 8 to 1 spritemap of 64
Title: Re: Merging two textures/images
Post by: Geheim on August 08, 2019, 09:44:28 pm
Have you seen sf::RenderTexture yet? (https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1RenderTexture.php) You can just draw your individual parts on one of them and use the combined texture for your sprite.
Another way would be to just draw them separately. If the parts overlap you might want to use an apropriate BlendMode (https://www.sfml-dev.org/documentation/2.5.1/structsf_1_1BlendMode.php).