Let me preface this by saying that I am by no means a professional at C++ or SFML, and I'm probably just doing something stupid.
Here's an excerpt of what I have:
IntRect spriteanimation(Sprite sprite, IntRect selection) {
//every 1/4 second, move an image right on the sprite sheet- if its at the end
//of the animation, reset to initial position
if (selection.left >= 32 * 3) {
selection.left = 0;
}
else {
selection.left += 32;
}
if (isspritehovered(sprite) == true && selection.top <= 32) {
selection.top += 32;
}
else if (selection.top > 0) {
selection.top -= 32;
}
return selection;
}
void main() {
while (renderWindow.isOpen()) {
if (sec.getElapsedTime().asSeconds() > .25) {
henrysprite.setTextureRect(spriteanimation(henrysprite, henryselection));
lucinasprite.setTextureRect(spriteanimation(lucinasprite, lucinaselection));
sec.restart();
}
renderWindow.draw(henrysprite);
renderWindow.draw(lucinasprite);
}
}
Now, what I can't understand is that moving the selection down 32 works perfectly fine and affects the animation, but moving the selection left doesn't work at all. Any help would be much appreciated. I'm a beginner, so go easy on me please.