diff options
author | Max-001 <maxsmits21@kpnmail.nl> | 2024-12-24 10:51:26 +0100 |
---|---|---|
committer | Max-001 <maxsmits21@kpnmail.nl> | 2024-12-24 10:51:26 +0100 |
commit | 0bfc194d2c31d111ad438c040d4b0b74238d4ef6 (patch) | |
tree | db880034cb7e679ce6f0979c40b02b16049a09e5 /src | |
parent | 2691f8ef665d38f04d6aa8f38681b68ca0c852ea (diff) |
Stop looping at last frame instead of start frame
Diffstat (limited to 'src')
-rw-r--r-- | src/crepe/system/AnimatorSystem.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/crepe/system/AnimatorSystem.cpp b/src/crepe/system/AnimatorSystem.cpp index e5ab2fa..0a5a417 100644 --- a/src/crepe/system/AnimatorSystem.cpp +++ b/src/crepe/system/AnimatorSystem.cpp @@ -1,6 +1,7 @@ #include "../api/Animator.h" #include "../manager/ComponentManager.h" #include "../manager/LoopTimerManager.h" +#include "util/Log.h" #include <chrono> #include "AnimatorSystem.h" @@ -29,12 +30,13 @@ void AnimatorSystem::frame_update() { int curr_frame = static_cast<int>(elapsed_time / frame_duration) % total_frames; - ctx.row = ctx.cycle_start + curr_frame; - a.spritesheet.mask.x = ctx.row * a.spritesheet.mask.w; - a.spritesheet.mask.y = (ctx.col * a.spritesheet.mask.h); - if (!ctx.looping && curr_frame == ctx.cycle_start && last_frame == total_frames - 1) { a.active = false; + continue; } + + ctx.row = ctx.cycle_start + curr_frame; + a.spritesheet.mask.x = ctx.row * a.spritesheet.mask.w; + a.spritesheet.mask.y = (ctx.col * a.spritesheet.mask.h); } } |