Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions src/LottieTweening.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ struct UserExample : tvgexam::Example
int stateIdx = 0; //current state index

struct {
float from; //tweening from frame number
float to; //tweening to frame number
float beginTime; //tweening begin time
bool active = false; //whether on-tweening or not
} tween;
Expand Down Expand Up @@ -74,19 +72,16 @@ struct UserExample : tvgexam::Example
void tweening(int stateIdx)
{
//don't allow the overlapped tweening
if (tween.active || stateIdx == this->stateIdx) return;
if (stateIdx == this->stateIdx) return;
Comment thread
hermet marked this conversation as resolved.

//reset the current state
lottie->segment(nullptr);

//tweening trigger time
tween.beginTime = timestamp();

//the current animation frame as the tweening "from" frame
tween.from = lottie->curFrame();

//the next state begin frame as the tweening "to" frame
tween.to = states[stateIdx].begin;
lottie->tweenTo(states[stateIdx].begin);

tween.active = true;

Expand Down Expand Up @@ -151,7 +146,7 @@ struct UserExample : tvgexam::Example

//perform the tweening effect
if (progress < 1.0f) {
if (lottie->tween(tween.from, tween.to, progress) == tvg::Result(0)) {
if (lottie->tween(progress) == tvg::Result(0)) {
canvas->update();
return true;
}
Expand Down
Loading