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

Author Topic: Sfml 2.0 how can i call a method a precise nomber of times each seconds?  (Read 1142 times)

0 Members and 1 Guest are viewing this topic.

ayzed

  • Newbie
  • *
  • Posts: 9
    • View Profile
Let's say that i want to call the draw method less than other methods so i can have more cpu for those other methods like updating movement or collision,how can i do it?can i have a working exemple?
thanx in advance

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
sf::Clock clock;
while(window.isOpen())
{
    if(clock.elapsedTime().asSeconds() >= 1.f)
    {
        // Do your stuff every second.
        clock.reset();
    }
}
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything