animation.cpp 422 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#include <gui/animation.hpp>

void Animation::update(const utils::Duration& dt)
{
  this->time += dt;
  while (this->time >= this->frame_duration)
    {
      this->frame++;
      if (this->frame == this->number_of_frames)
        this->frame = 0;
      this->time -= this->frame_duration;
    }
}

std::size_t Animation::get_current_frame() const
{
  return this->frame;
}

void Animation::reset()
{
  this->frame = 0;
}