Hi, I am trying to make a platform game, and have made an animation sprite, and a scrolling background by myself. I tried to make a scrolling background when I am walking backwards but I can't make it. Here is the relevant code. How can I make it so it will scroll if i walk backwards?
void main_game::ScrollingBackground(){
if (background1->getPosition().x < -background1->getGlobalBounds().width){
std::cout << "Out on the right side\n";
this->background1->setPosition(sf::Vector2f(this->background1->getGlobalBounds().width - 1, -50));
}
else if (background2->getPosition().x < -background2->getGlobalBounds().width){
std::cout << "Out on the right side\n";
this->background2->setPosition(sf::Vector2f(this->background2->getGlobalBounds().width - 1, -50));
}
}