SFML community forums

Help => Graphics => Topic started by: codelyoko373 on August 20, 2017, 02:07:53 am

Title: Selecting different sized Sprites from Sprite Sheet
Post by: codelyoko373 on August 20, 2017, 02:07:53 am
I'm quite new to SFML and I have looked at some videos of getting different sprites from sprite sheets but the reason those videos haven't really helped me is they use sprite sheets that hold same sized sprites throughout while the sprite sheet I'm using which is for Space Invaders:
(http://i.imgur.com/p71FaPP.png)
Has different sized sprites.

I was wondering how exactly I would get these different sized sprites out of the sprite sheet?
Title: Re: Selecting different sized Sprites from Sprite Sheet
Post by: Hapax on August 20, 2017, 02:38:47 am
Set the texture rect of the sf::Sprite to match the image part that you wish to use. The sprite automatically resizes to the size of the part of the image that you choose in this way.

sf::Sprite::SetTextureRect (https://www.sfml-dev.org/documentation/2.4.2/classsf_1_1Sprite.php#a3fefec419a4e6a90c0fd54c793d82ec2)