I have been trying to solve this for the past hour and I just can't fix it. Whenever I run this the sprite loads on the screen, but when I click the sprite repeats itself every 10 pixels and starts to flash. It seems like when I click, the sprite moves forever.
EDIT::
I added window.clear(); before I draw the sprite, but now it still seems like the sprite is moving multiple times from one mouse click.
int main()
{
sf::Texture text1;
text1.loadFromFile("first.png");
sf::Sprite sprite1;
sprite1.setTexture(text1);
sprite1.setOrigin(0,0);
sf::RenderWindow window(sf::VideoMode(400, 250), "Preamble", sf::Style::Default);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
if (event.type == sf::Event::MouseButtonPressed)
sprite1.move(10,0);
window.clear();
window.draw(sprite1);
window.display();
}
return 0;
}