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

Author Topic: Center and Half Size  (Read 2775 times)

0 Members and 1 Guest are viewing this topic.

Wander

  • Full Member
  • ***
  • Posts: 170
    • View Profile
    • Email
Center and Half Size
« on: August 15, 2010, 04:26:36 am »
I was looking at the tutorials and saw the views page.

Code: [Select]
   sf::Vector2f Center(1000, 1000);
    sf::Vector2f HalfSize(400, 300);
    sf::View View(Center, HalfSize);

    View.SetCenter(500, 300);
    View.SetHalfSize(200, 100);


The page didn't actually tell me what these mean.

Also, what does the 'f' mean that we usually have to put after number parameters? ie. 4.0f
-Wander

Walker

  • Full Member
  • ***
  • Posts: 181
    • View Profile
Center and Half Size
« Reply #1 on: August 15, 2010, 07:30:38 am »
The easiest way to understand views is just by setting one up and playing with it.

Half size is literally half the size of the view. If you wanted to "see" a 500x500 area with your view, you would set half size to 250, 250.

The centre is basically the view's position (window coordinates).

Someone else might explain the f thing better (or tell me that I'm wrong lol) but it tells the compiler that it's a float type. I'm pretty sure that compilers will default to double precision (rather than single precision 'float' type) without the f. It's always good to be specific in your code. Although it doesn't seem to be an issue much of the time, it's a good habit.

Wander

  • Full Member
  • ***
  • Posts: 170
    • View Profile
    • Email
Center and Half Size
« Reply #2 on: August 15, 2010, 07:32:30 am »
Thanks! :D What is the Vector2f thing?
-Wander

Wander

  • Full Member
  • ***
  • Posts: 170
    • View Profile
    • Email
Center and Half Size
« Reply #3 on: August 15, 2010, 07:35:12 am »
Also, I've set up a view that is 7000x3000 and it has shrunk it down to size so I can see most of it. Whenever I start up the program it shows only the bottom right portion of the rectangle. I have to use a move command to move it so I can see the rest of it. Is there an easy way to make it start centered, or am I just going to have to play with the move() function?
-Wander

Walker

  • Full Member
  • ***
  • Posts: 181
    • View Profile
Center and Half Size
« Reply #4 on: August 15, 2010, 07:43:03 am »
http://www.sfml-dev.org/documentation/1.6/classsf_1_1Vector2.htm

The docs can answer a lot of questions.

Quote from: "Wander"
Also, I've set up a view that is 7000x3000 and it has shrunk it down to size so I can see most of it. Whenever I start up the program it shows only the bottom right portion of the rectangle. I have to use a move command to move it so I can see the rest of it. Is there an easy way to make it start centered, or am I just going to have to play with the move() function?


I don't really understand what you mean. You can use SetCenter() to set the position.

Wander

  • Full Member
  • ***
  • Posts: 170
    • View Profile
    • Email
Center and Half Size
« Reply #5 on: August 15, 2010, 07:52:18 am »
Okay. Thanks.

Quote
You can use SetCenter() to set the position.


Oops. I realized what I did. I had set center to the size of the rectangle and halfsize to the middle. Haha. Newbie mistake.

Thank you very much! :)
-Wander

 

anything