From 97201bda7d87790779a37950aa930467aae38cb6 Mon Sep 17 00:00:00 2001 From: scottcgi Date: Mon, 16 Aug 2021 14:58:14 +0800 Subject: [PATCH] Change default easeType from Linear to Smooth. --- Engine/Toolkit/Utils/Tween.c | 33 ++++++++++++++++----------------- Engine/Toolkit/Utils/Tween.h | 2 +- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Engine/Toolkit/Utils/Tween.c b/Engine/Toolkit/Utils/Tween.c index 6624cc5..12e1a6d 100644 --- a/Engine/Toolkit/Utils/Tween.c +++ b/Engine/Toolkit/Utils/Tween.c @@ -9,7 +9,7 @@ * CodeStyle: https://github.com/scottcgi/Mojoc/blob/master/Docs/CodeStyle.md * * Since : 2016-6-8 - * Update : 2019-1-8 + * Update : 2021-8-16 * Author : scott.cgi */ @@ -107,7 +107,7 @@ static TweenActionValue* AddTweenActionValue(TweenAction* action) actionValue->OnGet = NULL; actionValue->OnSet = NULL; actionValue->isRelative = true; - actionValue->easeType = TweenEaseType_Linear; + actionValue->easeType = TweenEaseType_Smooth; return actionValue; } @@ -187,6 +187,18 @@ static void* RunActions(Array(TweenAction*)* actions, void* tweenID) } +static void RemoveActionByIndex(Tween* tween, TweenAction* action, int index) +{ + if (action == tween->queueAction) + { + tween->queueAction = NULL; + } + + AArrayList->RemoveByLast(tween->current, index); + AArrayList_Add(actionCacheList, action); +} + + static bool TryRemoveAction(void* tweenID, TweenAction* action) { Tween* tween = AArrayIntMap_Get(tweenRunningMap, tweenID, Tween*); @@ -199,14 +211,7 @@ static bool TryRemoveAction(void* tweenID, TweenAction* action) if (action == tweenAction) { - if (action == tween->queueAction) - { - tween->queueAction = NULL; - } - - AArrayList->RemoveByLast(tween->current, i); - AArrayList_Add(actionCacheList, action); - + RemoveActionByIndex(tween, action, i); return true; } } @@ -395,13 +400,7 @@ static void Update(float deltaSeconds) action->OnComplete(action); } - if (tween->queueAction == action) - { - tween->queueAction = NULL; - } - - AArrayList->RemoveByLast(tween->current, j); - AArrayList_Add(actionCacheList, action); + RemoveActionByIndex(tween, action, j); } } } diff --git a/Engine/Toolkit/Utils/Tween.h b/Engine/Toolkit/Utils/Tween.h index f380b74..0d5c597 100644 --- a/Engine/Toolkit/Utils/Tween.h +++ b/Engine/Toolkit/Utils/Tween.h @@ -72,7 +72,7 @@ typedef struct bool isRelative; /** - * Default TweenEaseType_Linear. + * Default TweenEaseType_Smooth. */ TweenEaseType easeType; }