Hello
as the title say how can i stop scrolling when i reach a certain position?
#include <SFML/Graphics.hpp>
#include <iostream>
int main()
{
sf::RenderWindow App(sf::VideoMode(800, 600), "SFML Views");
sf::Image BackgroundImage;
if (!BackgroundImage.LoadFromFile("background.png"))
return EXIT_FAILURE;
sf::Sprite Background1(BackgroundImage);
Background1.SetPosition(0, 0);
sf::Sprite Background2(BackgroundImage);
Background2.SetPosition(500, 0);
sf::Sprite Background3(BackgroundImage);
Background3.SetPosition(0, 500);
sf::Sprite Background4(BackgroundImage);
Background4.SetPosition(500, 500);
sf::Vector2f Center(500, 500);
sf::Vector2f HalfSize(400, 300);
sf::View View(Center, HalfSize);
while (App.IsOpened())
{
sf::Event Event;
while (App.GetEvent(Event))
{
}
float Offset = 200.f * App.GetFrameTime();
if(App.GetInput().GetMouseX() <=100) View.Move(-Offset, 0);
if(App.GetInput().GetMouseX() >=700) View.Move( Offset, 0);
if(App.GetInput().GetMouseY() <=100) View.Move( 0, -Offset);
if(App.GetInput().GetMouseY() >=500) View.Move( 0, Offset);
App.SetView(View);
App.Clear();
App.Draw(Background1);
App.Draw(Background2);
App.Draw(Background3);
App.Draw(Background4);
App.SetView(App.GetDefaultView());
App.Display();
}
return 0;
}