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

Author Topic: Having trouble interfacing with events  (Read 6757 times)

0 Members and 1 Guest are viewing this topic.

fragged

  • Newbie
  • *
  • Posts: 3
    • View Profile
Having trouble interfacing with events
« on: May 04, 2009, 09:21:14 pm »
hey guys, I'm having trouble interfacing with events, or finding any tutorial-like documentation to understand (Unfortunately, help(Event) hasn't been very helpful :()

Would anybody be kind enough to show me there code that prints /all/ events to the screen, along with the data related to it. With the code provided below I was able to see a keypress, or mouse movement, but unable to figure out how to probe for any more information..

Code: [Select]

while App.GetEvent(Event):
            print Event.Type
            #help(Event)


I'm happy to write my own handler, but I just cant figure out how to pull anymore data :(

Cheers,
Fragged

I've jumped to SFML from PyGame and I'm loving it; bar the installation trouble it seems to be a hell of a lot faster, with the same simple library :)

remi.k2620

  • Full Member
  • ***
  • Posts: 186
    • View Profile
    • http://remi.tuxfamily.org
Having trouble interfacing with events
« Reply #1 on: May 07, 2009, 08:28:05 pm »
It's the same in c++, so you can have a look at the c++ tutorial : http://www.sfml-dev.org/tutorials/1.4/window-events.php
Just adapt it to the python syntax. For example
Code: [Select]
while (App.IsOpened())
{
    sf::Event Event;
    while (App.GetEvent(Event))
    {
        // Window closed
        if (Event.Type == sf::Event::Closed)
            App.Close();

        // Escape key pressed
        if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
            App.Close();
    }
}


becomes
Code: [Select]
while App.IsOpened():
    Event = sf.Event()
    while App.GetEvent(Event):
        // Window closed
        if Event.Type == sf.Event.Closed:
            App.Close()

        // Escape key pressed
        if (Event.Type == sf.Event.KeyPressed) and (Event.Key.Code == sf.Key.Escape):
            App.Close()

 

anything