SFML community forums

Help => Graphics => Topic started by: Chiggy_Playz on April 18, 2019, 08:23:06 pm

Title: How can I check if a Sprite has a texture loaded or not?
Post by: Chiggy_Playz on April 18, 2019, 08:23:06 pm
I want to apply an if condition that if sprite does not have texture, then run.
Title: Re: How can I check if a Sprite has a texture loaded or not?
Post by: FRex on April 18, 2019, 09:11:59 pm
Sprite has a get texture that returns a pointer which can be NULL if it was never set.

https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Sprite.php#a1a76155146c8ff37c4eb5a306b4e9ebe
Title: Re: How can I check if a Sprite has a texture loaded or not?
Post by: eXpl0it3r on April 19, 2019, 09:37:12 am
A sprite always has a texture. That the texture has been loaded should be guaranteed by your application flow and can be checked when loadFromFile is called. :)