Add 2 utility functions: get the total time and the mean tempo of an animation.

This commit is contained in:
Ali El Gariani 2007-04-13 18:00:37 +00:00
parent f9ec829e7d
commit 40e84a0127
2 changed files with 19 additions and 0 deletions

View file

@ -176,6 +176,22 @@ int animated<T,T_void_value>::get_animation_time() const
return (int)(((double)(last_update_tick_ - start_tick_)*acceleration_)+starting_frame_time_);
}
template<typename T, typename T_void_value>
const int animated<T,T_void_value>::get_animation_duration() const
{
int duration = 0;
for (size_t i=0; i!=frames_.size(); i++) {
duration += frames_[i].duration_;
}
return duration;
}
template<typename T, typename T_void_value>
const int animated<T,T_void_value>::get_animation_tempo() const
{
return get_animation_duration() / get_frames_count();
}
template<typename T, typename T_void_value>
const T& animated<T,T_void_value>::get_current_frame() const
{

View file

@ -61,6 +61,9 @@ public:
bool animation_finished() const;
bool animation_would_finish() const;
int get_animation_time() const;
const int get_animation_duration() const;
// get the mean tempo (total duration / number of frames)
const int get_animation_tempo() const;
const T& get_current_frame() const;
// get the next frame (or the current + shift frames)
const T& get_next_frame(int shift = 1) const;