SFML community forums

Help => General => Topic started by: 5gum on January 16, 2014, 03:23:21 pm

Title: Set fixed sprite position when sf::View is active?
Post by: 5gum on January 16, 2014, 03:23:21 pm
Hey guys,

I prog a game and use sf::view for the map. But now I want something like a header for general information (money...) which is always on the top of the screen. With setPoistion(10,10) the sprite is just on the top of the map, not of the screen...

So what I have to do?

Thanks a lot,
5gum
Title: Re: Set fixed sprite position when sf::View is active?
Post by: eXpl0it3r on January 16, 2014, 03:30:29 pm
Read the official tutorial (http://www.sfml-dev.org/tutorials/2.1/graphics-view.php). :)

You can use multiple views, one that is for the map and one that is for the HUD and you simply set one draw things, set the other, draw the other stuff. ;)
Title: Re: Set fixed sprite position when sf::View is active?
Post by: Rhimlock on January 16, 2014, 03:32:06 pm
You have to use one view for the map and one view for the HUD.

Something like this:

window.setView(viewMap);
window.draw(map);
window.setView(viewHUD);
window.draw(sprite);
Title: Re: Set fixed sprite position when sf::View is active?
Post by: 5gum on January 16, 2014, 03:42:37 pm
Thanks to you both, it works, really easy :D