SFML community forums

Help => Window => Topic started by: phoekz on April 08, 2011, 09:39:01 am

Title: [SOLVED]Trying to create HUD on View (more elegant solution)
Post by: phoekz 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.
Title: [SOLVED]Trying to create HUD on View (more elegant solution)
Post by: Laurent 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.
Title: [SOLVED]Trying to create HUD on View (more elegant solution)
Post by: phoekz on April 08, 2011, 10:20:14 am
Oh man, that was insanely simple, can't believe I missed that.