add ActionCustom
This commit is contained in:
parent
5c1878bd46
commit
b4a37d0714
|
|
@ -205,6 +205,12 @@ namespace kiwano
|
||||||
return TweenHelper(new kiwano::Animation(0, frames));
|
return TweenHelper(new kiwano::Animation(0, frames));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline TweenHelper
|
||||||
|
Custom(kiwano::ActionCustom::TweenFunc tween_func)
|
||||||
|
{
|
||||||
|
return TweenHelper(new kiwano::ActionCustom(0, tween_func));
|
||||||
|
}
|
||||||
|
|
||||||
static inline ActionHelper
|
static inline ActionHelper
|
||||||
Delay(Duration delay)
|
Delay(Duration delay)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -259,16 +259,16 @@ namespace kiwano
|
||||||
|
|
||||||
ActionScaleBy::ActionScaleBy(Duration duration, float scale, EaseFunc func)
|
ActionScaleBy::ActionScaleBy(Duration duration, float scale, EaseFunc func)
|
||||||
: ActionTween(duration, func)
|
: ActionTween(duration, func)
|
||||||
|
, delta_x_(scale)
|
||||||
|
, delta_y_(scale)
|
||||||
{
|
{
|
||||||
delta_x_ = scale;
|
|
||||||
delta_y_ = scale;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionScaleBy::ActionScaleBy(Duration duration, float scale_x, float scale_y, EaseFunc func)
|
ActionScaleBy::ActionScaleBy(Duration duration, float scale_x, float scale_y, EaseFunc func)
|
||||||
: ActionTween(duration, func)
|
: ActionTween(duration, func)
|
||||||
|
, delta_x_(scale_x)
|
||||||
|
, delta_y_(scale_y)
|
||||||
{
|
{
|
||||||
delta_x_ = scale_x;
|
|
||||||
delta_y_ = scale_y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionScaleBy::Init(NodePtr target)
|
void ActionScaleBy::Init(NodePtr target)
|
||||||
|
|
@ -328,8 +328,8 @@ namespace kiwano
|
||||||
|
|
||||||
ActionOpacityBy::ActionOpacityBy(Duration duration, float opacity, EaseFunc func)
|
ActionOpacityBy::ActionOpacityBy(Duration duration, float opacity, EaseFunc func)
|
||||||
: ActionTween(duration, func)
|
: ActionTween(duration, func)
|
||||||
|
, delta_val_(opacity)
|
||||||
{
|
{
|
||||||
delta_val_ = opacity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionOpacityBy::Init(NodePtr target)
|
void ActionOpacityBy::Init(NodePtr target)
|
||||||
|
|
@ -389,6 +389,7 @@ namespace kiwano
|
||||||
|
|
||||||
ActionRotateBy::ActionRotateBy(Duration duration, float rotation, EaseFunc func)
|
ActionRotateBy::ActionRotateBy(Duration duration, float rotation, EaseFunc func)
|
||||||
: ActionTween(duration, func)
|
: ActionTween(duration, func)
|
||||||
|
, start_val_()
|
||||||
, delta_val_(rotation)
|
, delta_val_(rotation)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -485,6 +486,34 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------
|
||||||
|
// ActionCustom
|
||||||
|
//-------------------------------------------------------
|
||||||
|
|
||||||
|
ActionCustom::ActionCustom(Duration duration, TweenFunc tween_func, EaseFunc func)
|
||||||
|
: ActionTween(duration, func)
|
||||||
|
, tween_func_(tween_func)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ActionPtr ActionCustom::Clone() const
|
||||||
|
{
|
||||||
|
return new ActionCustom(dur_, tween_func_);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ActionCustom::Init(NodePtr target)
|
||||||
|
{
|
||||||
|
if (!tween_func_)
|
||||||
|
this->Done();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ActionCustom::UpdateTween(NodePtr target, float percent)
|
||||||
|
{
|
||||||
|
if (tween_func_)
|
||||||
|
tween_func_(target, percent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
// ActionDelay
|
// ActionDelay
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -470,6 +470,39 @@ namespace kiwano
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// 自定义动作
|
||||||
|
class KGE_API ActionCustom
|
||||||
|
: public ActionTween
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using TweenFunc = Closure<void(NodePtr, float)>;
|
||||||
|
|
||||||
|
ActionCustom(
|
||||||
|
Duration duration, /* 持续时长 */
|
||||||
|
TweenFunc tween_func, /* 过程函数 */
|
||||||
|
EaseFunc func = nullptr /* 速度变化 */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 获取该动作的拷贝对象
|
||||||
|
ActionPtr Clone() const override;
|
||||||
|
|
||||||
|
// 获取该动作的倒转
|
||||||
|
ActionPtr Reverse() const override
|
||||||
|
{
|
||||||
|
KGE_ERROR_LOG(L"Reverse() not supported in ActionCustom");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void Init(NodePtr target) override;
|
||||||
|
|
||||||
|
void UpdateTween(NodePtr target, float percent) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
TweenFunc tween_func_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// 延时动作
|
// 延时动作
|
||||||
class KGE_API ActionDelay
|
class KGE_API ActionDelay
|
||||||
: public Action
|
: public Action
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue