SFML community forums
Help => Window => Topic started by: Metaby on June 24, 2008, 07:22:15 pm
-
Hello, since i downloaded and used sfml 1.3, it looks like that my input's dont workt..
in sfml 1.2 i used input:
void Player::MainMenu(RenderWindow *Game)
{
MousePosX = Game->GetInput().GetMouseX();
MousePosY = Game->GetInput().GetMouseY();
// ... my quellcode
}
this worked in sfml 1.2 very good!
but in sfml 1.3 my programm dont react on any input event
no key control
no mouse control
....
i looked into the Doc and the Tutorials but i don't get it working!
Im working on Windows XP Prof. with Visual Studio 2005 Express Edition
please need help >.<
and sorry for my bad english :P
-
I've got exactly the same problem since sfml 1.3.
I'm working on Ubuntu 8.04 with g++.
-
I'm using the same code you are to get hold on the mouse position, works perfectly (SFML 1.3).
-
hm.. ok, it seems like, that my RenderWindow hangs-up
my console works although..
have anybody an idea?
need help pls..
-
i dont know if you are having the same problem as me, if you look at the recent thread about "mouse coords out until resize" you can see what i am experiencing, i am going to try sort it out this weekend,
just to check, are you running in fullscreen? or desktopmode?? i have experienced problems with these specifically and am trying to track down the bug.
-
I don't know whether any two of us have got the same problem. :roll: But after having played around with my code I have found at least a solution for me. Maybe it helps one of you ...
Following function does not work how I want it to (it always returns false):
bool IsADown()
{
const sf::Input& input = myWindow->GetInput(); // myWindow is a pointer to my RenderWindow
if( input.IsKeyDown(sf::Key::A) )
{
return true; // never happens
}
return false;
}
Note: The Input instance always seems to return default values (all keys are released, mouse coordinates are 0/0, etc.)
If I expand my function with some (in my eyes needless) code, it works flawlessly:
bool IsADown()
{
sf::Event event;
myWindow->GetEvent(event); // this seems to make the difference
const sf::Input& input = myWindow->GetInput();
if( input.IsKeyDown(sf::Key::A) )
{
return true; // now it works perfectly
}
return false;
}
Question: Is it really intentional that one has to call GetEvent(event) before accessing the Input instance?
Apart from that: Great library, I love it! Keep up the great work :)
-
Hi,
yeap it's intentional. If you don't call GetEvent, Input array (mouse position, keys states etc) will never be updated, so whether you use or not Event structure, you must call GetEvent in your game loop. =)
-
Yeah! Thanks all =D
it works =D