For my side scroller, I need a camera that always centers on my player's position.
I have 3 questions regarding the use of sf::View:
In my player's update function, I create a view, set its center to the player's position, and set it as the window's view.
sf::View v(sf::FloatRect(0, 0, 320, 240));
v.setCenter(player_.getPosition());
window_->setView(v);
1.) I tried using the view as an sf::View class member but it didn't work, so now I'm creating the view every tick as seen in the code above. Is that how it is supposed to be done, or should I be wary of how resource intensive it may be, aka what is the correct way to do it?
2.) Now that I have the view that is smaller than the entire map, not all information is displayed anymore. For example I had a UI (displaying hit points and stuff) and an FPS display in my window's corners which I now can't see anymore unless my player, ie the view, is near it. Do I have to use multiple views or something to display everything?
3.) Due to using a view it's not necessary anymore to render the entire map, but only what is seen in the view. Is that done automatically or do I need to somehow program myself what is to be rendered?
I would appreciate any help on this
Thank you!