The class looks primarily good, I like that you use RAII and don't inherit from sf::Sprite ;)
Still some advice, as requested:
Make your code const-correct. Top-level CV qualifiers for parameters like const std::size_t n are useless, as explained here (http://en.sfml-dev.org/forums/index.php?topic=2767.msg18197#msg18197).
std::size_t getSize();
// -->
std::size_t getSize() const;
sf::IntRect& getFrame(const std::size_t n);
// ->
sf::IntRect getFrame(std::size_t n) const; // or
const sf::IntRect& getFrame(std::size_t n) const;
And if the animation isn't modified in the animated sprite, you can make the pointers and references to it const, too.
AnimatedSprite's constructor should be explicit, and you should initialize everything in its initializer list. Also, it's not exactly clear in which cases you cast int to float... Basically, there exists an implicit conversion, but to make it expressive in the code, you can (but don't have to) use static_cast.
The constructor is currently declared as follows. It can be called with 0, 1, 2, or 3 arguments.AnimatedSprite(sf::Time frameTime = sf::seconds(0.2), bool paused = false, bool looped = true);
Every constructor that can be invoked with 1 argument provides an implicit conversion of the argument to the object. In your example, the following code works:
sf::Time time = sf::seconds(5);
AnimatedSprite sprite = time;
This is certainly not intended, and a potential source of errors. By using the explicit keyword, you make the conversion explicit. The above code won't compile anymore, instead you have to use the constructor syntax:
sf::Time time = sf::seconds(5);
AnimatedSprite sprite(time);
Hey Foaly.
Thanks for the class! Helped me a lot as a beginner :)
There's a mystype if AnimatedSprite.cpp here, should be with newFrame,:
void AnimatedSprite::setFrame(std::size_t newFrame, bool resetTime)
{
...
sf::IntRect rect = m_animation->getFrame(newFrame);
...
}
I also attached modified version with backwards loop added and the formentioned piece fixed, if you're interested. And I also changed it so it stops at the last frame, because I thought this is correct way. Don't know for sure though.