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

Author Topic: Set fixed sprite position when sf::View is active?  (Read 3458 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: 11030
    • 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
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

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

 

anything