But if I set the Position of the Viewport the sprite is not longer drawed on the Window...
view.SetViewport(sf::FloatRect(400.0, 400.0, ..., ...)); // Sprite is not drawed
view.SetViewport(sf::FloatRect(1.0, 1.0, ..., ...)); // Sprite is not drawed
view.SetViewport(sf::FloatRect(0.0, 1.0, ..., ...)); // Sprite is not drawed
In the Documentation ->
// Initialize the view to a rectangle located at (100, 100) and with a size of 400x200
view.Reset(sf::FloatRect(100, 100, 400, 200));
// Set its target viewport to be half of the window
view.SetViewport(sf::FloatRect(0.f, 0.f, 0.5f, 1.f));
Thats why I thought that by the resetting Method, the first two parameters are the Position of the View
and thats why I think that I'm not doing wrong, but it seems like I do...
The code:
// ... Create Sprite with size (64, 64) ...
// The View
sf::View view;
// Reset it, and set it on the location (400, 400) with the size (64, 64)
view.Reset(sf::FloatRect(400, 400, 64, 64));
// Setting Viewport
view.SetViewport(sf::FloatRect(0.0, 0.0,
sprite.GetGlobalBounds().Width / App.GetWidth(),
sprite.GetGlobalBounds().Height / App.GetHeight()));
// Setting position after init the View...
sprite.SetPosition(400, 400);