Game Development Reference
In-Depth Information
Manipulating cameras with sf::View
Arguably, the most important feature of the View class is its ability to change the center of
the view area. By default, the center of the view is the center of the view area, which means
that, if our view area is of the size (640, 480), the center of the view will be (320, 240).
This makes the rendering objects with position ( 0 ; 0 ) appear in the top-left corner. This is
the same behavior we get when using the default View of a SFML window. To change the
center of the view we can call View::setCenter() or View::move() ; here is an
example:
If we center the view at position ( 0 ; 0 ), that position in the world will appear in the center
of the screen. The sprite in the code is positioned at ( 0 ; 0 ) by default, so it would appear in
the center of the screen; here is the result:
Search WWH ::




Custom Search