Browse Source

Make animations call frame callback on end

master
C. J. Howard 4 years ago
parent
commit
35ab9c9480
1 changed files with 14 additions and 0 deletions
  1. +14
    -0
      src/animation/animation.hpp

+ 14
- 0
src/animation/animation.hpp View File

@ -26,6 +26,7 @@
#include <tuple> #include <tuple>
#include <type_traits> #include <type_traits>
#include <unordered_map> #include <unordered_map>
#include <iostream>
/** /**
* Abstract base class for animations. * Abstract base class for animations.
@ -451,6 +452,19 @@ void animation::advance(double dt)
{ {
stopped = true; stopped = true;
// Call frame callback for end frame
if (frame_callback != nullptr)
{
for (std::size_t i = 0; i < channels.size(); ++i)
{
auto frames = channels[i].find_keyframes(channels[i].get_duration());
if (frames[0] != nullptr)
{
frame_callback(static_cast<int>(i), std::get<1>(*frames[0]));
}
}
}
// Call end callback // Call end callback
if (end_callback) if (end_callback)
{ {

Loading…
Cancel
Save