Hello,
I want to use the sf::view class in sfml 2.0 to be able to implement a kind of camera in my application.
I started to implement what I wanted in sfml 1.6 but for many reasons I switch to sfml 2.0. My implementation of views worked well with the sfml 1.6, but it doesn't in 2.0. I can't move the view, I don't know why.
Here is the piece of code :
while (_app->isOpen())
{
while (_app->pollEvent(event))
{
if (event.type == sf::Event::Closed)
_app->close();
if (event.type == sf::Event::KeyPressed)
{
float Offset = 200.f; // I need to change that. I know :-)
if (event.key.code == sf::Keyboard::Up) _view.move( 0, -Offset);
if (event.key.code == sf::Keyboard::Down) _view.move( 0, Offset);
if (event.key.code == sf::Keyboard::Left) _view.move(-Offset, 0);
if (event.key.code == sf::Keyboard::Right) _view.move( Offset, 0);
}
}
_app->clear();
// Here come the function that draw my sprites...
_app->display();
}
With that kind of code, I am suppose to move the view. Apparently, the view move pretty well (I tested by getting the coordonates of the center of the view which is modified when I press a key), but on the window nothing happen.
Can you explain me why ?
Thank you.