SFML community forums
Help => Graphics => Topic started by: N_K on September 18, 2012, 06:28:54 am
-
Hi all,
Is there a way to draw text/sprites onto an sf::View? I use the view as a camera, instead of scrolling the game map, I move the viewport. But when I try to display some text, it will be drawn on the map, not on the viewport, and it will go out of sight when I move the camera. Or do I have to transform the text element(s) at the same speed and in the same direction as the viewport itself?
-
Use a second view which remains stationary to draw your UI.
-
Thanks, although I've gone a different way, I've found out that this is explained in View.hpp: set up the camera, draw the things that are supposed to be observed through the camera, then use renderWindow.setView(renderWindow.getDefaultView()) to return to the default view, then draw the things that are supposed to be drawn on the screen.
-
This is the same as thePyro_13 suggested, you use a second view that is stationary, in your case the default view. ;)
Keep in mind that if you resize the window the code might 'break', since the dedault view doesn't change with the window size.