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 788 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: 1839
    • View Profile
    • My GitHub Page
    • 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
ZipSavings, script to count rar/7z/zip savings: https://goo.gl/vvBj5M
LuaConsole: https://goo.gl/X4kRUk
FoxRaycaster: https://goo.gl/27nVS8
Small Games - Heart, Routing and Snek: https://goo.gl/15ZGWE https://goo.gl/k5gwWD https://goo.gl/4nKPnT
Botes - a notes app in Pascal: https://goo.gl/bzTqsi

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 9866
    • 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/