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

Author Topic: Moving the sf::View at the same rate that the player moves  (Read 645 times)

0 Members and 1 Guest are viewing this topic.

Clockwork

  • Newbie
  • *
  • Posts: 47
    • View Profile
Moving the sf::View at the same rate that the player moves
« on: July 06, 2014, 11:27:21 pm »
I want to make a sidescroller, but I ran into the problem where it seems unnecessarily complicated to get the camera to move at the same rate as the player.  If I do this:

view.move(sf::Vector2f(Speed, 0.f));

The camera moves significantly faster than the player, how can I match them up?

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Moving the sf::View at the same rate that the player moves
« Reply #1 on: July 06, 2014, 11:31:56 pm »
Why not just...
view.setCenter(player.getPosition());
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Clockwork

  • Newbie
  • *
  • Posts: 47
    • View Profile
Re: Moving the sf::View at the same rate that the player moves
« Reply #2 on: July 06, 2014, 11:38:42 pm »
That's what I love about programming, there's always a better way to solve a problem.

Thanks, I was over-thinking it again.