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

Author Topic: Set fixed sprite position when sf::View is active?  (Read 2383 times)

0 Members and 1 Guest are viewing this topic.

5gum

  • Newbie
  • *
  • Posts: 27
    • View Profile
Set fixed sprite position when sf::View is active?
« 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

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10150
    • View Profile
    • development blog
    • Email
Re: Set fixed sprite position when sf::View is active?
« Reply #1 on: January 16, 2014, 03:30:29 pm »
Read the official tutorial. :)

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. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/

Rhimlock

  • Jr. Member
  • **
  • Posts: 73
    • View Profile
Re: Set fixed sprite position when sf::View is active?
« Reply #2 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);

5gum

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: Set fixed sprite position when sf::View is active?
« Reply #3 on: January 16, 2014, 03:42:37 pm »
Thanks to you both, it works, really easy :D