diff options
Diffstat (limited to 'src/crepe')
-rw-r--r-- | src/crepe/api/Animator.h | 2 | ||||
-rw-r--r-- | src/crepe/system/AnimatorSystem.cpp | 9 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/crepe/api/Animator.h b/src/crepe/api/Animator.h index efc2f6e..95539d3 100644 --- a/src/crepe/api/Animator.h +++ b/src/crepe/api/Animator.h @@ -1,7 +1,7 @@ #pragma once -#include "../types.h" #include "../manager/LoopTimerManager.h" +#include "../types.h" #include "Component.h" #include "Sprite.h" diff --git a/src/crepe/system/AnimatorSystem.cpp b/src/crepe/system/AnimatorSystem.cpp index 1a0cde9..ec9a445 100644 --- a/src/crepe/system/AnimatorSystem.cpp +++ b/src/crepe/system/AnimatorSystem.cpp @@ -34,14 +34,15 @@ void AnimatorSystem::frame_update() { int total_frames = cycle_end - ctx.cycle_start; int curr_cycle_frame = (a.frame - ctx.cycle_start) % total_frames; + if (!ctx.looping && a.frame >= cycle_end) { + a.active = false; + continue; + } + ctx.row = (ctx.cycle_start + curr_cycle_frame) % a.grid_size.x; ctx.col = curr_cycle_frame / a.grid_size.x; a.spritesheet.mask.x = ctx.row * a.spritesheet.mask.w; a.spritesheet.mask.y = ctx.col * a.spritesheet.mask.y; - - if (!ctx.looping && a.frame >= cycle_end) { - a.active = false; - } } } |