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

Author Topic: Can't get view to move  (Read 1325 times)

0 Members and 1 Guest are viewing this topic.

Gauzr

  • Newbie
  • *
  • Posts: 20
    • View Profile
Can't get view to move
« on: June 06, 2015, 01:28:23 pm »
Sorry this is such a basic problem, but I can't seem to get the view in my game to move. I created the view and defined it, but when I move it in the game loop, nothing happens.



sf::RenderWindow window(sf::VideoMode(600, 600), "SFML");

sf::View view;
view.setSize(sf::Vector2f(600, 600));
view.setCenter(sf::Vector2f(300, 300));
                 
window.setView(view);


...

view.move(100, 0);
       


 
« Last Edit: June 06, 2015, 01:30:44 pm by Gauzr »

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Can't get view to move
« Reply #1 on: June 06, 2015, 01:53:53 pm »
When you call setView, it stores a copy of the view, not a reference or a pointer to the view. As such, you must call setView again after moving the view.

Gauzr

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Can't get view to move
« Reply #2 on: June 06, 2015, 02:05:11 pm »
Ah of course, that makes sense - thanks