parent
b87217ff90
commit
d0d3c8bc04
@ -1,2 +1,18 @@ |
|||||||
#include "animator.hpp" |
#include "animator.hpp" |
||||||
#include "constants.hpp" |
#include "constants.hpp" |
||||||
|
|
||||||
|
void Animator::step(sf::Sprite& sprite, int rect_x, int rect_y, int rect_w, int rect_h) { |
||||||
|
if(playing) { |
||||||
|
count++; |
||||||
|
frame = ((count / 4) % max_frames); |
||||||
|
playing = frame != 0; |
||||||
|
} |
||||||
|
|
||||||
|
sprite.setTextureRect(sf::IntRect({ |
||||||
|
{rect_x + frame * width, rect_y}, |
||||||
|
{rect_w, rect_h}})); |
||||||
|
} |
||||||
|
|
||||||
|
void Animator::play() { |
||||||
|
playing = true; |
||||||
|
} |
||||||
|
Loading…
Reference in new issue