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

Author Topic: When I'm displaying sprite on screen for short amount of time I see whole textur  (Read 1466 times)

0 Members and 1 Guest are viewing this topic.

MDK

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
I have a texture for animated creature that is controlled by a player. When I'm starting a program for a short amount of time I can see whole texture. And then after, maybe 1/5 or even 1/10 of a second a proper animation starting. Can I avoid displaying whole texture? Texture size is 300x300px, and animated sprite is 60x60, and its rather very small size of 7,52KB. File format is .PNG. In the same time I'm displaying another animation (smaller one - 300x50px, .PNG, independent from a player) and that one is ok.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Sounds like a bug in your code. Make sure the texture rect is always what you think it should be.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

MDK

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Ok, i found my "error".
I just changed lines:
  Sprite heroS;                         
  heroS.setTexture(heroT);
into:
  Sprite heroS(heroT, guyRectSourceSprite);

I realised that that was remnant from before. But the point is - first frame of animation was always displaying whole .png file and the second one after refreshing was a proper one. That was because of lack of IntRect in previous 2 lines of that code.
Thx for pointing on solution.