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

Author Topic: Good Way To "Lock" Something To A View  (Read 1600 times)

0 Members and 1 Guest are viewing this topic.

jdogg2727

  • Newbie
  • *
  • Posts: 3
    • View Profile
Good Way To "Lock" Something To A View
« on: March 12, 2017, 06:53:01 pm »
So I looked around for a good way to basically attach something to a view, but I couldn't find any great solutions.

Right now I'm trying to draw a tool box with text and images over top the rest of my editor for I can see information without it looking like a mess. Each frame the view moves I have to reset the position of the tool box, each image, and each text object.

if(*view moves*){
*update positioning for each object* //I don't want this step :(
...
...
}

draw(*object*)
...
...

Is there a way I can simply "attach" these to the view? Or would I maybe be better off drawing each of these to an image, positioning the image and then drawing that?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Good Way To "Lock" Something To A View
« Reply #1 on: March 12, 2017, 07:16:01 pm »
Just use another view that doesn't change.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

dratone

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Good Way To "Lock" Something To A View
« Reply #2 on: March 14, 2017, 05:16:29 pm »
That would be the way i'd do it aswel. In my case I've created 2 views: The GameView (For seeing the world) and a UIView. The UI view I use to draw non-world related UI elements (i.e. UI elements that shouldn't be attached to a specific in-world object).

To switch between views you can use the window.setView() function:

http://www.sfml-dev.org/documentation/2.4.2/classsf_1_1RenderTarget.php#a063db6dd0a14913504af30e50cb6d946

 

anything