Hi, I have got a problem with animation. I added frames to thor::FrameAnimation and next added it to thor::animator. Everything what it do is showing only one frame. I researched my problem and found nothing. I am using current version of SFML and thor on Xcode on mac. Could you help me?
I cut out only a few lines of code. In project i have it in separate classes.
thor::Animator<sf::Sprite, std::string> animator;
thor::FrameAnimation moveLeft;
sf::Sprite sPlayer;
sPlayer.setTexture(Textures);
sPlayer.setTextureRect(sf::IntRect (362, 248, 37, 59)); //set starting texture
moveLeft.addFrame(1.f, sf::IntRect (320, 304, 42, 58));
moveLeft.addFrame(2.f, sf::IntRect (320, 186, 42, 59));
moveLeft.addFrame(3.f, sf::IntRect (320, 304, 42, 58));
moveLeft.addFrame(4.f, sf::IntRect (320, 186, 42, 59));
animator.addAnimation("moveLeft", moveLeft, sf::seconds(4));
while (window.isOpen()) // Start the game loop
{
ProcessEvents();
Render();
animator.playAnimation("moveLeft");
animator.update(Clock.restart());
animator.animate(sPlayer);
window.draw(sPlayer);
window.display();
window.clear();
}
}