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

Author Topic: Adding 2 Events in an SFML Application?  (Read 2105 times)

0 Members and 1 Guest are viewing this topic.

bladelock

  • Newbie
  • *
  • Posts: 20
    • View Profile
Adding 2 Events in an SFML Application?
« on: September 26, 2011, 11:42:58 am »
Okay, i learned how to initialize an Event through this code
Code: [Select]
while (Running)
{
    sf::Event Event;
    while (App.GetEvent(Event))
    {
        // Process event
    }

    App.Display();
}


I then became zealous and created 2 events
Code: [Select]
while (Running)
{
    sf::Event Event;
    sf::Event Second;
    while (App.GetEvent(Event))
    {
        // Process event
    }

    while(App.GetEvent(Second))
    {
        //Process other events
     }

    App.Display();
}


Then when I run my SFML program, it releases this...

"Run-Time Check Failure #3 - The variable 'Second' is being used without being initialized."

I don't get it. How do I initialize my Event named Second?

Cheers.

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Adding 2 Events in an SFML Application?
« Reply #1 on: September 26, 2011, 01:03:44 pm »
Whats the point? If you got all events left in the first loop, why would a second event loop work at all? it just skips.

Haikarainen

  • Guest
Adding 2 Events in an SFML Application?
« Reply #2 on: September 26, 2011, 04:40:02 pm »
what mr devil means is, youre doing it wrong
Code: [Select]
sf::Event Event;
while(Window.PollEvent(Event)){
   // First event here
   if(Event.Type == sf::Event::Closed){
      Window.Close();
   }

   // Second event here
   if(Event.Type == sf::Event::Other){
      Something.Other();
   }
}

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Adding 2 Events in an SFML Application?
« Reply #3 on: September 27, 2011, 01:56:19 am »
Thanks a lot for the additional answer, i meant it when i said i didnt know what his point was , but that should be it :D

bladelock

  • Newbie
  • *
  • Posts: 20
    • View Profile
Adding 2 Events in an SFML Application?
« Reply #4 on: September 27, 2011, 11:12:11 am »
i think this solves this particular issue, but it seems like i might have to take on a different approach for this issue

http://www.sfml-dev.org/forum/viewtopic.php?p=39133#39133


thanks for the help!