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

Author Topic: q: how to use the sf:view correctly?  (Read 1222 times)

0 Members and 1 Guest are viewing this topic.

mudale222

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
q: how to use the sf:view correctly?
« on: June 01, 2015, 04:46:40 pm »
I defined the size of the window as (800,650) and i have image of (1439,659).
I want to see just part of the image so that i can move a little to the sides and still be on the image.
What that happen is that instead of showing just the part of the image it's squeezing almost the whole image into the screen.

code:
sf::View view(sf::Vector2f(middle_x, middle_y), sf::Vector2f(window.getSize().x, window.getSize().y));
view.setSize(WINDOW_X_LENGTH, WINDOW_Y_LENGTH - 50);
 

when middle_x and middle_y is the center of the image.

DarkRoku12

  • Full Member
  • ***
  • Posts: 203
  • Lua coder.
    • View Profile
    • Email
Re: q: how to use the sf:view correctly?
« Reply #1 on: June 01, 2015, 07:06:50 pm »
you need to consider "view" as a diferent window.

First , in the window localize the point: middle_x , middle_y , then draw a rectangle with the size WINDOW_X_LENGTH, WINDOW_Y_LENGTH - 50 and put the center of this rectagle in middle_x , middle_y and that its your new window.

suposse this example:

window size( 800 , 650 ) ( 800 , 650 - 50 = 800 , 600 view size ) 
image size ( 1440 , 660 )
center of the image (  720 , 330 ) ( center of the view )
And mi profile avatar rendered with the view. ( positionated in 0,0 )

See attachment.
« Last Edit: June 01, 2015, 07:09:13 pm by DarkRoku »
I would like a spanish/latin community...
Problems building for Android? Look here