SFML 2.0 RC problems

Hi

I'm following these http://www.youtube.com/watch?v=xuhkHOAhXZ0 guides to learn SFML 2.0, but I've run into a problem.

It seems that there are some great differences between the version he's using and the RC, most of the problems so far I've been able to solve, but now I've hit a wall.

He uses a switch to get handle Events, and he has a piece of code that's like this:
1
2
3
4
5
6
7
8
9
10
while(Window.pollEvent(Event))
{
    switch(Event.type)
    {
        case sf::Event::Keypressed:
            std::cout << "A key was pressed." << std::endl;
            if(Event.Key.Code == sf::Key::Back)
                std::cout << "Backspace was pressed." << std::endl;
    }
}


The problem I'm facing is that neither Event.Key.Code nor sf::Key::Back exists anymore, so I can't register what key is being pressed. I have the same problem with registering individual mouse buttons.

What are you supposed to do in SFML 2.0 here?

- Jhuyt
Checking the SFML 2 Documentation would have solved your problem. Replace Event.Key.Code with : Event.key.code and replace sf::Key::Back with sf::Keyboard::Back.
http://www.sfml-dev.org/documentation/2.0/classsf_1_1Keyboard.php

This might be helpful.

edit:
http://www.sfml-dev.org/documentation/1.5/namespacesf_1_1Key.php#details

That might be what you were looking for, but using if-statements to check for input is (in my opinion) better than using a switch and poll the events.
Last edited on
Looking at the documentation pages, I think it should be Event.key.code and sf::Keyboard::Key::Back (or simply sf::Keyboard::Back).
Thank you, it worked.

I did look through the documentation and it solved many of the other problems I had, but this one I just couldn't find :/
Topic archived. No new replies allowed.