Hey,
I'm a beginner in SFML so please don't be too strict.
I painted a simple rect (Size:20*60px) and included it in my program.
Now I want that the y-position of the rect gets smaller every frame (Like a loading bar).
I tried it with
rect_timer = 0;
while(window.isOpen())
{
rect_timer += 0.1;
rect.setTextureRect(sf::IntRect(0,rect_timer,20,60-rect_timer));
}
But the result was, that my rect moves in the wrong direction, so the lowest part dissapeared at first but I want that the toppest part dissapeares at first.
How can I do that?
Thanks, 5gum
try moving the top of the texture rect:
int amount = 60 - rect_timer;
rect.setTextureRect(sf::IntRect(0, 60 - amount, 20, amount));
it's also good practice to get rid of all those magic numbers, perhaps with some const values