Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How can I check if a Sprite has a texture loaded or not?  (Read 1447 times)

0 Members and 1 Guest are viewing this topic.

Chiggy_Playz

  • Newbie
  • *
  • Posts: 15
    • View Profile
How can I check if a Sprite has a texture loaded or not?
« on: April 18, 2019, 08:23:06 pm »
I want to apply an if condition that if sprite does not have texture, then run.

FRex

  • Hero Member
  • *****
  • Posts: 1841
  • Not doing gamedev/using SFML lately
    • View Profile
    • Email
Re: How can I check if a Sprite has a texture loaded or not?
« Reply #1 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
I'm not using SFML nor doing any gamedev lately.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10278
    • View Profile
    • development blog
    • Email
Re: How can I check if a Sprite has a texture loaded or not?
« Reply #2 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. :)
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/