From 0bfc194d2c31d111ad438c040d4b0b74238d4ef6 Mon Sep 17 00:00:00 2001 From: Max-001 Date: Tue, 24 Dec 2024 10:51:26 +0100 Subject: Stop looping at last frame instead of start frame --- src/crepe/system/AnimatorSystem.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/crepe') 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 #include "AnimatorSystem.h" @@ -29,12 +30,13 @@ void AnimatorSystem::frame_update() { int curr_frame = static_cast(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); } } -- cgit v1.2.3