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

Author Topic: Input won't work  (Read 1256 times)

0 Members and 1 Guest are viewing this topic.

loadsaEmone

  • Newbie
  • *
  • Posts: 2
    • View Profile
Input won't work
« on: September 28, 2011, 07:59:27 pm »
Code: [Select]

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

int main()
{
    sf::RenderWindow App(sf::VideoMode(512, 512, 32), "WHY!");
    while(App.IsOpened())
    {
        if(App.GetInput().IsKeyDown(sf::Key::Escape))
        {
        std::cout << "dddd";

        }

        App.Display();
    }
}



I feel as if the above code should work, but it doesn't. Am I missing something obvious, because for the life of me I can't see what.

Serapth

  • Full Member
  • ***
  • Posts: 105
    • View Profile
Input won't work
« Reply #1 on: September 28, 2011, 08:20:06 pm »
You need to call getEvent in your loop.

Code: [Select]

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

int main()
{
    sf::RenderWindow App(sf::VideoMode(512, 512, 32), "WHY!");
    while(App.IsOpened())
    {
sf::Event ignoreMe;
App.GetEvent(ignoreMe);
        if(App.GetInput().IsKeyDown(sf::Key::Escape))
        {
        std::cout << "dddd";

        }

        App.Display();
    }
}

loadsaEmone

  • Newbie
  • *
  • Posts: 2
    • View Profile
Input won't work
« Reply #2 on: September 28, 2011, 08:25:54 pm »
Ah, I guess that makes sense. Thanks man.

 

anything