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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - lostmemories

Pages: [1]
1
Hi, I am a beginner at SFML and am making a Pokemon copycat. I need help with displaying the exact same window on the screen for a few seconds. For example, when Pokemon use attacks, the text bar will display which attack they used for ~2 seconds. My current "fight menu" (where you select which attack to use) code follows this layout:

while(window.isOpen()){
  while(window.waitEvent(event)){
    switch(event.type){
      case sf::Event::KeyPressed:{
        if(event.key.code == sf::Keyboard::A){ //player selects the attack they are currently hovering over
          window.clear();
          window.draw(everything);
          window.display();
          usleep(2000000); //sleep for 2 seconds so that this window stays on screen
          //opponent uses an attack
          usleep(2000000); //sleep for 2 seconds again for the opponent's attack
          //loop back to player's turn

The problem is that if I do it this way, my program still picks up Events during the 2 seconds of sleep. So if you spam 'A' during the 2 seconds of sleep, the program will immediately repeat the same attack after the opponent's attack ends. How can I stop events from being collected while displaying these extended windows? Or is there a better way to display an extended window? Any help/ideas would be greatly appreciated, thanks!

Pages: [1]