SFML community forums

Help => General => Topic started by: hagel on December 18, 2011, 02:15:48 pm

Title: 'sf::Key' has not been declared
Post by: hagel on December 18, 2011, 02:15:48 pm
So I just recently built SFML2 and wanted to familiarize myself with the new stuff.
There I was, making a super simple program when it started complaining about sf::Key not being declared. I just thought that I made a typo or something but then I copy-pasted the code from here (http://sfml-dev.org/documentation/2.0/classsf_1_1Event.php) and it still complained.

What's the deal?

Here's what I got so far.

Code: [Select]

#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

#include <iostream>




int main(){


    sf::RenderWindow mainWindow(sf::VideoMode(800, 600,32), "SFML window");
    mainWindow.Clear(sf::Color(46,40,35));


    sf::Text text;
    text.SetString("TEXT FOR THE SCREEN");
    text.SetPosition(200,200);

    mainWindow.Draw(text);
    mainWindow.Display();

    while(true){
        sf::Event currentEvent;
        mainWindow.PollEvent(currentEvent);
        if(currentEvent.Type == sf::Event::Closed){
            return EXIT_FAILURE;
        }

        if ((currentEvent.Type == sf::Event::KeyPressed) && (currentEvent.Key.Code == sf::Key::Escape)){ // here's the problem
            printf("%i\n", currentEvent.Key.Code);
            return EXIT_SUCCESS;
        }
    }


    return EXIT_SUCCESS;

}
Title: 'sf::Key' has not been declared
Post by: Anata on December 18, 2011, 02:25:23 pm
hello

With SFML2 , it's sf::Keyboard::Up for example and not key :)
Title: 'sf::Key' has not been declared
Post by: hagel on December 18, 2011, 02:46:04 pm
Thanks, it totally works now.
The examples should probably be updated.