sf::View view;
view.reset(sf::FloatRect(0,0, screenDimensions.x, screenDimensions.y));
view.setViewport(sf::FloatRect(0,0, 1.0f, 1.0f));
sf::Vector2f position(screenDimensions.x / 2, screenDimensions.y / 2);
if(animatedSprite.getPosition().x + 16 > screenDimensions.x / 2)
position.x = animatedSprite.getPosition().x + 16;
else
position.x = screenDimensions.x / 2;
if(animatedSprite.getPosition().y + 16 > screenDimensions.y / 2)
position.y = animatedSprite.getPosition().y + 16;
else
position.y = screenDimensions.y / 2;
view.setCenter(position);
window.setView(view);
I keep trying to keep the camera from going off the background by tracking the sprite, but that obviously was not working right!
If I understood you right, you want to stop the camera once it would potentially leave the background texture, is that right?
Yes, that is exactly what I am trying to do. Keeping everything a variable that can change with the size of the map.