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

Author Topic: Sprite texture shows up fully for a second until it goes to frame.  (Read 1191 times)

0 Members and 1 Guest are viewing this topic.

Rietty

  • Newbie
  • *
  • Posts: 5
    • View Profile
Hi, so I have this project I'm working on, and here is the relevant code:

https://github.com/Rietty/Hellcraft/blob/master/Menu.hpp

The issue is that when I first start my application, the sprite shows up fully (aka all frames flash across the screen) before it goes to animation/frame cycling. Obviously this isn't something that should be happening and I'm a bit stumped to resolve it. I've tried moving various initialization calls around as well as having a Boolean check for when stuff is initialized however this does not seem to solve the problem.

What else can I try and is there something else I'm missing?

Currently it looks like this for the first second after loading:

(click to show/hide)


eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Sprite texture shows up fully for a second until it goes to frame.
« Reply #1 on: January 15, 2019, 07:31:46 am »
When initializing your animation object, you're never setting the frameSize/textureRect. It gets set for the first time in update(), but update() will call it for the first time once some some time had passed to fullfil the condition if(m_currentTime >= m_frameTime).
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Rietty

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Sprite texture shows up fully for a second until it goes to frame.
« Reply #2 on: January 15, 2019, 04:16:23 pm »
Aha!
That worked! Thank you so much. :)

 

anything