diff --git a/game/source/VaKon2D.cpp b/game/source/VaKon2D.cpp index d603f917d..2111df6e8 100644 --- a/game/source/VaKon2D.cpp +++ b/game/source/VaKon2D.cpp @@ -69,7 +69,7 @@ void VaKon2D::start() StopMotionAnimation animation; animation.setupAnimation({{0, 0}, {32, 32}}, {{544, 0}, {32, 32}}, widget); animation.setFrameGap(100); - animation.setMode(IAnimation::Mode::PingPong); + animation.setMode(IAnimation::Mode::Repeating); animation.start(); while (!GetWindow().shouldClose()) diff --git a/lib/core/animations/source/StopMotionAnimation.cpp b/lib/core/animations/source/StopMotionAnimation.cpp index 542af71f5..c7f489280 100644 --- a/lib/core/animations/source/StopMotionAnimation.cpp +++ b/lib/core/animations/source/StopMotionAnimation.cpp @@ -109,7 +109,7 @@ void StopMotionAnimation::draw(ShaderPack& shaderPack) { case Mode::PingPong: { - const auto cooldown = (std::chrono::system_clock::now() - lastAnimatingFrame).count() / 10000ll; + const auto cooldown = (std::chrono::system_clock::now() - lastAnimatingFrame).count() / 10'000ll; if (cooldown >= frameGap_) { if (direction_ == PingPongDirection::ToEnd) @@ -147,10 +147,10 @@ void StopMotionAnimation::draw(ShaderPack& shaderPack) } case Mode::Repeating: { - const auto cooldown = (std::chrono::system_clock::now() - lastAnimatingFrame).count() / 1000ll; + const auto cooldown = (std::chrono::system_clock::now() - lastAnimatingFrame).count() / 10'000ll; if (cooldown >= frameGap_) { - if (currentFrame_ >= framesCount_) + if (currentFrame_ >= framesCount_ - 1) { currentOffsetPosition_ = startPosition_; currentFrame_ = 0; @@ -166,6 +166,29 @@ void StopMotionAnimation::draw(ShaderPack& shaderPack) } break; } + case Mode::SingleShot: + { + const auto cooldown = (std::chrono::system_clock::now() - lastAnimatingFrame).count() / 10'000ll; + if (cooldown >= frameGap_) + { + if (currentFrame_ >= framesCount_ - 1) + { + currentOffsetPosition_ = endPosition_; + widget_->setTextureRect(Utils::IRect{currentOffsetPosition_, textureSize_}); + currentFrame_ = framesCount_; + break; + } + + currentOffsetPosition_ += offsetPosition_; + + ++currentFrame_; + + widget_->setTextureRect(Utils::IRect{currentOffsetPosition_, textureSize_}); + + lastAnimatingFrame = std::chrono::system_clock::now(); + } + break; + } } } widget_->draw(shaderPack);