SFML community forums

Help => Graphics => Topic started by: vEjEsE on August 03, 2010, 11:16:02 pm

Title: View and view moving
Post by: vEjEsE on August 03, 2010, 11:16:02 pm
Is there any way to make an object stick to the window, like saying in a RTS game a menu bar and minmap are in the same position related to the window's coordinates even though the background is moving.

I know that the mouse's coordinates dosen't depend on the view's transformation, but I don't see how I could use that...


So, besides moving the menu with the view, is there an other way?
Title: View and view moving
Post by: lotios611 on August 03, 2010, 11:41:32 pm
Here's some sample code.
Code: [Select]
sf::View example;
App.SetView(example);
//Draw the stuff that scrolls
App.SetView(App.GetDefaultView());
//Draw the HUD
Title: View and view moving
Post by: vEjEsE on August 03, 2010, 11:50:11 pm
That code draws the things that are in the view and then goes back to the view's default position, right?

Isn't that CPU expensive? And wouldn't it draw the scrolling backgrond objects from the default position?


-- Thanks for the quick answer.
Title: View and view moving
Post by: lotios611 on August 04, 2010, 12:05:31 am
Quote from: "vEjEsE"
That code draws the things that are in the view and then goes back to the view's default position, right?

Isn't that CPU expensive? And wouldn't it draw the scrolling backgrond objects from the default position?

I'm not sure how it's implemented, but I think that its just a simple variable change which would mean that it's not that CPU expensive. It's mentioned in the tutorial (http://www.sfml-dev.org/tutorials/1.6/graphics-views.php).
Quote from: "yEjEsE"
-- Thanks for the quick answer.
No problem.
Title: View and view moving
Post by: Laurent on August 04, 2010, 08:52:01 am
Indeed, views are almost free to use.