SFML community forums
Help => Window => Topic started by: evilertoaster on February 11, 2008, 05:48:52 am
-
Per Subject-
I'm trying to make the current mouse position display in my render window for debuging purposes.
Essentially I have this for my main loop-
sf::Input inpt;
sf::String text("","arial.ttf",16.f);
while (1)
{
text.SetText(Convert::toString(inpt.GetMouseX())); //custom conversion works fine, GetMouseX only returns a 0
DoEvents(App); //handles things like window closing ect.
App.Draw(sprScreen); //my main screen
App.Draw(text)
App.Display();
}
Short of posting all the code here, is there anything inherently wrong with trying to get the mouse coordiantes this way?
-
Can we see the DoEvents function ?
-
sure thing-
bool DoEvents(sf::RenderWindow &App)
{
sf::Event Event;
while (App.GetEvent(Event))
{
if (Event.Type == sf::Event::Closed)
exit(0);
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
exit(0);
}
return true;
}
-
How do you initialize inpt ?
-
the first line of code on my intial post is the first and only time I initalize it.
-
Really ? So that explains the behavior.
Try this instead ;)
const sf::Input& inpt = App.GetInput();
-
Works like I wanted. Thanks Laurent.
Actually, thats more what I wanted initially I think...
I kept trying sf::Input::GetMouseX()
but I beleive App.GetInput().GetMouseX()
is what I was after :?
Although now looking at it maybe I'll just declare a variable like....
Well anyways, thanks agian :D