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

Author Topic: View and view moving  (Read 2283 times)

0 Members and 1 Guest are viewing this topic.

vEjEsE

  • Newbie
  • *
  • Posts: 28
    • View Profile
View and view moving
« 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?

lotios611

  • Newbie
  • *
  • Posts: 32
    • View Profile
View and view moving
« Reply #1 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

vEjEsE

  • Newbie
  • *
  • Posts: 28
    • View Profile
View and view moving
« Reply #2 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.

lotios611

  • Newbie
  • *
  • Posts: 32
    • View Profile
View and view moving
« Reply #3 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.
Quote from: "yEjEsE"
-- Thanks for the quick answer.
No problem.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
View and view moving
« Reply #4 on: August 04, 2010, 08:52:01 am »
Indeed, views are almost free to use.
Laurent Gomila - SFML developer