Update actions
This commit is contained in:
parent
8c291b1cdc
commit
876035ccae
|
|
@ -22,19 +22,25 @@
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
ActionDelay::ActionDelay(Duration delay)
|
|
||||||
|
ActionDelayPtr ActionDelay::Create(Duration delay)
|
||||||
{
|
{
|
||||||
SetDelay(delay);
|
ActionDelayPtr ptr = new (std::nothrow) ActionDelay;
|
||||||
|
if (ptr)
|
||||||
|
{
|
||||||
|
ptr->SetDelay(delay);
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr ActionDelay::Clone() const
|
ActionPtr ActionDelay::Clone() const
|
||||||
{
|
{
|
||||||
return new ActionDelay(GetDelay());
|
return ActionDelay::Create(GetDelay());
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr ActionDelay::Reverse() const
|
ActionPtr ActionDelay::Reverse() const
|
||||||
{
|
{
|
||||||
return new ActionDelay(GetDelay());
|
return ActionDelay::Create(GetDelay());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace kiwano
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,9 @@
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
||||||
|
KGE_DECLARE_SMART_PTR(ActionDelay);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \addtogroup Actions
|
* \addtogroup Actions
|
||||||
* @{
|
* @{
|
||||||
|
|
@ -34,9 +37,9 @@ class KGE_API ActionDelay : public Action
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 构建延时动画
|
/// @brief 创建延时动画
|
||||||
/// @param delay 延时时长
|
/// @param delay 延时时长
|
||||||
ActionDelay(Duration delay);
|
static ActionDelayPtr Create(Duration delay);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取该动画的拷贝对象
|
/// @brief 获取该动画的拷贝对象
|
||||||
|
|
|
||||||
|
|
@ -24,19 +24,25 @@
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
//-------------------------------------------------------
|
|
||||||
// ActionGroup
|
ActionGroupPtr ActionGroup::Create(Vector<ActionPtr> const& actions, bool sync)
|
||||||
//-------------------------------------------------------
|
{
|
||||||
|
ActionGroupPtr ptr = new (std::nothrow) ActionGroup(sync);
|
||||||
|
if (ptr)
|
||||||
|
{
|
||||||
|
ptr->AddActions(actions);
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
ActionGroup::ActionGroup()
|
ActionGroup::ActionGroup()
|
||||||
: sync_(false)
|
: sync_(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionGroup::ActionGroup(Vector<ActionPtr> const& actions, bool sync)
|
ActionGroup::ActionGroup(bool sync)
|
||||||
: sync_(sync)
|
: sync_(sync)
|
||||||
{
|
{
|
||||||
this->Add(actions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionGroup::~ActionGroup() {}
|
ActionGroup::~ActionGroup() {}
|
||||||
|
|
@ -100,7 +106,7 @@ void ActionGroup::Update(Actor* target, Duration dt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionGroup::Add(ActionPtr action)
|
void ActionGroup::AddAction(ActionPtr action)
|
||||||
{
|
{
|
||||||
if (action)
|
if (action)
|
||||||
{
|
{
|
||||||
|
|
@ -108,10 +114,10 @@ void ActionGroup::Add(ActionPtr action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionGroup::Add(Vector<ActionPtr> const& actions)
|
void ActionGroup::AddActions(Vector<ActionPtr> const& actions)
|
||||||
{
|
{
|
||||||
for (const auto& action : actions)
|
for (const auto& action : actions)
|
||||||
Add(action);
|
AddAction(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr ActionGroup::Clone() const
|
ActionPtr ActionGroup::Clone() const
|
||||||
|
|
@ -124,8 +130,7 @@ ActionPtr ActionGroup::Clone() const
|
||||||
actions.push_back(action->Clone());
|
actions.push_back(action->Clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ActionPtr group = new (std::nothrow) ActionGroup(actions, sync_);
|
return ActionGroup::Create(actions, sync_);
|
||||||
return group;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr ActionGroup::Reverse() const
|
ActionPtr ActionGroup::Reverse() const
|
||||||
|
|
@ -138,8 +143,7 @@ ActionPtr ActionGroup::Reverse() const
|
||||||
actions.push_back(action->Reverse());
|
actions.push_back(action->Reverse());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ActionPtr group = new (std::nothrow) ActionGroup(actions, sync_);
|
return ActionGroup::Create(actions, sync_);
|
||||||
return group;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace kiwano
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -37,25 +37,27 @@ class KGE_API ActionGroup : public Action
|
||||||
public:
|
public:
|
||||||
using ActionList = IntrusiveList<ActionPtr>;
|
using ActionList = IntrusiveList<ActionPtr>;
|
||||||
|
|
||||||
ActionGroup();
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 动画组合
|
/// @brief 创建动画组合
|
||||||
/// @param actions 动画集合
|
/// @param actions 动画集合
|
||||||
/// @param sync 同步执行
|
/// @param sync 同步执行
|
||||||
explicit ActionGroup(Vector<ActionPtr> const& actions, bool sync = false);
|
static ActionGroupPtr Create(Vector<ActionPtr> const& actions, bool sync = false);
|
||||||
|
|
||||||
|
ActionGroup();
|
||||||
|
|
||||||
|
ActionGroup(bool sync);
|
||||||
|
|
||||||
virtual ~ActionGroup();
|
virtual ~ActionGroup();
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 添加动画
|
/// @brief 添加动画
|
||||||
/// @param action 动画
|
/// @param action 动画
|
||||||
void Add(ActionPtr action);
|
void AddAction(ActionPtr action);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 添加多个动画
|
/// @brief 添加多个动画
|
||||||
/// @param actions 动画集合
|
/// @param actions 动画集合
|
||||||
void Add(Vector<ActionPtr> const& actions);
|
void AddActions(Vector<ActionPtr> const& actions);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取所有动画
|
/// @brief 获取所有动画
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ struct ActionHelper
|
||||||
/// @brief 设置循环次数
|
/// @brief 设置循环次数
|
||||||
inline ActionHelper& SetLoops(int loops)
|
inline ActionHelper& SetLoops(int loops)
|
||||||
{
|
{
|
||||||
core->SetLoops(loops);
|
ptr->SetLoops(loops);
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -50,7 +50,7 @@ struct ActionHelper
|
||||||
/// @brief 设置动画延迟
|
/// @brief 设置动画延迟
|
||||||
inline ActionHelper& SetDelay(Duration delay)
|
inline ActionHelper& SetDelay(Duration delay)
|
||||||
{
|
{
|
||||||
core->SetDelay(delay);
|
ptr->SetDelay(delay);
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -58,7 +58,7 @@ struct ActionHelper
|
||||||
/// @brief 设置动画结束回调函数
|
/// @brief 设置动画结束回调函数
|
||||||
inline ActionHelper& SetDoneCallback(DoneCallback const& cb)
|
inline ActionHelper& SetDoneCallback(DoneCallback const& cb)
|
||||||
{
|
{
|
||||||
core->SetDoneCallback(cb);
|
ptr->SetDoneCallback(cb);
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,7 +66,7 @@ struct ActionHelper
|
||||||
/// @brief 设置动画循环结束时的回调函数
|
/// @brief 设置动画循环结束时的回调函数
|
||||||
inline ActionHelper& SetLoopDoneCallback(DoneCallback const& cb)
|
inline ActionHelper& SetLoopDoneCallback(DoneCallback const& cb)
|
||||||
{
|
{
|
||||||
core->SetLoopDoneCallback(cb);
|
ptr->SetLoopDoneCallback(cb);
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -74,7 +74,7 @@ struct ActionHelper
|
||||||
/// @brief 动画结束时移除目标角色
|
/// @brief 动画结束时移除目标角色
|
||||||
inline ActionHelper& RemoveTargetWhenDone()
|
inline ActionHelper& RemoveTargetWhenDone()
|
||||||
{
|
{
|
||||||
core->RemoveTargetWhenDone();
|
ptr->RemoveTargetWhenDone();
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -82,7 +82,7 @@ struct ActionHelper
|
||||||
/// @brief 设置名称
|
/// @brief 设置名称
|
||||||
inline ActionHelper& SetName(String const& name)
|
inline ActionHelper& SetName(String const& name)
|
||||||
{
|
{
|
||||||
core->SetName(name);
|
ptr->SetName(name);
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -90,21 +90,21 @@ struct ActionHelper
|
||||||
/// @brief 获取指针
|
/// @brief 获取指针
|
||||||
inline ActionPtr Get() const
|
inline ActionPtr Get() const
|
||||||
{
|
{
|
||||||
return core;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ActionHelper(ActionPtr core)
|
inline ActionHelper(ActionPtr ptr)
|
||||||
: core(core)
|
: ptr(ptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
inline operator ActionPtr() const
|
inline operator ActionPtr() const
|
||||||
{
|
{
|
||||||
return core;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ActionPtr core;
|
ActionPtr ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -117,7 +117,7 @@ struct TweenHelper
|
||||||
/// @brief 设置动画持续时长
|
/// @brief 设置动画持续时长
|
||||||
inline TweenHelper& SetDuration(Duration dur)
|
inline TweenHelper& SetDuration(Duration dur)
|
||||||
{
|
{
|
||||||
core->SetDuration(dur);
|
ptr->SetDuration(dur);
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -125,7 +125,7 @@ struct TweenHelper
|
||||||
/// @brief 设置循环次数
|
/// @brief 设置循环次数
|
||||||
inline TweenHelper& SetLoops(int loops)
|
inline TweenHelper& SetLoops(int loops)
|
||||||
{
|
{
|
||||||
core->SetLoops(loops);
|
ptr->SetLoops(loops);
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -133,7 +133,7 @@ struct TweenHelper
|
||||||
/// @brief 设置缓动函数
|
/// @brief 设置缓动函数
|
||||||
inline TweenHelper& SetEaseFunc(EaseFunc ease)
|
inline TweenHelper& SetEaseFunc(EaseFunc ease)
|
||||||
{
|
{
|
||||||
core->SetEaseFunc(ease);
|
ptr->SetEaseFunc(ease);
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -141,7 +141,7 @@ struct TweenHelper
|
||||||
/// @brief 设置动画延迟
|
/// @brief 设置动画延迟
|
||||||
inline TweenHelper& SetDelay(Duration delay)
|
inline TweenHelper& SetDelay(Duration delay)
|
||||||
{
|
{
|
||||||
core->SetDelay(delay);
|
ptr->SetDelay(delay);
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -149,7 +149,7 @@ struct TweenHelper
|
||||||
/// @brief 设置动画结束回调函数
|
/// @brief 设置动画结束回调函数
|
||||||
inline TweenHelper& SetDoneCallback(DoneCallback const& cb)
|
inline TweenHelper& SetDoneCallback(DoneCallback const& cb)
|
||||||
{
|
{
|
||||||
core->SetDoneCallback(cb);
|
ptr->SetDoneCallback(cb);
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -157,7 +157,7 @@ struct TweenHelper
|
||||||
/// @brief 设置动画循环结束时的回调函数
|
/// @brief 设置动画循环结束时的回调函数
|
||||||
inline TweenHelper& SetLoopDoneCallback(DoneCallback const& cb)
|
inline TweenHelper& SetLoopDoneCallback(DoneCallback const& cb)
|
||||||
{
|
{
|
||||||
core->SetLoopDoneCallback(cb);
|
ptr->SetLoopDoneCallback(cb);
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -165,7 +165,7 @@ struct TweenHelper
|
||||||
/// @brief 动画结束时移除目标角色
|
/// @brief 动画结束时移除目标角色
|
||||||
inline TweenHelper& RemoveTargetWhenDone()
|
inline TweenHelper& RemoveTargetWhenDone()
|
||||||
{
|
{
|
||||||
core->RemoveTargetWhenDone();
|
ptr->RemoveTargetWhenDone();
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -173,7 +173,7 @@ struct TweenHelper
|
||||||
/// @brief 设置名称
|
/// @brief 设置名称
|
||||||
inline TweenHelper& SetName(String const& name)
|
inline TweenHelper& SetName(String const& name)
|
||||||
{
|
{
|
||||||
core->SetName(name);
|
ptr->SetName(name);
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -181,26 +181,26 @@ struct TweenHelper
|
||||||
/// @brief 获取指针
|
/// @brief 获取指针
|
||||||
inline ActionTweenPtr Get() const
|
inline ActionTweenPtr Get() const
|
||||||
{
|
{
|
||||||
return core;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline TweenHelper(ActionTweenPtr core)
|
inline TweenHelper(ActionTweenPtr ptr)
|
||||||
: core(core)
|
: ptr(ptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
inline operator ActionPtr() const
|
inline operator ActionPtr() const
|
||||||
{
|
{
|
||||||
return core;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline operator ActionTweenPtr() const
|
inline operator ActionTweenPtr() const
|
||||||
{
|
{
|
||||||
return core;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ActionTweenPtr core;
|
ActionTweenPtr ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -214,7 +214,7 @@ public:
|
||||||
/// @param vector 移动向量
|
/// @param vector 移动向量
|
||||||
static inline TweenHelper MoveBy(Duration dur, Point const& vector)
|
static inline TweenHelper MoveBy(Duration dur, Point const& vector)
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::ActionMoveBy(dur, vector));
|
return TweenHelper(ActionMoveBy::Create(dur, vector));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -223,7 +223,7 @@ public:
|
||||||
/// @param pos 目的坐标
|
/// @param pos 目的坐标
|
||||||
static inline TweenHelper MoveTo(Duration dur, Point const& pos)
|
static inline TweenHelper MoveTo(Duration dur, Point const& pos)
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::ActionMoveTo(dur, pos));
|
return TweenHelper(ActionMoveTo::Create(dur, pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -234,7 +234,7 @@ public:
|
||||||
/// @param jumps 跳跃次数
|
/// @param jumps 跳跃次数
|
||||||
static inline TweenHelper JumpBy(Duration duration, Vec2 const& vec, float height, int jumps = 1)
|
static inline TweenHelper JumpBy(Duration duration, Vec2 const& vec, float height, int jumps = 1)
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::ActionJumpBy(duration, vec, height, jumps));
|
return TweenHelper(ActionJumpBy::Create(duration, vec, height, jumps));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -245,7 +245,7 @@ public:
|
||||||
/// @param jumps 跳跃次数
|
/// @param jumps 跳跃次数
|
||||||
static inline TweenHelper JumpTo(Duration duration, Point const& pos, float height, int jumps = 1)
|
static inline TweenHelper JumpTo(Duration duration, Point const& pos, float height, int jumps = 1)
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::ActionJumpTo(duration, pos, height, jumps));
|
return TweenHelper(ActionJumpTo::Create(duration, pos, height, jumps));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -255,7 +255,7 @@ public:
|
||||||
/// @param scale_y 纵向缩放相对变化值
|
/// @param scale_y 纵向缩放相对变化值
|
||||||
static inline TweenHelper ScaleBy(Duration dur, float scale_x, float scale_y)
|
static inline TweenHelper ScaleBy(Duration dur, float scale_x, float scale_y)
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::ActionScaleBy(dur, scale_x, scale_y));
|
return TweenHelper(ActionScaleBy::Create(dur, scale_x, scale_y));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -265,7 +265,7 @@ public:
|
||||||
/// @param scale_y 纵向缩放目标值
|
/// @param scale_y 纵向缩放目标值
|
||||||
static inline TweenHelper ScaleTo(Duration dur, float scale_x, float scale_y)
|
static inline TweenHelper ScaleTo(Duration dur, float scale_x, float scale_y)
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::ActionScaleTo(dur, scale_x, scale_y));
|
return TweenHelper(ActionScaleTo::Create(dur, scale_x, scale_y));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -274,7 +274,7 @@ public:
|
||||||
/// @param opacity 目标透明度
|
/// @param opacity 目标透明度
|
||||||
static inline TweenHelper FadeTo(Duration dur, float opacity)
|
static inline TweenHelper FadeTo(Duration dur, float opacity)
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::ActionFadeTo(dur, opacity));
|
return TweenHelper(ActionFadeTo::Create(dur, opacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -282,7 +282,7 @@ public:
|
||||||
/// @param duration 动画时长
|
/// @param duration 动画时长
|
||||||
static inline TweenHelper FadeIn(Duration dur)
|
static inline TweenHelper FadeIn(Duration dur)
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::ActionFadeIn(dur));
|
return TweenHelper(ActionFadeIn::Create(dur));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -290,7 +290,7 @@ public:
|
||||||
/// @param duration 动画时长
|
/// @param duration 动画时长
|
||||||
static inline TweenHelper FadeOut(Duration dur)
|
static inline TweenHelper FadeOut(Duration dur)
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::ActionFadeOut(dur));
|
return TweenHelper(ActionFadeOut::Create(dur));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -299,7 +299,7 @@ public:
|
||||||
/// @param rotation 角度相对变化值
|
/// @param rotation 角度相对变化值
|
||||||
static inline TweenHelper RotateBy(Duration dur, float rotation)
|
static inline TweenHelper RotateBy(Duration dur, float rotation)
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::ActionRotateBy(dur, rotation));
|
return TweenHelper(ActionRotateBy::Create(dur, rotation));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -308,7 +308,7 @@ public:
|
||||||
/// @param rotation 目标角度
|
/// @param rotation 目标角度
|
||||||
static inline TweenHelper RotateTo(Duration dur, float rotation)
|
static inline TweenHelper RotateTo(Duration dur, float rotation)
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::ActionRotateTo(dur, rotation));
|
return TweenHelper(ActionRotateTo::Create(dur, rotation));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -321,7 +321,7 @@ public:
|
||||||
static inline TweenHelper Walk(Duration duration, ShapePtr path, bool rotating = false, float start = 0.f,
|
static inline TweenHelper Walk(Duration duration, ShapePtr path, bool rotating = false, float start = 0.f,
|
||||||
float end = 1.f)
|
float end = 1.f)
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::ActionWalk(duration, path, rotating, start, end));
|
return TweenHelper(ActionWalk::Create(duration, path, rotating, start, end));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -330,7 +330,7 @@ public:
|
||||||
/// @param[in] frame_seq 序列帧
|
/// @param[in] frame_seq 序列帧
|
||||||
static inline TweenHelper Animation(Duration dur, FrameSequencePtr frames)
|
static inline TweenHelper Animation(Duration dur, FrameSequencePtr frames)
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::Animation(dur, frames));
|
return TweenHelper(Animation::Create(dur, frames));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -339,7 +339,7 @@ public:
|
||||||
/// @param tween_func 动画回调函数
|
/// @param tween_func 动画回调函数
|
||||||
static inline TweenHelper Custom(Duration dur, ActionCustom::TweenFunc tween_func)
|
static inline TweenHelper Custom(Duration dur, ActionCustom::TweenFunc tween_func)
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::ActionCustom(dur, tween_func));
|
return TweenHelper(ActionCustom::Create(dur, tween_func));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -347,7 +347,7 @@ public:
|
||||||
/// @param delay 延时时长
|
/// @param delay 延时时长
|
||||||
static inline ActionHelper Delay(Duration delay)
|
static inline ActionHelper Delay(Duration delay)
|
||||||
{
|
{
|
||||||
return ActionHelper(new kiwano::ActionDelay(delay));
|
return ActionHelper(ActionDelay::Create(delay));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -356,7 +356,7 @@ public:
|
||||||
/// @param sync 同步执行
|
/// @param sync 同步执行
|
||||||
static inline ActionHelper Group(Vector<ActionPtr> const& actions, bool sync = false)
|
static inline ActionHelper Group(Vector<ActionPtr> const& actions, bool sync = false)
|
||||||
{
|
{
|
||||||
return ActionHelper(new kiwano::ActionGroup(actions, sync));
|
return ActionHelper(ActionGroup::Create(actions, sync));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -96,24 +96,9 @@ ActionTween::ActionTween()
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionTween::ActionTween(Duration duration, EaseFunc func)
|
ActionTween::ActionTween(Duration duration, EaseFunc func)
|
||||||
|
: dur_(duration)
|
||||||
|
, ease_func_(func)
|
||||||
{
|
{
|
||||||
SetDuration(duration);
|
|
||||||
SetEaseFunc(func);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ActionTween::SetEaseFunc(EaseFunc const& func)
|
|
||||||
{
|
|
||||||
ease_func_ = func;
|
|
||||||
}
|
|
||||||
|
|
||||||
EaseFunc const& ActionTween::GetEaseFunc() const
|
|
||||||
{
|
|
||||||
return ease_func_;
|
|
||||||
}
|
|
||||||
|
|
||||||
Duration ActionTween::GetDuration() const
|
|
||||||
{
|
|
||||||
return dur_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionTween::Update(Actor* target, Duration dt)
|
void ActionTween::Update(Actor* target, Duration dt)
|
||||||
|
|
@ -144,20 +129,22 @@ void ActionTween::Update(Actor* target, Duration dt)
|
||||||
UpdateTween(target, percent);
|
UpdateTween(target, percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionTween::SetDuration(Duration duration)
|
|
||||||
{
|
|
||||||
dur_ = duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
// Move Action
|
// Move Action
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
ActionMoveBy::ActionMoveBy(Duration duration, Vec2 const& vector, EaseFunc func)
|
ActionMoveByPtr ActionMoveBy::Create(Duration duration, Vec2 const& displacement)
|
||||||
: ActionTween(duration, func)
|
|
||||||
{
|
{
|
||||||
delta_pos_ = vector;
|
ActionMoveByPtr ptr = new (std::nothrow) ActionMoveBy;
|
||||||
|
if (ptr)
|
||||||
|
{
|
||||||
|
ptr->SetDuration(duration);
|
||||||
|
ptr->SetDisplacement(displacement);
|
||||||
}
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
ActionMoveBy::ActionMoveBy() {}
|
||||||
|
|
||||||
void ActionMoveBy::Init(Actor* target)
|
void ActionMoveBy::Init(Actor* target)
|
||||||
{
|
{
|
||||||
|
|
@ -172,7 +159,7 @@ void ActionMoveBy::UpdateTween(Actor* target, float percent)
|
||||||
Point diff = target->GetPosition() - prev_pos_;
|
Point diff = target->GetPosition() - prev_pos_;
|
||||||
start_pos_ = start_pos_ + diff;
|
start_pos_ = start_pos_ + diff;
|
||||||
|
|
||||||
Point new_pos = start_pos_ + (delta_pos_ * percent);
|
Point new_pos = start_pos_ + (displacement_ * percent);
|
||||||
target->SetPosition(new_pos);
|
target->SetPosition(new_pos);
|
||||||
|
|
||||||
prev_pos_ = new_pos;
|
prev_pos_ = new_pos;
|
||||||
|
|
@ -180,51 +167,71 @@ void ActionMoveBy::UpdateTween(Actor* target, float percent)
|
||||||
|
|
||||||
ActionPtr ActionMoveBy::Clone() const
|
ActionPtr ActionMoveBy::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) ActionMoveBy(GetDuration(), delta_pos_, GetEaseFunc());
|
return ActionMoveBy::Create(GetDuration(), displacement_);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr ActionMoveBy::Reverse() const
|
ActionPtr ActionMoveBy::Reverse() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) ActionMoveBy(GetDuration(), -delta_pos_, GetEaseFunc());
|
return ActionMoveBy::Create(GetDuration(), -displacement_);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionMoveTo::ActionMoveTo(Duration duration, Point const& pos, EaseFunc func)
|
ActionMoveToPtr ActionMoveTo::Create(Duration duration, Point const& distination)
|
||||||
: ActionMoveBy(duration, Point(), func)
|
|
||||||
{
|
{
|
||||||
end_pos_ = pos;
|
ActionMoveToPtr ptr = new (std::nothrow) ActionMoveTo;
|
||||||
|
if (ptr)
|
||||||
|
{
|
||||||
|
ptr->SetDuration(duration);
|
||||||
|
ptr->SetDistination(distination);
|
||||||
}
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
ActionMoveTo::ActionMoveTo() {}
|
||||||
|
|
||||||
ActionPtr ActionMoveTo::Clone() const
|
ActionPtr ActionMoveTo::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) ActionMoveTo(GetDuration(), end_pos_, GetEaseFunc());
|
return ActionMoveTo::Create(GetDuration(), distination_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionMoveTo::Init(Actor* target)
|
void ActionMoveTo::Init(Actor* target)
|
||||||
{
|
{
|
||||||
ActionMoveBy::Init(target);
|
ActionMoveBy::Init(target);
|
||||||
delta_pos_ = end_pos_ - start_pos_;
|
displacement_ = distination_ - start_pos_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
// Jump Action
|
// Jump Action
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
ActionJumpBy::ActionJumpBy(Duration duration, Vec2 const& vec, float height, int jumps, EaseFunc func)
|
ActionJumpByPtr ActionJumpBy::Create(Duration duration, Vec2 const& displacement, float height, int count,
|
||||||
: ActionTween(duration, func)
|
EaseFunc ease)
|
||||||
, delta_pos_(vec)
|
{
|
||||||
, height_(height)
|
ActionJumpByPtr ptr = new (std::nothrow) ActionJumpBy;
|
||||||
, jumps_(jumps)
|
if (ptr)
|
||||||
|
{
|
||||||
|
ptr->SetDuration(duration);
|
||||||
|
ptr->SetEaseFunc(ease);
|
||||||
|
ptr->SetJumpHeight(height);
|
||||||
|
ptr->SetJumpCount(count);
|
||||||
|
ptr->SetDisplacement(displacement);
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
ActionJumpBy::ActionJumpBy()
|
||||||
|
: height_(0.0f)
|
||||||
|
, jump_count_(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr ActionJumpBy::Clone() const
|
ActionPtr ActionJumpBy::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) ActionJumpBy(GetDuration(), delta_pos_, height_, jumps_, GetEaseFunc());
|
return ActionJumpBy::Create(GetDuration(), displacement_, height_, jump_count_);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr ActionJumpBy::Reverse() const
|
ActionPtr ActionJumpBy::Reverse() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) ActionJumpBy(GetDuration(), -delta_pos_, height_, jumps_, GetEaseFunc());
|
return ActionJumpBy::Create(GetDuration(), -displacement_, height_, jump_count_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionJumpBy::Init(Actor* target)
|
void ActionJumpBy::Init(Actor* target)
|
||||||
|
|
@ -237,10 +244,10 @@ void ActionJumpBy::Init(Actor* target)
|
||||||
|
|
||||||
void ActionJumpBy::UpdateTween(Actor* target, float percent)
|
void ActionJumpBy::UpdateTween(Actor* target, float percent)
|
||||||
{
|
{
|
||||||
float frac = fmod(percent * jumps_, 1.f);
|
float frac = fmod(percent * jump_count_, 1.f);
|
||||||
float x = delta_pos_.x * percent;
|
float x = displacement_.x * percent;
|
||||||
float y = height_ * 4 * frac * (1 - frac);
|
float y = height_ * 4 * frac * (1 - frac);
|
||||||
y += delta_pos_.y * percent;
|
y += displacement_.y * percent;
|
||||||
|
|
||||||
Point diff = target->GetPosition() - prev_pos_;
|
Point diff = target->GetPosition() - prev_pos_;
|
||||||
start_pos_ = diff + start_pos_;
|
start_pos_ = diff + start_pos_;
|
||||||
|
|
@ -251,31 +258,53 @@ void ActionJumpBy::UpdateTween(Actor* target, float percent)
|
||||||
prev_pos_ = new_pos;
|
prev_pos_ = new_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionJumpTo::ActionJumpTo(Duration duration, Point const& pos, float height, int jumps, EaseFunc func)
|
ActionJumpToPtr ActionJumpTo::Create(Duration duration, Point const& distination, float height, int count,
|
||||||
: ActionJumpBy(duration, Point(), height, jumps, func)
|
EaseFunc ease)
|
||||||
, end_pos_(pos)
|
|
||||||
{
|
{
|
||||||
|
ActionJumpToPtr ptr = new (std::nothrow) ActionJumpTo;
|
||||||
|
if (ptr)
|
||||||
|
{
|
||||||
|
ptr->SetDuration(duration);
|
||||||
|
ptr->SetEaseFunc(ease);
|
||||||
|
ptr->SetJumpHeight(height);
|
||||||
|
ptr->SetJumpCount(count);
|
||||||
|
ptr->SetDistination(distination);
|
||||||
}
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
ActionJumpTo::ActionJumpTo() {}
|
||||||
|
|
||||||
ActionPtr ActionJumpTo::Clone() const
|
ActionPtr ActionJumpTo::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) ActionJumpTo(GetDuration(), end_pos_, height_, jumps_, GetEaseFunc());
|
return ActionJumpTo::Create(GetDuration(), distination_, height_, jump_count_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionJumpTo::Init(Actor* target)
|
void ActionJumpTo::Init(Actor* target)
|
||||||
{
|
{
|
||||||
ActionJumpBy::Init(target);
|
ActionJumpBy::Init(target);
|
||||||
delta_pos_ = end_pos_ - start_pos_;
|
displacement_ = distination_ - start_pos_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
// Scale Action
|
// Scale Action
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
ActionScaleBy::ActionScaleBy(Duration duration, float scale_x, float scale_y, EaseFunc func)
|
ActionScaleByPtr ActionScaleBy::Create(Duration duration, float scale_x, float scale_y)
|
||||||
: ActionTween(duration, func)
|
{
|
||||||
, delta_x_(scale_x)
|
ActionScaleByPtr ptr = new (std::nothrow) ActionScaleBy;
|
||||||
, delta_y_(scale_y)
|
if (ptr)
|
||||||
|
{
|
||||||
|
ptr->SetDuration(duration);
|
||||||
|
ptr->SetScaleX(scale_x);
|
||||||
|
ptr->SetScaleY(scale_y);
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
ActionScaleBy::ActionScaleBy()
|
||||||
|
: delta_x_(0.0f)
|
||||||
|
, delta_y_(0.0f)
|
||||||
, start_scale_x_(0.f)
|
, start_scale_x_(0.f)
|
||||||
, start_scale_y_(0.f)
|
, start_scale_y_(0.f)
|
||||||
{
|
{
|
||||||
|
|
@ -297,24 +326,35 @@ void ActionScaleBy::UpdateTween(Actor* target, float percent)
|
||||||
|
|
||||||
ActionPtr ActionScaleBy::Clone() const
|
ActionPtr ActionScaleBy::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) ActionScaleBy(GetDuration(), delta_x_, delta_y_, GetEaseFunc());
|
return ActionScaleBy::Create(GetDuration(), delta_x_, delta_y_);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr ActionScaleBy::Reverse() const
|
ActionPtr ActionScaleBy::Reverse() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) ActionScaleBy(GetDuration(), -delta_x_, -delta_y_, GetEaseFunc());
|
return ActionScaleBy::Create(GetDuration(), -delta_x_, -delta_y_);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionScaleTo::ActionScaleTo(Duration duration, float scale_x, float scale_y, EaseFunc func)
|
ActionScaleToPtr ActionScaleTo::Create(Duration duration, float scale_x, float scale_y)
|
||||||
: ActionScaleBy(duration, 0, 0, func)
|
{
|
||||||
|
ActionScaleToPtr ptr = new (std::nothrow) ActionScaleTo;
|
||||||
|
if (ptr)
|
||||||
|
{
|
||||||
|
ptr->SetDuration(duration);
|
||||||
|
ptr->SetTargetScaleX(scale_x);
|
||||||
|
ptr->SetTargetScaleY(scale_y);
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
ActionScaleTo::ActionScaleTo()
|
||||||
|
: end_scale_x_(0.0f)
|
||||||
|
, end_scale_y_(0.0f)
|
||||||
{
|
{
|
||||||
end_scale_x_ = scale_x;
|
|
||||||
end_scale_y_ = scale_y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr ActionScaleTo::Clone() const
|
ActionPtr ActionScaleTo::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) ActionScaleTo(GetDuration(), end_scale_x_, end_scale_y_, GetEaseFunc());
|
return ActionScaleTo::Create(GetDuration(), end_scale_x_, end_scale_y_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionScaleTo::Init(Actor* target)
|
void ActionScaleTo::Init(Actor* target)
|
||||||
|
|
@ -328,11 +368,21 @@ void ActionScaleTo::Init(Actor* target)
|
||||||
// Opacity Action
|
// Opacity Action
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
ActionFadeTo::ActionFadeTo(Duration duration, float opacity, EaseFunc func)
|
ActionFadeToPtr ActionFadeTo::Create(Duration duration, float opacity)
|
||||||
: ActionTween(duration, func)
|
{
|
||||||
, delta_val_(0.f)
|
ActionFadeToPtr ptr = new (std::nothrow) ActionFadeTo;
|
||||||
|
if (ptr)
|
||||||
|
{
|
||||||
|
ptr->SetDuration(duration);
|
||||||
|
ptr->SetTargetOpacity(opacity);
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
ActionFadeTo::ActionFadeTo()
|
||||||
|
: delta_val_(0.0f)
|
||||||
, start_val_(0.f)
|
, start_val_(0.f)
|
||||||
, end_val_(opacity)
|
, end_val_(0.0f)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -352,27 +402,49 @@ void ActionFadeTo::UpdateTween(Actor* target, float percent)
|
||||||
|
|
||||||
ActionPtr ActionFadeTo::Clone() const
|
ActionPtr ActionFadeTo::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) ActionFadeTo(GetDuration(), end_val_, GetEaseFunc());
|
return ActionFadeTo::Create(GetDuration(), end_val_);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionFadeIn::ActionFadeIn(Duration duration, EaseFunc func)
|
ActionFadeInPtr ActionFadeIn::Create(Duration duration)
|
||||||
: ActionFadeTo(duration, 1, func)
|
|
||||||
{
|
{
|
||||||
|
ActionFadeInPtr ptr = new (std::nothrow) ActionFadeIn;
|
||||||
|
if (ptr)
|
||||||
|
{
|
||||||
|
ptr->SetDuration(duration);
|
||||||
|
ptr->SetTargetOpacity(1.0f);
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionFadeOut::ActionFadeOut(Duration duration, EaseFunc func)
|
ActionFadeOutPtr ActionFadeOut::Create(Duration duration)
|
||||||
: ActionFadeTo(duration, 0, func)
|
|
||||||
{
|
{
|
||||||
|
ActionFadeOutPtr ptr = new (std::nothrow) ActionFadeOut;
|
||||||
|
if (ptr)
|
||||||
|
{
|
||||||
|
ptr->SetDuration(duration);
|
||||||
|
ptr->SetTargetOpacity(0.0f);
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
// Rotate Action
|
// Rotate Action
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
ActionRotateBy::ActionRotateBy(Duration duration, float rotation, EaseFunc func)
|
ActionRotateByPtr ActionRotateBy::Create(Duration duration, float rotation)
|
||||||
: ActionTween(duration, func)
|
{
|
||||||
, start_val_()
|
ActionRotateByPtr ptr = new (std::nothrow) ActionRotateBy;
|
||||||
, delta_val_(rotation)
|
if (ptr)
|
||||||
|
{
|
||||||
|
ptr->SetDuration(duration);
|
||||||
|
ptr->SetRotation(rotation);
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
ActionRotateBy::ActionRotateBy()
|
||||||
|
: start_val_(0.0f)
|
||||||
|
, delta_val_(0.0f)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -395,23 +467,33 @@ void ActionRotateBy::UpdateTween(Actor* target, float percent)
|
||||||
|
|
||||||
ActionPtr ActionRotateBy::Clone() const
|
ActionPtr ActionRotateBy::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) ActionRotateBy(GetDuration(), delta_val_, GetEaseFunc());
|
return ActionRotateBy::Create(GetDuration(), delta_val_);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr ActionRotateBy::Reverse() const
|
ActionPtr ActionRotateBy::Reverse() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) ActionRotateBy(GetDuration(), -delta_val_, GetEaseFunc());
|
return ActionRotateBy::Create(GetDuration(), -delta_val_);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionRotateTo::ActionRotateTo(Duration duration, float rotation, EaseFunc func)
|
ActionRotateToPtr ActionRotateTo::Create(Duration duration, float rotation)
|
||||||
: ActionRotateBy(duration, 0, func)
|
{
|
||||||
|
ActionRotateToPtr ptr = new (std::nothrow) ActionRotateTo;
|
||||||
|
if (ptr)
|
||||||
|
{
|
||||||
|
ptr->SetDuration(duration);
|
||||||
|
ptr->SetTargetRotation(rotation);
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
ActionRotateTo::ActionRotateTo()
|
||||||
|
: end_val_(0.0f)
|
||||||
{
|
{
|
||||||
end_val_ = rotation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr ActionRotateTo::Clone() const
|
ActionPtr ActionRotateTo::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) ActionRotateTo(GetDuration(), end_val_, GetEaseFunc());
|
return ActionRotateTo::Create(GetDuration(), end_val_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionRotateTo::Init(Actor* target)
|
void ActionRotateTo::Init(Actor* target)
|
||||||
|
|
@ -424,15 +506,22 @@ void ActionRotateTo::Init(Actor* target)
|
||||||
// ActionCustom
|
// ActionCustom
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
ActionCustom::ActionCustom(Duration duration, TweenFunc tween_func, EaseFunc func)
|
ActionCustomPtr ActionCustom::Create(Duration duration, TweenFunc tween_func)
|
||||||
: ActionTween(duration, func)
|
|
||||||
, tween_func_(tween_func)
|
|
||||||
{
|
{
|
||||||
|
ActionCustomPtr ptr = new (std::nothrow) ActionCustom;
|
||||||
|
if (ptr)
|
||||||
|
{
|
||||||
|
ptr->SetDuration(duration);
|
||||||
|
ptr->SetTweenFunc(tween_func);
|
||||||
}
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
ActionCustom::ActionCustom() {}
|
||||||
|
|
||||||
ActionPtr ActionCustom::Clone() const
|
ActionPtr ActionCustom::Clone() const
|
||||||
{
|
{
|
||||||
return new ActionCustom(GetDuration(), tween_func_);
|
return ActionCustom::Create(GetDuration(), tween_func_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionCustom::Init(Actor* target)
|
void ActionCustom::Init(Actor* target)
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ public:
|
||||||
/// @brief 补间动画
|
/// @brief 补间动画
|
||||||
/// @param duration 动画时长
|
/// @param duration 动画时长
|
||||||
/// @param func 动画速度缓动函数
|
/// @param func 动画速度缓动函数
|
||||||
ActionTween(Duration duration, EaseFunc func);
|
ActionTween(Duration duration, EaseFunc ease);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取动画时长
|
/// @brief 获取动画时长
|
||||||
|
|
@ -130,11 +130,20 @@ class KGE_API ActionMoveBy : public ActionTween
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 构造相对位移动画
|
/// @brief 创建相对位移动画
|
||||||
/// @param duration 动画时长
|
/// @param duration 动画时长
|
||||||
/// @param vector 移动向量
|
/// @param displacement 位移向量
|
||||||
/// @param func 动画速度缓动函数
|
static ActionMoveByPtr Create(Duration duration, Vec2 const& displacement);
|
||||||
ActionMoveBy(Duration duration, Vec2 const& vector, EaseFunc func = nullptr);
|
|
||||||
|
ActionMoveBy();
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取位移向量
|
||||||
|
Vec2 GetDisplacement() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置位移向量
|
||||||
|
void SetDisplacement(Vec2 const& displacement);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取该动画的拷贝对象
|
/// @brief 获取该动画的拷贝对象
|
||||||
|
|
@ -152,7 +161,7 @@ protected:
|
||||||
protected:
|
protected:
|
||||||
Point start_pos_;
|
Point start_pos_;
|
||||||
Point prev_pos_;
|
Point prev_pos_;
|
||||||
Vec2 delta_pos_;
|
Vec2 displacement_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -161,11 +170,20 @@ class KGE_API ActionMoveTo : public ActionMoveBy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 构造位移动画
|
/// @brief 创建位移动画
|
||||||
/// @param duration 动画时长
|
/// @param duration 动画时长
|
||||||
/// @param pos 目的坐标
|
/// @param distination 目的坐标
|
||||||
/// @param func 动画速度缓动函数
|
static ActionMoveToPtr Create(Duration duration, Point const& distination);
|
||||||
ActionMoveTo(Duration duration, Point const& pos, EaseFunc func = nullptr);
|
|
||||||
|
ActionMoveTo();
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取目的坐标
|
||||||
|
Point GetDistination() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置目的坐标
|
||||||
|
void SetDistination(Point const& distination);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取该动画的拷贝对象
|
/// @brief 获取该动画的拷贝对象
|
||||||
|
|
@ -183,7 +201,7 @@ protected:
|
||||||
void Init(Actor* target) override;
|
void Init(Actor* target) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Point end_pos_;
|
Point distination_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -192,13 +210,39 @@ class KGE_API ActionJumpBy : public ActionTween
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 构造相对跳跃动画
|
/// @brief 创建相对跳跃动画
|
||||||
/// @param duration 动画时长
|
/// @param duration 动画时长
|
||||||
/// @param vec 跳跃位移向量
|
/// @param displacement 跳跃位移向量
|
||||||
/// @param height 跳跃高度
|
/// @param height 跳跃高度
|
||||||
/// @param jumps 跳跃次数
|
/// @param count 跳跃次数
|
||||||
/// @param func 动画速度缓动函数
|
static ActionJumpByPtr Create(Duration duration, Vec2 const& displacement, float height, int count = 1,
|
||||||
ActionJumpBy(Duration duration, Vec2 const& vec, float height, int jumps = 1, EaseFunc func = nullptr);
|
EaseFunc ease = nullptr);
|
||||||
|
|
||||||
|
ActionJumpBy();
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取跳跃位移
|
||||||
|
Vec2 GetDisplacement() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取跳跃高度
|
||||||
|
float GetJumpHeight() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取跳跃次数
|
||||||
|
int GetJumpCount() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置跳跃位移
|
||||||
|
void SetDisplacement(Vec2 const& displacement);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置跳跃高度
|
||||||
|
void SetJumpHeight(float height);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置跳跃次数
|
||||||
|
void SetJumpCount(int count);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取该动画的拷贝对象
|
/// @brief 获取该动画的拷贝对象
|
||||||
|
|
@ -214,10 +258,10 @@ protected:
|
||||||
void UpdateTween(Actor* target, float percent) override;
|
void UpdateTween(Actor* target, float percent) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Point start_pos_;
|
|
||||||
Point delta_pos_;
|
|
||||||
float height_;
|
float height_;
|
||||||
int jumps_;
|
int jump_count_;
|
||||||
|
Point start_pos_;
|
||||||
|
Point displacement_;
|
||||||
Point prev_pos_;
|
Point prev_pos_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -227,13 +271,23 @@ class KGE_API ActionJumpTo : public ActionJumpBy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 构造跳跃动画
|
/// @brief 创建跳跃动画
|
||||||
/// @param duration 动画时长
|
/// @param duration 动画时长
|
||||||
/// @param pos 目的坐标
|
/// @param distination 目的坐标
|
||||||
/// @param height 跳跃高度
|
/// @param height 跳跃高度
|
||||||
/// @param jumps 跳跃次数
|
/// @param count 跳跃次数
|
||||||
/// @param func 动画速度缓动函数
|
static ActionJumpToPtr Create(Duration duration, Point const& distination, float height, int count = 1,
|
||||||
ActionJumpTo(Duration duration, Point const& pos, float height, int jumps = 1, EaseFunc func = nullptr);
|
EaseFunc ease = nullptr);
|
||||||
|
|
||||||
|
ActionJumpTo();
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取目的坐标
|
||||||
|
Point GetDistination() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置目的坐标
|
||||||
|
void SetDistination(Point const& distination);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取该动画的拷贝对象
|
/// @brief 获取该动画的拷贝对象
|
||||||
|
|
@ -251,7 +305,7 @@ protected:
|
||||||
void Init(Actor* target) override;
|
void Init(Actor* target) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Point end_pos_;
|
Point distination_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -260,12 +314,29 @@ class KGE_API ActionScaleBy : public ActionTween
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 构造相对缩放动画
|
/// @brief 创建相对缩放动画
|
||||||
/// @param duration 动画时长
|
/// @param duration 动画时长
|
||||||
/// @param scale_x 横向缩放相对变化值
|
/// @param scale_x 横向缩放相对变化值
|
||||||
/// @param scale_y 纵向缩放相对变化值
|
/// @param scale_y 纵向缩放相对变化值
|
||||||
/// @param func 动画速度缓动函数
|
static ActionScaleByPtr Create(Duration duration, float scale_x, float scale_y);
|
||||||
ActionScaleBy(Duration duration, float scale_x, float scale_y, EaseFunc func = nullptr);
|
|
||||||
|
ActionScaleBy();
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取横向缩放相对变化值
|
||||||
|
float GetScaleX() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取横向缩放相对变化值
|
||||||
|
float GetScaleY() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置纵向缩放相对变化值
|
||||||
|
void SetScaleX(float scale_x);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置纵向缩放相对变化值
|
||||||
|
void SetScaleY(float scale_y);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取该动画的拷贝对象
|
/// @brief 获取该动画的拷贝对象
|
||||||
|
|
@ -293,12 +364,29 @@ class KGE_API ActionScaleTo : public ActionScaleBy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 构造缩放动画
|
/// @brief 创建缩放动画
|
||||||
/// @param duration 动画时长
|
/// @param duration 动画时长
|
||||||
/// @param scale_x 横向缩放目标值
|
/// @param scale_x 横向缩放目标值
|
||||||
/// @param scale_y 纵向缩放目标值
|
/// @param scale_y 纵向缩放目标值
|
||||||
/// @param func 动画速度缓动函数
|
static ActionScaleToPtr Create(Duration duration, float scale_x, float scale_y);
|
||||||
ActionScaleTo(Duration duration, float scale_x, float scale_y, EaseFunc func = nullptr);
|
|
||||||
|
ActionScaleTo();
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取横向缩放目标值
|
||||||
|
float GetTargetScaleX() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取横向缩放目标值
|
||||||
|
float GetTargetScaleY() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置纵向缩放目标值
|
||||||
|
void SetTargetScaleX(float scale_x);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置纵向缩放目标值
|
||||||
|
void SetTargetScaleY(float scale_y);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取该动画的拷贝对象
|
/// @brief 获取该动画的拷贝对象
|
||||||
|
|
@ -326,11 +414,20 @@ class KGE_API ActionFadeTo : public ActionTween
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 构造透明度渐变动画
|
/// @brief 创建透明度渐变动画
|
||||||
/// @param duration 动画时长
|
/// @param duration 动画时长
|
||||||
/// @param opacity 目标透明度
|
/// @param opacity 目标透明度
|
||||||
/// @param func 动画速度缓动函数
|
static ActionFadeToPtr Create(Duration duration, float opacity);
|
||||||
ActionFadeTo(Duration duration, float opacity, EaseFunc func = nullptr);
|
|
||||||
|
ActionFadeTo();
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取目标透明度
|
||||||
|
float GetTargetOpacity() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置目标透明度
|
||||||
|
void SetTargetOpacity(float opacity);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取该动画的拷贝对象
|
/// @brief 获取该动画的拷贝对象
|
||||||
|
|
@ -361,10 +458,9 @@ class KGE_API ActionFadeIn : public ActionFadeTo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 构造淡入动画
|
/// @brief 创建淡入动画
|
||||||
/// @param duration 动画时长
|
/// @param duration 动画时长
|
||||||
/// @param func 动画速度缓动函数
|
static ActionFadeInPtr Create(Duration duration);
|
||||||
explicit ActionFadeIn(Duration duration, EaseFunc func = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -373,10 +469,9 @@ class KGE_API ActionFadeOut : public ActionFadeTo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 构造淡出动画
|
/// @brief 创建淡出动画
|
||||||
/// @param duration 动画时长
|
/// @param duration 动画时长
|
||||||
/// @param func 动画速度缓动函数
|
static ActionFadeOutPtr Create(Duration duration);
|
||||||
explicit ActionFadeOut(Duration duration, EaseFunc func = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
|
|
@ -385,11 +480,20 @@ class KGE_API ActionRotateBy : public ActionTween
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 构造相对旋转动画
|
/// @brief 创建相对旋转动画
|
||||||
/// @param duration 动画时长
|
/// @param duration 动画时长
|
||||||
/// @param rotation 角度相对变化值
|
/// @param rotation 角度相对变化值
|
||||||
/// @param func 动画速度缓动函数
|
static ActionRotateByPtr Create(Duration duration, float rotation);
|
||||||
ActionRotateBy(Duration duration, float rotation, EaseFunc func = nullptr);
|
|
||||||
|
ActionRotateBy();
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取角度相对变化值
|
||||||
|
float GetRotation() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置角度相对变化值
|
||||||
|
void SetRotation(float rotation);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取该动画的拷贝对象
|
/// @brief 获取该动画的拷贝对象
|
||||||
|
|
@ -415,11 +519,20 @@ class KGE_API ActionRotateTo : public ActionRotateBy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 构造旋转动画
|
/// @brief 创建旋转动画
|
||||||
/// @param duration 动画时长
|
/// @param duration 动画时长
|
||||||
/// @param rotation 目标角度
|
/// @param rotation 目标角度
|
||||||
/// @param func 动画速度缓动函数
|
static ActionRotateToPtr Create(Duration duration, float rotation);
|
||||||
ActionRotateTo(Duration duration, float rotation, EaseFunc func = nullptr);
|
|
||||||
|
ActionRotateTo();
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取目标角度
|
||||||
|
float GetTargetRotation() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置目标角度
|
||||||
|
void SetTargetRotation(float rotation);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取该动画的拷贝对象
|
/// @brief 获取该动画的拷贝对象
|
||||||
|
|
@ -451,11 +564,20 @@ public:
|
||||||
using TweenFunc = Function<void(Actor* /* target */, float /* percent */)>;
|
using TweenFunc = Function<void(Actor* /* target */, float /* percent */)>;
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 构造自定义动画
|
/// @brief 创建自定义动画
|
||||||
/// @param duration 动画时长
|
/// @param duration 动画时长
|
||||||
/// @param tween_func 动画回调函数
|
/// @param tween_func 动画回调函数
|
||||||
/// @param func 动画速度缓动函数
|
static ActionCustomPtr Create(Duration duration, TweenFunc tween_func);
|
||||||
ActionCustom(Duration duration, TweenFunc tween_func, EaseFunc func = nullptr);
|
|
||||||
|
ActionCustom();
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取动画回调函数
|
||||||
|
TweenFunc GetTweenFunc() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置动画回调函数
|
||||||
|
void SetTweenFunc(TweenFunc const& tween_func);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取该动画的拷贝对象
|
/// @brief 获取该动画的拷贝对象
|
||||||
|
|
@ -480,4 +602,164 @@ private:
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
inline EaseFunc const& ActionTween::GetEaseFunc() const
|
||||||
|
{
|
||||||
|
return ease_func_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Duration ActionTween::GetDuration() const
|
||||||
|
{
|
||||||
|
return dur_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void ActionTween::SetDuration(Duration duration)
|
||||||
|
{
|
||||||
|
dur_ = duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void ActionTween::SetEaseFunc(EaseFunc const& func)
|
||||||
|
{
|
||||||
|
ease_func_ = func;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vec2 ActionMoveBy::GetDisplacement() const
|
||||||
|
{
|
||||||
|
return displacement_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void ActionMoveBy::SetDisplacement(Vec2 const& displacement)
|
||||||
|
{
|
||||||
|
displacement_ = displacement;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Point ActionMoveTo::GetDistination() const
|
||||||
|
{
|
||||||
|
return distination_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void ActionMoveTo::SetDistination(Point const& distination)
|
||||||
|
{
|
||||||
|
distination_ = distination;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vec2 ActionJumpBy::GetDisplacement() const
|
||||||
|
{
|
||||||
|
return displacement_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float ActionJumpBy::GetJumpHeight() const
|
||||||
|
{
|
||||||
|
return height_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int ActionJumpBy::GetJumpCount() const
|
||||||
|
{
|
||||||
|
return jump_count_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void ActionJumpBy::SetDisplacement(Vec2 const& displacement)
|
||||||
|
{
|
||||||
|
displacement_ = displacement;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void ActionJumpBy::SetJumpHeight(float height)
|
||||||
|
{
|
||||||
|
height_ = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void ActionJumpBy::SetJumpCount(int count)
|
||||||
|
{
|
||||||
|
jump_count_ = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Point ActionJumpTo::GetDistination() const
|
||||||
|
{
|
||||||
|
return distination_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void ActionJumpTo::SetDistination(Point const& distination)
|
||||||
|
{
|
||||||
|
distination_ = distination;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float ActionScaleBy::GetScaleX() const
|
||||||
|
{
|
||||||
|
return delta_x_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float ActionScaleBy::GetScaleY() const
|
||||||
|
{
|
||||||
|
return delta_y_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void ActionScaleBy::SetScaleX(float scale_x)
|
||||||
|
{
|
||||||
|
delta_x_ = scale_x;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void ActionScaleBy::SetScaleY(float scale_y)
|
||||||
|
{
|
||||||
|
delta_y_ = scale_y;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float ActionScaleTo::GetTargetScaleX() const
|
||||||
|
{
|
||||||
|
return end_scale_x_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float ActionScaleTo::GetTargetScaleY() const
|
||||||
|
{
|
||||||
|
return end_scale_y_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void ActionScaleTo::SetTargetScaleX(float scale_x)
|
||||||
|
{
|
||||||
|
end_scale_x_ = scale_x;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void ActionScaleTo::SetTargetScaleY(float scale_y)
|
||||||
|
{
|
||||||
|
end_scale_y_ = scale_y;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float ActionFadeTo::GetTargetOpacity() const
|
||||||
|
{
|
||||||
|
return end_val_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void ActionFadeTo::SetTargetOpacity(float opacity)
|
||||||
|
{
|
||||||
|
end_val_ = opacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float ActionRotateBy::GetRotation() const
|
||||||
|
{
|
||||||
|
return delta_val_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void ActionRotateBy::SetRotation(float rotation)
|
||||||
|
{
|
||||||
|
delta_val_ = rotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float ActionRotateTo::GetTargetRotation() const
|
||||||
|
{
|
||||||
|
return end_val_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void ActionRotateTo::SetTargetRotation(float rotation)
|
||||||
|
{
|
||||||
|
end_val_ = rotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ActionCustom::TweenFunc ActionCustom::GetTweenFunc() const
|
||||||
|
{
|
||||||
|
return tween_func_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void ActionCustom::SetTweenFunc(TweenFunc const& tween_func)
|
||||||
|
{
|
||||||
|
tween_func_ = tween_func;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace kiwano
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -23,39 +23,37 @@
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
ActionWalk::ActionWalk(Duration duration, bool rotating, float start, float end, EaseFunc func)
|
|
||||||
: ActionTween(duration, func)
|
ActionWalkPtr ActionWalk::Create(Duration duration, ShapePtr path, bool rotating, float start, float end)
|
||||||
, start_(start)
|
{
|
||||||
, end_(end)
|
ActionWalkPtr ptr = new (std::nothrow) ActionWalk;
|
||||||
, rotating_(rotating)
|
if (ptr)
|
||||||
|
{
|
||||||
|
ptr->SetDuration(duration);
|
||||||
|
ptr->SetPath(path);
|
||||||
|
ptr->SetRotating(rotating);
|
||||||
|
ptr->SetStartValue(start);
|
||||||
|
ptr->SetEndValue(end);
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
ActionWalk::ActionWalk()
|
||||||
|
: start_(0.0f)
|
||||||
|
, end_(1.0f)
|
||||||
|
, rotating_(false)
|
||||||
, length_(0.f)
|
, length_(0.f)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionWalk::ActionWalk(Duration duration, ShapePtr path, bool rotating, float start, float end, EaseFunc func)
|
|
||||||
: ActionWalk(duration, rotating, start, end, func)
|
|
||||||
{
|
|
||||||
path_ = path;
|
|
||||||
}
|
|
||||||
|
|
||||||
ActionPtr ActionWalk::Clone() const
|
ActionPtr ActionWalk::Clone() const
|
||||||
{
|
{
|
||||||
ActionWalkPtr clone = new ActionWalk(GetDuration(), rotating_, start_, end_, GetEaseFunc());
|
return ActionWalk::Create(GetDuration(), path_, rotating_, start_, end_);
|
||||||
if (clone)
|
|
||||||
{
|
|
||||||
clone->SetPath(path_);
|
|
||||||
}
|
|
||||||
return clone;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr ActionWalk::Reverse() const
|
ActionPtr ActionWalk::Reverse() const
|
||||||
{
|
{
|
||||||
ActionWalkPtr reverse = new ActionWalk(GetDuration(), rotating_, end_, start_, GetEaseFunc());
|
return ActionWalk::Create(GetDuration(), path_, rotating_, end_, start_);
|
||||||
if (reverse)
|
|
||||||
{
|
|
||||||
reverse->SetPath(path_);
|
|
||||||
}
|
|
||||||
return reverse;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionWalk::Init(Actor* target)
|
void ActionWalk::Init(Actor* target)
|
||||||
|
|
|
||||||
|
|
@ -38,24 +38,48 @@ class KGE_API ActionWalk : public ActionTween
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 构造路径行走动画
|
/// @brief 创建路径行走动画
|
||||||
/// @param duration 持续时长
|
|
||||||
/// @param rotating 是否沿路径切线方向旋转
|
|
||||||
/// @param start 路径起点(百分比)
|
|
||||||
/// @param end 路径终点(百分比)
|
|
||||||
/// @param func 动画速度缓动函数
|
|
||||||
ActionWalk(Duration duration, bool rotating = false, float start = 0.f, float end = 1.f, EaseFunc func = nullptr);
|
|
||||||
|
|
||||||
/// \~chinese
|
|
||||||
/// @brief 构造路径行走动画
|
|
||||||
/// @param duration 持续时长
|
/// @param duration 持续时长
|
||||||
/// @param path 路径形状
|
/// @param path 路径形状
|
||||||
/// @param rotating 是否沿路径切线方向旋转
|
/// @param rotating 是否沿路径切线方向旋转
|
||||||
/// @param start 路径起点(百分比)
|
/// @param start 路径起点(百分比)
|
||||||
/// @param end 路径终点(百分比)
|
/// @param end 路径终点(百分比)
|
||||||
/// @param func 动画速度缓动函数
|
static ActionWalkPtr Create(Duration duration, ShapePtr path, bool rotating = false, float start = 0.f,
|
||||||
ActionWalk(Duration duration, ShapePtr path, bool rotating = false, float start = 0.f, float end = 1.f,
|
float end = 1.f);
|
||||||
EaseFunc func = nullptr);
|
|
||||||
|
ActionWalk();
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取路线
|
||||||
|
ShapePtr GetPath() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 是否沿路径切线方向旋转
|
||||||
|
bool IsRotating() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取路径起点(百分比)
|
||||||
|
float GetStartValue() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 获取路径终点(百分比)
|
||||||
|
float GetEndValue() const;
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置路径形状
|
||||||
|
void SetPath(ShapePtr path);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置沿路径切线方向旋转
|
||||||
|
void SetRotating(bool rotating);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置路径起点(百分比)
|
||||||
|
void SetStartValue(float start);
|
||||||
|
|
||||||
|
/// \~chinese
|
||||||
|
/// @brief 设置路径终点(百分比)
|
||||||
|
void SetEndValue(float end);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 获取该动画的拷贝对象
|
/// @brief 获取该动画的拷贝对象
|
||||||
|
|
@ -65,14 +89,6 @@ public:
|
||||||
/// @brief 获取该动画的倒转
|
/// @brief 获取该动画的倒转
|
||||||
ActionPtr Reverse() const override;
|
ActionPtr Reverse() const override;
|
||||||
|
|
||||||
/// \~chinese
|
|
||||||
/// @brief 获取路线
|
|
||||||
ShapePtr const& GetPath() const;
|
|
||||||
|
|
||||||
/// \~chinese
|
|
||||||
/// @brief 设置路径形状
|
|
||||||
void SetPath(ShapePtr path);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Init(Actor* target) override;
|
void Init(Actor* target) override;
|
||||||
|
|
||||||
|
|
@ -89,13 +105,44 @@ private:
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
inline ShapePtr const& ActionWalk::GetPath() const
|
inline ShapePtr ActionWalk::GetPath() const
|
||||||
{
|
{
|
||||||
return path_;
|
return path_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool ActionWalk::IsRotating() const
|
||||||
|
{
|
||||||
|
return rotating_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float ActionWalk::GetStartValue() const
|
||||||
|
{
|
||||||
|
return start_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float ActionWalk::GetEndValue() const
|
||||||
|
{
|
||||||
|
return end_;
|
||||||
|
}
|
||||||
|
|
||||||
inline void ActionWalk::SetPath(ShapePtr path)
|
inline void ActionWalk::SetPath(ShapePtr path)
|
||||||
{
|
{
|
||||||
path_ = path;
|
path_ = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void ActionWalk::SetRotating(bool rotating)
|
||||||
|
{
|
||||||
|
rotating_ = rotating;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void ActionWalk::SetStartValue(float start)
|
||||||
|
{
|
||||||
|
start_ = start;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void ActionWalk::SetEndValue(float end)
|
||||||
|
{
|
||||||
|
end_ = end;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace kiwano
|
} // namespace kiwano
|
||||||
|
|
|
||||||
|
|
@ -24,18 +24,23 @@
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
||||||
|
AnimationPtr Animation::Create(Duration duration, FrameSequencePtr frame_seq)
|
||||||
|
{
|
||||||
|
AnimationPtr ptr = new (std::nothrow) Animation;
|
||||||
|
if (ptr)
|
||||||
|
{
|
||||||
|
ptr->SetDuration(duration);
|
||||||
|
ptr->SetFrameSequence(frame_seq);
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
Animation::Animation()
|
Animation::Animation()
|
||||||
: frame_seq_(nullptr)
|
: frame_seq_(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Animation::Animation(Duration duration, FrameSequencePtr frame_seq, EaseFunc func)
|
|
||||||
: ActionTween(duration, func)
|
|
||||||
, frame_seq_(nullptr)
|
|
||||||
{
|
|
||||||
this->SetFrameSequence(frame_seq);
|
|
||||||
}
|
|
||||||
|
|
||||||
Animation::~Animation() {}
|
Animation::~Animation() {}
|
||||||
|
|
||||||
FrameSequencePtr Animation::GetFrameSequence() const
|
FrameSequencePtr Animation::GetFrameSequence() const
|
||||||
|
|
@ -84,7 +89,7 @@ ActionPtr Animation::Clone() const
|
||||||
{
|
{
|
||||||
if (frame_seq_)
|
if (frame_seq_)
|
||||||
{
|
{
|
||||||
return new (std::nothrow) Animation(GetDuration(), frame_seq_, GetEaseFunc());
|
return Animation::Create(GetDuration(), frame_seq_);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
@ -96,7 +101,7 @@ ActionPtr Animation::Reverse() const
|
||||||
FrameSequencePtr frames = frame_seq_->Reverse();
|
FrameSequencePtr frames = frame_seq_->Reverse();
|
||||||
if (frames)
|
if (frames)
|
||||||
{
|
{
|
||||||
return new (std::nothrow) Animation(GetDuration(), frames, GetEaseFunc());
|
return Animation::Create(GetDuration(), frames);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
||||||
|
|
@ -36,14 +36,13 @@ KGE_DECLARE_SMART_PTR(Animation);
|
||||||
class KGE_API Animation : public ActionTween
|
class KGE_API Animation : public ActionTween
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Animation();
|
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief 构建帧动画
|
/// @brief 创建帧动画
|
||||||
/// @param duration 动画时长
|
/// @param duration 动画时长
|
||||||
/// @param[in] frame_seq 序列帧
|
/// @param[in] frame_seq 序列帧
|
||||||
/// @param func 动画速度缓动函数
|
static AnimationPtr Create(Duration duration, FrameSequencePtr frame_seq);
|
||||||
Animation(Duration duration, FrameSequencePtr frame_seq, EaseFunc func = nullptr);
|
|
||||||
|
Animation();
|
||||||
|
|
||||||
virtual ~Animation();
|
virtual ~Animation();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,4 +43,5 @@ struct ComPtrProxy
|
||||||
// ComPtr<> is a smart pointer for COM
|
// ComPtr<> is a smart pointer for COM
|
||||||
template <typename _Ty, typename = typename std::enable_if<std::is_base_of<IUnknown, _Ty>::value, int>::type>
|
template <typename _Ty, typename = typename std::enable_if<std::is_base_of<IUnknown, _Ty>::value, int>::type>
|
||||||
using ComPtr = IntrusivePtr<_Ty, ComPtrProxy>;
|
using ComPtr = IntrusivePtr<_Ty, ComPtrProxy>;
|
||||||
|
|
||||||
} // namespace kiwano
|
} // namespace kiwano
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue