Пример #1
0
void KeyFrameAnimation::Update(float deltaTime) {
    if (HasEnded()) return;

    currentTime += deltaTime;

    currentFrame = GetCurrentKeyFrame(currentFrame);    

    if (currentFrame == keyFrames.size() - 1) {
        currentRepeat++;
        if (HasEnded()) {
            currentFrame--; // step to the last frame (vs return)
        }
        else {
            currentTime = std::fmod(currentTime, keyFrames[currentFrame].time); // or = 0 for animation reset on repeat
            currentFrame = GetCurrentKeyFrame(0);
        }
    }

    KeyFrame& first  = keyFrames[currentFrame    ];
    KeyFrame& second = keyFrames[currentFrame + 1];
    
    float amount = GetTransition(first, second);

    DoLerp(first, second, amount);
}
Пример #2
0
 constexpr bool IsInside(RoughTime now) const {
   return HasBegun(now) && !HasEnded(now);
 }