Hi,
So in my header file for the player I have this code:
const std::array<sf::IntRect, 3> INTERACT
{{
sf::IntRect(11, 0, 11, 10),
sf::IntRect(22, 0, 11, 10),
sf::IntRect(11, 0, 11, 10)
}};
And then in the source file I have this inside the update function:
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space) && animationState != interact)
{
animationState = interact;
for (int i = 0; i < INTERACT.size(); i++)
{
sf::Clock frameTimer;
sprite.setTextureRect(INTERACT[i]);
std::cout << "Sprite: " << i << "should have changed..." << std::endl;
//Waits to iterate the next frame
while (frameTimer.getElapsedTime().asMilliseconds() < 100) {}
}
animationState = idle;
std::cout << "done!";
}
Now, the problem is that the sprite.setTextureRect(INTERACT(i)) part does not work. The cout does run so I know that the function is being called. If I hold down the spacebar, however, it will eventually be showing just the last frame. Is there something obvious that I'm missing?