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

Author Topic: Moving a view with mouse  (Read 1070 times)

0 Members and 1 Guest are viewing this topic.

Chronos

  • Newbie
  • *
  • Posts: 5
    • View Profile
Moving a view with mouse
« on: November 08, 2019, 11:35:08 am »
Hi,

My function is working well but the mouse is moving a bit faster than the view and that's really ennoying  :-\ Is there a way to synchronize them ?
if (event.type == Event::MouseMoved) {
                                if (!moving || !checkMouseOnGameView(static_cast<Vector2f> (Mouse::getPosition(window)), window))
                                        break;
                                p1IconSprite.setColor(Color(0, 0, 0, 0));
                                const sf::Vector2f newPos = sf::Vector2f(event.mouseMove.x, event.mouseMove.y);
                                Vector2f deltaPos = oldPos - newPos;
                                deltaPos.x *= accumZoom;
                                deltaPos.y *= accumZoom;
                                gameView.move(deltaPos);
                                window.setView(gameView);
                                oldPos = newPos;
                        }
 

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: Moving a view with mouse
« Reply #1 on: November 08, 2019, 11:45:45 am »
did you try this from the tutorials?
Visit my game site (and hopefully help funding it? )
Website | IndieDB

Chronos

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Moving a view with mouse
« Reply #2 on: November 08, 2019, 12:01:57 pm »
did you try this from the tutorials?

You're probably right ! I'll try this later, it should solve my problem !  ;D

 

anything