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

Author Topic: Viewport not changing and stays at (0, 0)  (Read 1875 times)

0 Members and 1 Guest are viewing this topic.

MrSnappingTurtle

  • Newbie
  • *
  • Posts: 21
    • View Profile
    • Email
Viewport not changing and stays at (0, 0)
« on: August 16, 2014, 07:05:12 am »
Hi, I have the following code:

view.reset(sf::FloatRect(mainLevel->rooms[i]->roomSprite.getPosition().x, mainLevel->rooms[i]->roomSprite.getPosition().y, window.getSize().x, window.getSize().y));
window.setView(view);
std::cout << "Room Position: (" << mainLevel->rooms[i]->roomSprite.getPosition().x << ", " << mainLevel->rooms[i]->roomSprite.getPosition().y << ")" << std::endl;
std::cout << "Viewport: (" << window.getView().getViewport().left << ", " << view.getViewport().top << ")" << std::endl;
 

However, when I have the viewport position log, it is at (0, 0) when the room position is at (-75, -75). This happens even if I hardcode the (-75, -75) into it. Does anyone know why this happens? Thanks!

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: Viewport not changing and stays at (0, 0)
« Reply #1 on: August 16, 2014, 07:28:04 am »
The viewport defines the area where the view is displayed inside your window. It is set with the setViewport method.
It doesn't relate to the view position in the world.
« Last Edit: August 16, 2014, 07:33:13 am by G. »

 

anything