SFML community forums

Help => General => Topic started by: bladelock on September 26, 2011, 11:42:58 am

Title: Adding 2 Events in an SFML Application?
Post by: bladelock 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.
Title: Adding 2 Events in an SFML Application?
Post by: Grimshaw 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.
Title: Adding 2 Events in an SFML Application?
Post by: Haikarainen 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();
   }
}
Title: Adding 2 Events in an SFML Application?
Post by: Grimshaw 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
Title: Adding 2 Events in an SFML Application?
Post by: bladelock 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!