diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-12-03 10:40:37 +0100 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-12-03 10:40:37 +0100 |
commit | 683ae28b81a66f18bbadbe7ae70eb8ddd952c293 (patch) | |
tree | b183b92bc41a3cb80db5ea132d9d612095690c9f /src | |
parent | 9f243b9a7a19cc626e787cd71c83e3c3225018b9 (diff) |
fixed the one cycle aimatorsystem where it did not do the last frame_for the full duration
Diffstat (limited to 'src')
-rw-r--r-- | src/crepe/system/AnimatorSystem.cpp | 4 | ||||
-rw-r--r-- | src/example/rendering_particle.cpp | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/crepe/system/AnimatorSystem.cpp b/src/crepe/system/AnimatorSystem.cpp index 9cf8ba5..e9cdd4c 100644 --- a/src/crepe/system/AnimatorSystem.cpp +++ b/src/crepe/system/AnimatorSystem.cpp @@ -20,6 +20,8 @@ void AnimatorSystem::update() { Animator::Data & ctx = a.data; double frame_duration = 1.0f / ctx.fps; + int last_frame = ctx.curr_row; + int cycle_end = (ctx.cycle_end == -1) ? ctx.row : ctx.cycle_end; int total_frames = cycle_end - ctx.cycle_start; @@ -29,7 +31,7 @@ void AnimatorSystem::update() { ctx.spritesheet.mask.x = ctx.curr_row * ctx.spritesheet.mask.w; ctx.spritesheet.mask.y = (ctx.curr_col * ctx.spritesheet.mask.h); - if (!ctx.looping && curr_frame == total_frames - 1) { + if (!ctx.looping && curr_frame == ctx.cycle_start && last_frame == total_frames - 1) { a.active = false; } } diff --git a/src/example/rendering_particle.cpp b/src/example/rendering_particle.cpp index f84eb94..e18c7b7 100644 --- a/src/example/rendering_particle.cpp +++ b/src/example/rendering_particle.cpp @@ -71,15 +71,13 @@ public: .col = 4, .row = 4, .fps = 1, - .looping = true, - .cycle_start = 1, - .cycle_end = 3, + .looping = false, }); anim.set_anim(2); auto & cam = game_object.add_component<Camera>(Camera::Data{ .bg_color = Color::WHITE, - .screen = ivec2{720, 1280}, + .screen = ivec2{1280, 720}, .viewport_size = vec2{400, 400}, .zoom = 1.0, }); |