Hi there,
Let's say I have a RectangleShape that I want to grow in height over time. In order to do that, in each call to my update() function I call setSize() with a new height and my shape grows nicely.
Now I have a texture that fills up the maximum size of my RectangleShape, but I only want to display parts of that texture as my rectangle grows. If I use setTextureRect() initially and set the maximum size of my RectangleShape, the texture will scale as the shape grows in height, which is expected but not exactly what I want.
I would really just like each resize of my shape to show more of the texture without scaling the texture.
I have tried to change the texture rectangle in each call to update by doing something like:
float height_increase = 2;
setSize({getSize().x, getSize().y + height_increase});
auto rect = getTextureRect();
rect.height += height_increase;
setTextureRect(rect);
With the initial size of the texture rectangle matching the initial size of my RectangleShape, but I couldn't really make it work and it also seems very "hackish" so I'm not really sure if this is the right way to go.
To make things slightly more complicated, I would really like to use the Animatior functionality from the very useful Thor library to animate my RectangleShape as it is growing in size, but that might not be that important to start with.
I can post a more complete example of what I'm trying to achieve if that makes it clearer, but I hope it's quite clear what I want to do and I feel like I'm approaching this the wrong way.
Any help or hints would be greatly appreciated as I'm fairly new to SFML and indeed to graphics/game programming in general.
Thanks a lot.