SFML community forums

Help => General => Topic started by: Chronos on November 08, 2019, 11:35:08 am

Title: Moving a view with mouse
Post by: Chronos 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;
                        }
 
Title: Re: Moving a view with mouse
Post by: Stauricus on November 08, 2019, 11:45:45 am
did you try this (https://www.sfml-dev.org/tutorials/2.5/graphics-view.php#coordinates-conversions) from the tutorials?
Title: Re: Moving a view with mouse
Post by: Chronos on November 08, 2019, 12:01:57 pm
did you try this (https://www.sfml-dev.org/tutorials/2.5/graphics-view.php#coordinates-conversions) from the tutorials?

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