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

Author Topic: 'sf::Key' has not been declared  (Read 4650 times)

0 Members and 1 Guest are viewing this topic.

hagel

  • Newbie
  • *
  • Posts: 23
    • View Profile
'sf::Key' has not been declared
« 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 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;

}

Anata

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
'sf::Key' has not been declared
« Reply #1 on: December 18, 2011, 02:25:23 pm »
hello

With SFML2 , it's sf::Keyboard::Up for example and not key :)

hagel

  • Newbie
  • *
  • Posts: 23
    • View Profile
'sf::Key' has not been declared
« Reply #2 on: December 18, 2011, 02:46:04 pm »
Thanks, it totally works now.
The examples should probably be updated.

 

anything