spacebox/src/Animation.hpp

39 lines
764 B
C++

#ifndef Animation_h_
#define Animation_h_
#include <vector>
#include <functional>
#include <algorithm>
#include "Timer.hpp"
typedef std::function<void()> callback;
struct Animation
{
bool playing = false, ending = false, paused = false;
int previous_step_time = 0, overflow = 0, count = 0;
float delay = 0, frame_length;
callback step;
Timer timer = Timer();
template<typename T>
Animation(void(T::*f)(), T* o, float frame_length = 0) : frame_length(frame_length)
{
step = std::bind(f, o);
timer.toggle(false);
}
void set_frame_length(float);
void play(float = 0, bool = false);
void play_once(float = 0);
void pause();
void unpause();
void reset();
void update();
};
#endif