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

Author Topic: [SOLVED]Trying to create HUD on View (more elegant solution)  (Read 1963 times)

0 Members and 1 Guest are viewing this topic.

phoekz

  • Newbie
  • *
  • Posts: 14
    • View Profile
[SOLVED]Trying to create HUD on View (more elegant solution)
« on: April 08, 2011, 09:39:01 am »
What I'm trying to do is simply have text on View so it will move when the View moves as well. I have accomplished by setting the text's position relative to View's center position, like this:

Code: [Select]
CountFPS.Update();
float x = View.GetCenter().x - 510;
float y = View.GetCenter().y - 388;
Text.SetPosition(x, y);
Text.SetText(CountFPS.GetFPS());
Screen->Draw(Text);


It is quite hacky in my opinion and requires lot of pixel perfection to get it right, also when I want more elements to the HUD, it will be quite a mess. Is there some more cleaner/elegant way to do this?

Thanks in advance.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
[SOLVED]Trying to create HUD on View (more elegant solution)
« Reply #1 on: April 08, 2011, 09:51:40 am »
Use another view, that never moves, and draw your text with it. That's what views are for.
Laurent Gomila - SFML developer

phoekz

  • Newbie
  • *
  • Posts: 14
    • View Profile
[SOLVED]Trying to create HUD on View (more elegant solution)
« Reply #2 on: April 08, 2011, 10:20:14 am »
Oh man, that was insanely simple, can't believe I missed that.

 

anything