refactoring actions
This commit is contained in:
parent
946dfb8314
commit
2c1cef7e4d
|
|
@ -34,9 +34,8 @@ namespace easy2d
|
||||||
, protected IntrusiveListItem<ActionPtr>
|
, protected IntrusiveListItem<ActionPtr>
|
||||||
{
|
{
|
||||||
friend class ActionManager;
|
friend class ActionManager;
|
||||||
friend class Loop;
|
friend class ActionSequence;
|
||||||
friend class Sequence;
|
friend class ActionSpawn;
|
||||||
friend class Spawn;
|
|
||||||
friend class IntrusiveList<ActionPtr>;
|
friend class IntrusiveList<ActionPtr>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -24,23 +24,23 @@
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
// Sequence
|
// ActionSequence
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
Sequence::Sequence()
|
ActionSequence::ActionSequence()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Sequence::Sequence(Array<ActionPtr> const& actions)
|
ActionSequence::ActionSequence(Array<ActionPtr> const& actions)
|
||||||
{
|
{
|
||||||
this->Add(actions);
|
this->Add(actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
Sequence::~Sequence()
|
ActionSequence::~ActionSequence()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sequence::Init(NodePtr const& target)
|
void ActionSequence::Init(NodePtr const& target)
|
||||||
{
|
{
|
||||||
if (actions_.IsEmpty())
|
if (actions_.IsEmpty())
|
||||||
Done();
|
Done();
|
||||||
|
|
@ -51,7 +51,7 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sequence::Update(NodePtr const& target, Duration dt)
|
void ActionSequence::Update(NodePtr const& target, Duration dt)
|
||||||
{
|
{
|
||||||
if (current_)
|
if (current_)
|
||||||
{
|
{
|
||||||
|
|
@ -71,7 +71,7 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sequence::Add(ActionPtr const& action)
|
void ActionSequence::Add(ActionPtr const& action)
|
||||||
{
|
{
|
||||||
if (action)
|
if (action)
|
||||||
{
|
{
|
||||||
|
|
@ -79,15 +79,15 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sequence::Add(Array<ActionPtr> const& actions)
|
void ActionSequence::Add(Array<ActionPtr> const& actions)
|
||||||
{
|
{
|
||||||
for (const auto& action : actions)
|
for (const auto& action : actions)
|
||||||
Add(action);
|
Add(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr Sequence::Clone() const
|
ActionPtr ActionSequence::Clone() const
|
||||||
{
|
{
|
||||||
auto sequence = new (std::nothrow) Sequence();
|
auto sequence = new (std::nothrow) ActionSequence();
|
||||||
if (sequence)
|
if (sequence)
|
||||||
{
|
{
|
||||||
for (auto action = actions_.First(); action; action = action->NextItem())
|
for (auto action = actions_.First(); action; action = action->NextItem())
|
||||||
|
|
@ -101,9 +101,9 @@ namespace easy2d
|
||||||
return sequence;
|
return sequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr Sequence::Reverse() const
|
ActionPtr ActionSequence::Reverse() const
|
||||||
{
|
{
|
||||||
auto sequence = new (std::nothrow) Sequence();
|
auto sequence = new (std::nothrow) ActionSequence();
|
||||||
if (sequence && !actions_.IsEmpty())
|
if (sequence && !actions_.IsEmpty())
|
||||||
{
|
{
|
||||||
for (auto action = actions_.Last(); action; action = action->PrevItem())
|
for (auto action = actions_.Last(); action; action = action->PrevItem())
|
||||||
|
|
@ -116,25 +116,25 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
// Spawn
|
// ActionSpawn
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
Spawn::Spawn()
|
ActionSpawn::ActionSpawn()
|
||||||
: size_(0)
|
: size_(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Spawn::Spawn(Array<ActionPtr> const& actions)
|
ActionSpawn::ActionSpawn(Array<ActionPtr> const& actions)
|
||||||
: size_(0)
|
: size_(0)
|
||||||
{
|
{
|
||||||
this->Add(actions);
|
this->Add(actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
Spawn::~Spawn()
|
ActionSpawn::~ActionSpawn()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spawn::Init(NodePtr const& target)
|
void ActionSpawn::Init(NodePtr const& target)
|
||||||
{
|
{
|
||||||
if (actions_.IsEmpty())
|
if (actions_.IsEmpty())
|
||||||
Done();
|
Done();
|
||||||
|
|
@ -147,7 +147,7 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spawn::Update(NodePtr const& target, Duration dt)
|
void ActionSpawn::Update(NodePtr const& target, Duration dt)
|
||||||
{
|
{
|
||||||
int done_num = 0;
|
int done_num = 0;
|
||||||
for (auto action = actions_.First(); action; action = action->NextItem())
|
for (auto action = actions_.First(); action; action = action->NextItem())
|
||||||
|
|
@ -168,7 +168,7 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spawn::Add(ActionPtr const& action)
|
void ActionSpawn::Add(ActionPtr const& action)
|
||||||
{
|
{
|
||||||
if (action)
|
if (action)
|
||||||
{
|
{
|
||||||
|
|
@ -177,15 +177,15 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spawn::Add(Array<ActionPtr> const& actions)
|
void ActionSpawn::Add(Array<ActionPtr> const& actions)
|
||||||
{
|
{
|
||||||
for (const auto& action : actions)
|
for (const auto& action : actions)
|
||||||
Add(action);
|
Add(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr Spawn::Clone() const
|
ActionPtr ActionSpawn::Clone() const
|
||||||
{
|
{
|
||||||
auto spawn = new (std::nothrow) Spawn();
|
auto spawn = new (std::nothrow) ActionSpawn();
|
||||||
if (spawn)
|
if (spawn)
|
||||||
{
|
{
|
||||||
for (auto action = actions_.First(); action; action = action->NextItem())
|
for (auto action = actions_.First(); action; action = action->NextItem())
|
||||||
|
|
@ -196,9 +196,9 @@ namespace easy2d
|
||||||
return spawn;
|
return spawn;
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr Spawn::Reverse() const
|
ActionPtr ActionSpawn::Reverse() const
|
||||||
{
|
{
|
||||||
auto spawn = new (std::nothrow) Spawn();
|
auto spawn = new (std::nothrow) ActionSpawn();
|
||||||
if (spawn && !actions_.IsEmpty())
|
if (spawn && !actions_.IsEmpty())
|
||||||
{
|
{
|
||||||
for (auto action = actions_.Last(); action; action = action->PrevItem())
|
for (auto action = actions_.Last(); action; action = action->PrevItem())
|
||||||
|
|
|
||||||
|
|
@ -24,17 +24,17 @@
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
// 顺序动作
|
// 顺序动作
|
||||||
class E2D_API Sequence
|
class E2D_API ActionSequence
|
||||||
: public Action
|
: public Action
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Sequence();
|
ActionSequence();
|
||||||
|
|
||||||
explicit Sequence(
|
explicit ActionSequence(
|
||||||
Array<ActionPtr> const& actions /* 动作列表 */
|
Array<ActionPtr> const& actions /* 动作列表 */
|
||||||
);
|
);
|
||||||
|
|
||||||
virtual ~Sequence();
|
virtual ~ActionSequence();
|
||||||
|
|
||||||
// 在结尾添加动作
|
// 在结尾添加动作
|
||||||
void Add(
|
void Add(
|
||||||
|
|
@ -66,17 +66,17 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 同步动作
|
// 同步动作
|
||||||
class E2D_API Spawn
|
class E2D_API ActionSpawn
|
||||||
: public Action
|
: public Action
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Spawn();
|
ActionSpawn();
|
||||||
|
|
||||||
explicit Spawn(
|
explicit ActionSpawn(
|
||||||
Array<ActionPtr> const& actions /* 动作列表 */
|
Array<ActionPtr> const& actions /* 动作列表 */
|
||||||
);
|
);
|
||||||
|
|
||||||
virtual ~Spawn();
|
virtual ~ActionSpawn();
|
||||||
|
|
||||||
// 在结尾添加动作
|
// 在结尾添加动作
|
||||||
void Add(
|
void Add(
|
||||||
|
|
|
||||||
|
|
@ -94,13 +94,13 @@ namespace easy2d
|
||||||
static inline TweenHelper
|
static inline TweenHelper
|
||||||
MoveBy(Point const& vector)
|
MoveBy(Point const& vector)
|
||||||
{
|
{
|
||||||
return TweenHelper(new easy2d::MoveBy(0, vector));
|
return TweenHelper(new easy2d::ActionMoveBy(0, vector));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline TweenHelper
|
static inline TweenHelper
|
||||||
MoveTo(Point const& pos)
|
MoveTo(Point const& pos)
|
||||||
{
|
{
|
||||||
return TweenHelper(new easy2d::MoveTo(0, pos));
|
return TweenHelper(new easy2d::ActionMoveTo(0, pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline TweenHelper
|
static inline TweenHelper
|
||||||
|
|
@ -109,7 +109,7 @@ namespace easy2d
|
||||||
float height, /* 跳跃高度 */
|
float height, /* 跳跃高度 */
|
||||||
int jumps = 1) /* 跳跃次数 */
|
int jumps = 1) /* 跳跃次数 */
|
||||||
{
|
{
|
||||||
return TweenHelper(new easy2d::JumpBy(0, pos, height, jumps));
|
return TweenHelper(new easy2d::ActionJumpBy(0, pos, height, jumps));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline TweenHelper
|
static inline TweenHelper
|
||||||
|
|
@ -118,67 +118,67 @@ namespace easy2d
|
||||||
float height, /* 跳跃高度 */
|
float height, /* 跳跃高度 */
|
||||||
int jumps = 1) /* 跳跃次数 */
|
int jumps = 1) /* 跳跃次数 */
|
||||||
{
|
{
|
||||||
return TweenHelper(new easy2d::JumpTo(0, pos, height, jumps));
|
return TweenHelper(new easy2d::ActionJumpTo(0, pos, height, jumps));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline TweenHelper
|
static inline TweenHelper
|
||||||
ScaleBy(float scale)
|
ScaleBy(float scale)
|
||||||
{
|
{
|
||||||
return TweenHelper(new easy2d::ScaleBy(0, scale));
|
return TweenHelper(new easy2d::ActionScaleBy(0, scale));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline TweenHelper
|
static inline TweenHelper
|
||||||
ScaleBy(float scale_x, float scale_y)
|
ScaleBy(float scale_x, float scale_y)
|
||||||
{
|
{
|
||||||
return TweenHelper(new easy2d::ScaleBy(0, scale_x, scale_y));
|
return TweenHelper(new easy2d::ActionScaleBy(0, scale_x, scale_y));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline TweenHelper
|
static inline TweenHelper
|
||||||
ScaleTo(float scale)
|
ScaleTo(float scale)
|
||||||
{
|
{
|
||||||
return TweenHelper(new easy2d::ScaleTo(0, scale));
|
return TweenHelper(new easy2d::ActionScaleTo(0, scale));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline TweenHelper
|
static inline TweenHelper
|
||||||
ScaleTo(float scale_x, float scale_y)
|
ScaleTo(float scale_x, float scale_y)
|
||||||
{
|
{
|
||||||
return TweenHelper(new easy2d::ScaleTo(0, scale_x, scale_y));
|
return TweenHelper(new easy2d::ActionScaleTo(0, scale_x, scale_y));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline TweenHelper
|
static inline TweenHelper
|
||||||
OpacityBy(float opacity)
|
OpacityBy(float opacity)
|
||||||
{
|
{
|
||||||
return TweenHelper(new easy2d::OpacityBy(0, opacity));
|
return TweenHelper(new easy2d::ActionOpacityBy(0, opacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline TweenHelper
|
static inline TweenHelper
|
||||||
OpacityTo(float opacity)
|
OpacityTo(float opacity)
|
||||||
{
|
{
|
||||||
return TweenHelper(new easy2d::OpacityTo(0, opacity));
|
return TweenHelper(new easy2d::ActionOpacityTo(0, opacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline TweenHelper
|
static inline TweenHelper
|
||||||
FadeIn(Duration dur)
|
FadeIn(Duration dur)
|
||||||
{
|
{
|
||||||
return TweenHelper(new easy2d::FadeIn(dur));
|
return TweenHelper(new easy2d::ActionFadeIn(dur));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline TweenHelper
|
static inline TweenHelper
|
||||||
FadeOut(Duration dur)
|
FadeOut(Duration dur)
|
||||||
{
|
{
|
||||||
return TweenHelper(new easy2d::FadeOut(dur));
|
return TweenHelper(new easy2d::ActionFadeOut(dur));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline TweenHelper
|
static inline TweenHelper
|
||||||
RotateBy(float rotation)
|
RotateBy(float rotation)
|
||||||
{
|
{
|
||||||
return TweenHelper(new easy2d::RotateBy(0, rotation));
|
return TweenHelper(new easy2d::ActionRotateBy(0, rotation));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline TweenHelper
|
static inline TweenHelper
|
||||||
RotateTo(float rotation)
|
RotateTo(float rotation)
|
||||||
{
|
{
|
||||||
return TweenHelper(new easy2d::RotateTo(0, rotation));
|
return TweenHelper(new easy2d::ActionRotateTo(0, rotation));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline TweenHelper
|
static inline TweenHelper
|
||||||
|
|
@ -188,7 +188,7 @@ namespace easy2d
|
||||||
float start = 0.f, /* 起点 */
|
float start = 0.f, /* 起点 */
|
||||||
float end = 1.f) /* 终点 */
|
float end = 1.f) /* 终点 */
|
||||||
{
|
{
|
||||||
return TweenHelper(new easy2d::PathAction(0, geo, rotating, start, end));
|
return TweenHelper(new easy2d::ActionPath(0, geo, rotating, start, end));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline TweenHelper
|
static inline TweenHelper
|
||||||
|
|
@ -200,13 +200,13 @@ namespace easy2d
|
||||||
static inline ActionHelper
|
static inline ActionHelper
|
||||||
Sequence(Array<ActionPtr> const& actions)
|
Sequence(Array<ActionPtr> const& actions)
|
||||||
{
|
{
|
||||||
return ActionHelper(new easy2d::Sequence(actions));
|
return ActionHelper(new easy2d::ActionSequence(actions));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline ActionHelper
|
static inline ActionHelper
|
||||||
Spawn(Array<ActionPtr> const& actions)
|
Spawn(Array<ActionPtr> const& actions)
|
||||||
{
|
{
|
||||||
return ActionHelper(new easy2d::Spawn(actions));
|
return ActionHelper(new easy2d::ActionSpawn(actions));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -129,13 +129,13 @@ namespace easy2d
|
||||||
// Move Action
|
// Move Action
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
MoveBy::MoveBy(Duration duration, Point const& vector, EaseFunc func)
|
ActionMoveBy::ActionMoveBy(Duration duration, Point const& vector, EaseFunc func)
|
||||||
: ActionTween(duration, func)
|
: ActionTween(duration, func)
|
||||||
{
|
{
|
||||||
delta_pos_ = vector;
|
delta_pos_ = vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveBy::Init(NodePtr const& target)
|
void ActionMoveBy::Init(NodePtr const& target)
|
||||||
{
|
{
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
|
|
@ -143,7 +143,7 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveBy::UpdateTween(NodePtr const& target, float percent)
|
void ActionMoveBy::UpdateTween(NodePtr const& 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;
|
||||||
|
|
@ -154,30 +154,30 @@ namespace easy2d
|
||||||
prev_pos_ = new_pos;
|
prev_pos_ = new_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr MoveBy::Clone() const
|
ActionPtr ActionMoveBy::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) MoveBy(dur_, delta_pos_, ease_func_);
|
return new (std::nothrow) ActionMoveBy(dur_, delta_pos_, ease_func_);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr MoveBy::Reverse() const
|
ActionPtr ActionMoveBy::Reverse() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) MoveBy(dur_, -delta_pos_, ease_func_);
|
return new (std::nothrow) ActionMoveBy(dur_, -delta_pos_, ease_func_);
|
||||||
}
|
}
|
||||||
|
|
||||||
MoveTo::MoveTo(Duration duration, Point const& pos, EaseFunc func)
|
ActionMoveTo::ActionMoveTo(Duration duration, Point const& pos, EaseFunc func)
|
||||||
: MoveBy(duration, Point(), func)
|
: ActionMoveBy(duration, Point(), func)
|
||||||
{
|
{
|
||||||
end_pos_ = pos;
|
end_pos_ = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr MoveTo::Clone() const
|
ActionPtr ActionMoveTo::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) MoveTo(dur_, end_pos_, ease_func_);
|
return new (std::nothrow) ActionMoveTo(dur_, end_pos_, ease_func_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveTo::Init(NodePtr const& target)
|
void ActionMoveTo::Init(NodePtr const& target)
|
||||||
{
|
{
|
||||||
MoveBy::Init(target);
|
ActionMoveBy::Init(target);
|
||||||
delta_pos_ = end_pos_ - start_pos_;
|
delta_pos_ = end_pos_ - start_pos_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -186,7 +186,7 @@ namespace easy2d
|
||||||
// Jump Action
|
// Jump Action
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
JumpBy::JumpBy(Duration duration, Point const& vec, float height, int jumps, EaseFunc func)
|
ActionJumpBy::ActionJumpBy(Duration duration, Point const& vec, float height, int jumps, EaseFunc func)
|
||||||
: ActionTween(duration, func)
|
: ActionTween(duration, func)
|
||||||
, delta_pos_(vec)
|
, delta_pos_(vec)
|
||||||
, height_(height)
|
, height_(height)
|
||||||
|
|
@ -194,17 +194,17 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr JumpBy::Clone() const
|
ActionPtr ActionJumpBy::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) JumpBy(dur_, delta_pos_, height_, jumps_, ease_func_);
|
return new (std::nothrow) ActionJumpBy(dur_, delta_pos_, height_, jumps_, ease_func_);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr JumpBy::Reverse() const
|
ActionPtr ActionJumpBy::Reverse() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) JumpBy(dur_, -delta_pos_, height_, jumps_, ease_func_);
|
return new (std::nothrow) ActionJumpBy(dur_, -delta_pos_, height_, jumps_, ease_func_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JumpBy::Init(NodePtr const& target)
|
void ActionJumpBy::Init(NodePtr const& target)
|
||||||
{
|
{
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
|
|
@ -212,7 +212,7 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void JumpBy::UpdateTween(NodePtr const& target, float percent)
|
void ActionJumpBy::UpdateTween(NodePtr const& target, float percent)
|
||||||
{
|
{
|
||||||
float frac = fmod(percent * jumps_, 1.f);
|
float frac = fmod(percent * jumps_, 1.f);
|
||||||
float x = delta_pos_.x * percent;
|
float x = delta_pos_.x * percent;
|
||||||
|
|
@ -228,20 +228,20 @@ namespace easy2d
|
||||||
prev_pos_ = new_pos;
|
prev_pos_ = new_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
JumpTo::JumpTo(Duration duration, Point const& pos, float height, int jumps, EaseFunc func)
|
ActionJumpTo::ActionJumpTo(Duration duration, Point const& pos, float height, int jumps, EaseFunc func)
|
||||||
: JumpBy(duration, Point(), height, jumps, func)
|
: ActionJumpBy(duration, Point(), height, jumps, func)
|
||||||
, end_pos_(pos)
|
, end_pos_(pos)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr JumpTo::Clone() const
|
ActionPtr ActionJumpTo::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) JumpTo(dur_, end_pos_, height_, jumps_, ease_func_);
|
return new (std::nothrow) ActionJumpTo(dur_, end_pos_, height_, jumps_, ease_func_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JumpTo::Init(NodePtr const& target)
|
void ActionJumpTo::Init(NodePtr const& target)
|
||||||
{
|
{
|
||||||
JumpBy::Init(target);
|
ActionJumpBy::Init(target);
|
||||||
delta_pos_ = end_pos_ - start_pos_;
|
delta_pos_ = end_pos_ - start_pos_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -250,21 +250,21 @@ namespace easy2d
|
||||||
// Scale Action
|
// Scale Action
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
ScaleBy::ScaleBy(Duration duration, float scale, EaseFunc func)
|
ActionScaleBy::ActionScaleBy(Duration duration, float scale, EaseFunc func)
|
||||||
: ActionTween(duration, func)
|
: ActionTween(duration, func)
|
||||||
{
|
{
|
||||||
delta_x_ = scale;
|
delta_x_ = scale;
|
||||||
delta_y_ = scale;
|
delta_y_ = scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScaleBy::ScaleBy(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_x_ = scale_x;
|
||||||
delta_y_ = scale_y;
|
delta_y_ = scale_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScaleBy::Init(NodePtr const& target)
|
void ActionScaleBy::Init(NodePtr const& target)
|
||||||
{
|
{
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
|
|
@ -273,43 +273,43 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScaleBy::UpdateTween(NodePtr const& target, float percent)
|
void ActionScaleBy::UpdateTween(NodePtr const& target, float percent)
|
||||||
{
|
{
|
||||||
target->SetScale(start_scale_x_ + delta_x_ * percent, start_scale_y_ + delta_y_ * percent);
|
target->SetScale(start_scale_x_ + delta_x_ * percent, start_scale_y_ + delta_y_ * percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr ScaleBy::Clone() const
|
ActionPtr ActionScaleBy::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) ScaleBy(dur_, delta_x_, delta_y_, ease_func_);
|
return new (std::nothrow) ActionScaleBy(dur_, delta_x_, delta_y_, ease_func_);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr ScaleBy::Reverse() const
|
ActionPtr ActionScaleBy::Reverse() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) ScaleBy(dur_, -delta_x_, -delta_y_, ease_func_);
|
return new (std::nothrow) ActionScaleBy(dur_, -delta_x_, -delta_y_, ease_func_);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScaleTo::ScaleTo(Duration duration, float scale, EaseFunc func)
|
ActionScaleTo::ActionScaleTo(Duration duration, float scale, EaseFunc func)
|
||||||
: ScaleBy(duration, 0, 0, func)
|
: ActionScaleBy(duration, 0, 0, func)
|
||||||
{
|
{
|
||||||
end_scale_x_ = scale;
|
end_scale_x_ = scale;
|
||||||
end_scale_y_ = scale;
|
end_scale_y_ = scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScaleTo::ScaleTo(Duration duration, float scale_x, float scale_y, EaseFunc func)
|
ActionScaleTo::ActionScaleTo(Duration duration, float scale_x, float scale_y, EaseFunc func)
|
||||||
: ScaleBy(duration, 0, 0, func)
|
: ActionScaleBy(duration, 0, 0, func)
|
||||||
{
|
{
|
||||||
end_scale_x_ = scale_x;
|
end_scale_x_ = scale_x;
|
||||||
end_scale_y_ = scale_y;
|
end_scale_y_ = scale_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr ScaleTo::Clone() const
|
ActionPtr ActionScaleTo::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) ScaleTo(dur_, end_scale_x_, end_scale_y_, ease_func_);
|
return new (std::nothrow) ActionScaleTo(dur_, end_scale_x_, end_scale_y_, ease_func_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScaleTo::Init(NodePtr const& target)
|
void ActionScaleTo::Init(NodePtr const& target)
|
||||||
{
|
{
|
||||||
ScaleBy::Init(target);
|
ActionScaleBy::Init(target);
|
||||||
delta_x_ = end_scale_x_ - start_scale_x_;
|
delta_x_ = end_scale_x_ - start_scale_x_;
|
||||||
delta_y_ = end_scale_y_ - start_scale_y_;
|
delta_y_ = end_scale_y_ - start_scale_y_;
|
||||||
}
|
}
|
||||||
|
|
@ -319,13 +319,13 @@ namespace easy2d
|
||||||
// Opacity Action
|
// Opacity Action
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
OpacityBy::OpacityBy(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 OpacityBy::Init(NodePtr const& target)
|
void ActionOpacityBy::Init(NodePtr const& target)
|
||||||
{
|
{
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
|
|
@ -333,45 +333,45 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpacityBy::UpdateTween(NodePtr const& target, float percent)
|
void ActionOpacityBy::UpdateTween(NodePtr const& target, float percent)
|
||||||
{
|
{
|
||||||
target->SetOpacity(start_val_ + delta_val_ * percent);
|
target->SetOpacity(start_val_ + delta_val_ * percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr OpacityBy::Clone() const
|
ActionPtr ActionOpacityBy::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) OpacityBy(dur_, delta_val_, ease_func_);
|
return new (std::nothrow) ActionOpacityBy(dur_, delta_val_, ease_func_);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr OpacityBy::Reverse() const
|
ActionPtr ActionOpacityBy::Reverse() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) OpacityBy(dur_, -delta_val_, ease_func_);
|
return new (std::nothrow) ActionOpacityBy(dur_, -delta_val_, ease_func_);
|
||||||
}
|
}
|
||||||
|
|
||||||
OpacityTo::OpacityTo(Duration duration, float opacity, EaseFunc func)
|
ActionOpacityTo::ActionOpacityTo(Duration duration, float opacity, EaseFunc func)
|
||||||
: OpacityBy(duration, 0, func)
|
: ActionOpacityBy(duration, 0, func)
|
||||||
{
|
{
|
||||||
end_val_ = opacity;
|
end_val_ = opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr OpacityTo::Clone() const
|
ActionPtr ActionOpacityTo::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) OpacityTo(dur_, end_val_, ease_func_);
|
return new (std::nothrow) ActionOpacityTo(dur_, end_val_, ease_func_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpacityTo::Init(NodePtr const& target)
|
void ActionOpacityTo::Init(NodePtr const& target)
|
||||||
{
|
{
|
||||||
OpacityBy::Init(target);
|
ActionOpacityBy::Init(target);
|
||||||
delta_val_ = end_val_ - start_val_;
|
delta_val_ = end_val_ - start_val_;
|
||||||
}
|
}
|
||||||
|
|
||||||
FadeIn::FadeIn(Duration duration, EaseFunc func)
|
ActionFadeIn::ActionFadeIn(Duration duration, EaseFunc func)
|
||||||
: OpacityTo(duration, 1, func)
|
: ActionOpacityTo(duration, 1, func)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FadeOut::FadeOut(Duration duration, EaseFunc func)
|
ActionFadeOut::ActionFadeOut(Duration duration, EaseFunc func)
|
||||||
: OpacityTo(duration, 0, func)
|
: ActionOpacityTo(duration, 0, func)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -380,13 +380,13 @@ namespace easy2d
|
||||||
// Rotate Action
|
// Rotate Action
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
RotateBy::RotateBy(Duration duration, float rotation, EaseFunc func)
|
ActionRotateBy::ActionRotateBy(Duration duration, float rotation, EaseFunc func)
|
||||||
: ActionTween(duration, func)
|
: ActionTween(duration, func)
|
||||||
, delta_val_(rotation)
|
, delta_val_(rotation)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void RotateBy::Init(NodePtr const& target)
|
void ActionRotateBy::Init(NodePtr const& target)
|
||||||
{
|
{
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
|
|
@ -394,7 +394,7 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RotateBy::UpdateTween(NodePtr const& target, float percent)
|
void ActionRotateBy::UpdateTween(NodePtr const& target, float percent)
|
||||||
{
|
{
|
||||||
float rotation = start_val_ + delta_val_ * percent;
|
float rotation = start_val_ + delta_val_ * percent;
|
||||||
if (rotation > 360.f)
|
if (rotation > 360.f)
|
||||||
|
|
@ -403,39 +403,39 @@ namespace easy2d
|
||||||
target->SetRotation(rotation);
|
target->SetRotation(rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr RotateBy::Clone() const
|
ActionPtr ActionRotateBy::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) RotateBy(dur_, delta_val_, ease_func_);
|
return new (std::nothrow) ActionRotateBy(dur_, delta_val_, ease_func_);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr RotateBy::Reverse() const
|
ActionPtr ActionRotateBy::Reverse() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) RotateBy(dur_, -delta_val_, ease_func_);
|
return new (std::nothrow) ActionRotateBy(dur_, -delta_val_, ease_func_);
|
||||||
}
|
}
|
||||||
|
|
||||||
RotateTo::RotateTo(Duration duration, float rotation, EaseFunc func)
|
ActionRotateTo::ActionRotateTo(Duration duration, float rotation, EaseFunc func)
|
||||||
: RotateBy(duration, 0, func)
|
: ActionRotateBy(duration, 0, func)
|
||||||
{
|
{
|
||||||
end_val_ = rotation;
|
end_val_ = rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr RotateTo::Clone() const
|
ActionPtr ActionRotateTo::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) RotateTo(dur_, end_val_, ease_func_);
|
return new (std::nothrow) ActionRotateTo(dur_, end_val_, ease_func_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RotateTo::Init(NodePtr const& target)
|
void ActionRotateTo::Init(NodePtr const& target)
|
||||||
{
|
{
|
||||||
RotateBy::Init(target);
|
ActionRotateBy::Init(target);
|
||||||
delta_val_ = end_val_ - start_val_;
|
delta_val_ = end_val_ - start_val_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
// PathAction
|
// ActionPath
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
PathAction::PathAction(Duration duration, GeometryPtr const& geo, bool rotating, float start, float end, EaseFunc func)
|
ActionPath::ActionPath(Duration duration, GeometryPtr const& geo, bool rotating, float start, float end, EaseFunc func)
|
||||||
: ActionTween(duration, func)
|
: ActionTween(duration, func)
|
||||||
, start_(start)
|
, start_(start)
|
||||||
, end_(end)
|
, end_(end)
|
||||||
|
|
@ -444,22 +444,22 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr PathAction::Clone() const
|
ActionPtr ActionPath::Clone() const
|
||||||
{
|
{
|
||||||
return new PathAction(dur_, geo_, rotating_, start_, end_, ease_func_);
|
return new ActionPath(dur_, geo_, rotating_, start_, end_, ease_func_);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr PathAction::Reverse() const
|
ActionPtr ActionPath::Reverse() const
|
||||||
{
|
{
|
||||||
return new PathAction(dur_, geo_, rotating_, end_, start_, ease_func_);
|
return new ActionPath(dur_, geo_, rotating_, end_, start_, ease_func_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathAction::Init(NodePtr const& target)
|
void ActionPath::Init(NodePtr const& target)
|
||||||
{
|
{
|
||||||
start_pos_ = target->GetPosition();
|
start_pos_ = target->GetPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathAction::UpdateTween(NodePtr const& target, float percent)
|
void ActionPath::UpdateTween(NodePtr const& target, float percent)
|
||||||
{
|
{
|
||||||
float length = geo_->GetLength() * std::min(std::max((end_ - start_) * percent + start_, 0.f), 1.f);
|
float length = geo_->GetLength() * std::min(std::max((end_ - start_) * percent + start_, 0.f), 1.f);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "Action.h"
|
#include "Action.h"
|
||||||
#include "logs.h"
|
#include "logs.h"
|
||||||
#include "Geometry.h" // PathAction
|
#include "Geometry.h" // ActionPath
|
||||||
#include "../math/ease.hpp"
|
#include "../math/ease.hpp"
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
|
|
@ -109,11 +109,11 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 相对位移动作
|
// 相对位移动作
|
||||||
class E2D_API MoveBy
|
class E2D_API ActionMoveBy
|
||||||
: public ActionTween
|
: public ActionTween
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MoveBy(
|
ActionMoveBy(
|
||||||
Duration duration, /* 持续时长 */
|
Duration duration, /* 持续时长 */
|
||||||
Point const& vector, /* 移动距离 */
|
Point const& vector, /* 移动距离 */
|
||||||
EaseFunc func = nullptr /* 速度变化 */
|
EaseFunc func = nullptr /* 速度变化 */
|
||||||
|
|
@ -138,11 +138,11 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 位移动作
|
// 位移动作
|
||||||
class E2D_API MoveTo
|
class E2D_API ActionMoveTo
|
||||||
: public MoveBy
|
: public ActionMoveBy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MoveTo(
|
ActionMoveTo(
|
||||||
Duration duration, /* 持续时长 */
|
Duration duration, /* 持续时长 */
|
||||||
Point const& pos, /* 目的坐标 */
|
Point const& pos, /* 目的坐标 */
|
||||||
EaseFunc func = nullptr /* 速度变化 */
|
EaseFunc func = nullptr /* 速度变化 */
|
||||||
|
|
@ -154,7 +154,7 @@ namespace easy2d
|
||||||
// 获取该动作的倒转
|
// 获取该动作的倒转
|
||||||
virtual ActionPtr Reverse() const override
|
virtual ActionPtr Reverse() const override
|
||||||
{
|
{
|
||||||
E2D_ERROR_LOG(L"Reverse() not supported in MoveTo");
|
E2D_ERROR_LOG(L"Reverse() not supported in ActionMoveTo");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -167,11 +167,11 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 相对跳跃动作
|
// 相对跳跃动作
|
||||||
class E2D_API JumpBy
|
class E2D_API ActionJumpBy
|
||||||
: public ActionTween
|
: public ActionTween
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
JumpBy(
|
ActionJumpBy(
|
||||||
Duration duration, /* 持续时长 */
|
Duration duration, /* 持续时长 */
|
||||||
Point const& vec, /* 跳跃距离 */
|
Point const& vec, /* 跳跃距离 */
|
||||||
float height, /* 跳跃高度 */
|
float height, /* 跳跃高度 */
|
||||||
|
|
@ -200,11 +200,11 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 跳跃动作
|
// 跳跃动作
|
||||||
class E2D_API JumpTo
|
class E2D_API ActionJumpTo
|
||||||
: public JumpBy
|
: public ActionJumpBy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
JumpTo(
|
ActionJumpTo(
|
||||||
Duration duration, /* 持续时长 */
|
Duration duration, /* 持续时长 */
|
||||||
Point const& pos, /* 目的坐标 */
|
Point const& pos, /* 目的坐标 */
|
||||||
float height, /* 跳跃高度 */
|
float height, /* 跳跃高度 */
|
||||||
|
|
@ -218,7 +218,7 @@ namespace easy2d
|
||||||
// 获取该动作的倒转
|
// 获取该动作的倒转
|
||||||
virtual ActionPtr Reverse() const override
|
virtual ActionPtr Reverse() const override
|
||||||
{
|
{
|
||||||
E2D_ERROR_LOG(L"Reverse() not supported in JumpTo");
|
E2D_ERROR_LOG(L"Reverse() not supported in ActionJumpTo");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -231,17 +231,17 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 相对缩放动作
|
// 相对缩放动作
|
||||||
class E2D_API ScaleBy
|
class E2D_API ActionScaleBy
|
||||||
: public ActionTween
|
: public ActionTween
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ScaleBy(
|
ActionScaleBy(
|
||||||
Duration duration, /* 持续时长 */
|
Duration duration, /* 持续时长 */
|
||||||
float scale, /* 相对变化值 */
|
float scale, /* 相对变化值 */
|
||||||
EaseFunc func = nullptr /* 速度变化 */
|
EaseFunc func = nullptr /* 速度变化 */
|
||||||
);
|
);
|
||||||
|
|
||||||
ScaleBy(
|
ActionScaleBy(
|
||||||
Duration duration, /* 持续时长 */
|
Duration duration, /* 持续时长 */
|
||||||
float scale_x, /* 横向缩放相对变化值 */
|
float scale_x, /* 横向缩放相对变化值 */
|
||||||
float scale_y, /* 纵向缩放相对变化值 */
|
float scale_y, /* 纵向缩放相对变化值 */
|
||||||
|
|
@ -268,17 +268,17 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 缩放动作
|
// 缩放动作
|
||||||
class E2D_API ScaleTo
|
class E2D_API ActionScaleTo
|
||||||
: public ScaleBy
|
: public ActionScaleBy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ScaleTo(
|
ActionScaleTo(
|
||||||
Duration duration, /* 持续时长 */
|
Duration duration, /* 持续时长 */
|
||||||
float scale, /* 目标值 */
|
float scale, /* 目标值 */
|
||||||
EaseFunc func = nullptr /* 速度变化 */
|
EaseFunc func = nullptr /* 速度变化 */
|
||||||
);
|
);
|
||||||
|
|
||||||
ScaleTo(
|
ActionScaleTo(
|
||||||
Duration duration, /* 持续时长 */
|
Duration duration, /* 持续时长 */
|
||||||
float scale_x, /* 横向缩放目标值 */
|
float scale_x, /* 横向缩放目标值 */
|
||||||
float scale_y, /* 纵向缩放目标值 */
|
float scale_y, /* 纵向缩放目标值 */
|
||||||
|
|
@ -291,7 +291,7 @@ namespace easy2d
|
||||||
// 获取该动作的倒转
|
// 获取该动作的倒转
|
||||||
virtual ActionPtr Reverse() const override
|
virtual ActionPtr Reverse() const override
|
||||||
{
|
{
|
||||||
E2D_ERROR_LOG(L"Reverse() not supported in ScaleTo");
|
E2D_ERROR_LOG(L"Reverse() not supported in ActionScaleTo");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -305,11 +305,11 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 透明度相对渐变动作
|
// 透明度相对渐变动作
|
||||||
class E2D_API OpacityBy
|
class E2D_API ActionOpacityBy
|
||||||
: public ActionTween
|
: public ActionTween
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OpacityBy(
|
ActionOpacityBy(
|
||||||
Duration duration, /* 持续时长 */
|
Duration duration, /* 持续时长 */
|
||||||
float opacity, /* 相对变化值 */
|
float opacity, /* 相对变化值 */
|
||||||
EaseFunc func = nullptr /* 速度变化 */
|
EaseFunc func = nullptr /* 速度变化 */
|
||||||
|
|
@ -333,11 +333,11 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 透明度渐变动作
|
// 透明度渐变动作
|
||||||
class E2D_API OpacityTo
|
class E2D_API ActionOpacityTo
|
||||||
: public OpacityBy
|
: public ActionOpacityBy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OpacityTo(
|
ActionOpacityTo(
|
||||||
Duration duration, /* 持续时长 */
|
Duration duration, /* 持续时长 */
|
||||||
float opacity, /* 目标值 */
|
float opacity, /* 目标值 */
|
||||||
EaseFunc func = nullptr /* 速度变化 */
|
EaseFunc func = nullptr /* 速度变化 */
|
||||||
|
|
@ -349,7 +349,7 @@ namespace easy2d
|
||||||
// 获取该动作的倒转
|
// 获取该动作的倒转
|
||||||
virtual ActionPtr Reverse() const override
|
virtual ActionPtr Reverse() const override
|
||||||
{
|
{
|
||||||
E2D_ERROR_LOG(L"Reverse() not supported in OpacityTo");
|
E2D_ERROR_LOG(L"Reverse() not supported in ActionOpacityTo");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -362,12 +362,12 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 淡入动作
|
// 淡入动作
|
||||||
class E2D_API FadeIn
|
class E2D_API ActionFadeIn
|
||||||
: public OpacityTo
|
: public ActionOpacityTo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// 创建淡入动作
|
// 创建淡入动作
|
||||||
explicit FadeIn(
|
explicit ActionFadeIn(
|
||||||
Duration duration, /* 持续时长 */
|
Duration duration, /* 持续时长 */
|
||||||
EaseFunc func = nullptr /* 速度变化 */
|
EaseFunc func = nullptr /* 速度变化 */
|
||||||
);
|
);
|
||||||
|
|
@ -375,12 +375,12 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 淡出动作
|
// 淡出动作
|
||||||
class E2D_API FadeOut
|
class E2D_API ActionFadeOut
|
||||||
: public OpacityTo
|
: public ActionOpacityTo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// 创建淡出动作
|
// 创建淡出动作
|
||||||
explicit FadeOut(
|
explicit ActionFadeOut(
|
||||||
Duration duration, /* 持续时长 */
|
Duration duration, /* 持续时长 */
|
||||||
EaseFunc func = Ease::Linear /* 速度变化 */
|
EaseFunc func = Ease::Linear /* 速度变化 */
|
||||||
);
|
);
|
||||||
|
|
@ -388,11 +388,11 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 相对旋转动作
|
// 相对旋转动作
|
||||||
class E2D_API RotateBy
|
class E2D_API ActionRotateBy
|
||||||
: public ActionTween
|
: public ActionTween
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RotateBy(
|
ActionRotateBy(
|
||||||
Duration duration, /* 持续时长 */
|
Duration duration, /* 持续时长 */
|
||||||
float rotation, /* 相对变化值 */
|
float rotation, /* 相对变化值 */
|
||||||
EaseFunc func = nullptr /* 速度变化 */
|
EaseFunc func = nullptr /* 速度变化 */
|
||||||
|
|
@ -416,11 +416,11 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 旋转动作
|
// 旋转动作
|
||||||
class E2D_API RotateTo
|
class E2D_API ActionRotateTo
|
||||||
: public RotateBy
|
: public ActionRotateBy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RotateTo(
|
ActionRotateTo(
|
||||||
Duration duration, /* 持续时长 */
|
Duration duration, /* 持续时长 */
|
||||||
float rotation, /* 目标值 */
|
float rotation, /* 目标值 */
|
||||||
EaseFunc func = nullptr /* 速度变化 */
|
EaseFunc func = nullptr /* 速度变化 */
|
||||||
|
|
@ -432,7 +432,7 @@ namespace easy2d
|
||||||
// 获取该动作的倒转
|
// 获取该动作的倒转
|
||||||
virtual ActionPtr Reverse() const override
|
virtual ActionPtr Reverse() const override
|
||||||
{
|
{
|
||||||
E2D_ERROR_LOG(L"Reverse() not supported in RotateTo");
|
E2D_ERROR_LOG(L"Reverse() not supported in ActionRotateTo");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -445,11 +445,11 @@ namespace easy2d
|
||||||
|
|
||||||
|
|
||||||
// 路径动作
|
// 路径动作
|
||||||
class E2D_API PathAction
|
class E2D_API ActionPath
|
||||||
: public ActionTween
|
: public ActionTween
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PathAction(
|
ActionPath(
|
||||||
Duration duration, /* 持续时长 */
|
Duration duration, /* 持续时长 */
|
||||||
GeometryPtr const& geo, /* 几何图形 */
|
GeometryPtr const& geo, /* 几何图形 */
|
||||||
bool rotating = false, /* 沿路径切线方向旋转 */
|
bool rotating = false, /* 沿路径切线方向旋转 */
|
||||||
|
|
|
||||||
|
|
@ -99,22 +99,22 @@ namespace easy2d
|
||||||
|
|
||||||
E2D_DECLARE_SMART_PTR(Action);
|
E2D_DECLARE_SMART_PTR(Action);
|
||||||
E2D_DECLARE_SMART_PTR(ActionTween);
|
E2D_DECLARE_SMART_PTR(ActionTween);
|
||||||
E2D_DECLARE_SMART_PTR(MoveBy);
|
E2D_DECLARE_SMART_PTR(ActionMoveBy);
|
||||||
E2D_DECLARE_SMART_PTR(MoveTo);
|
E2D_DECLARE_SMART_PTR(ActionMoveTo);
|
||||||
E2D_DECLARE_SMART_PTR(JumpBy);
|
E2D_DECLARE_SMART_PTR(ActionJumpBy);
|
||||||
E2D_DECLARE_SMART_PTR(JumpTo);
|
E2D_DECLARE_SMART_PTR(ActionJumpTo);
|
||||||
E2D_DECLARE_SMART_PTR(ScaleBy);
|
E2D_DECLARE_SMART_PTR(ActionScaleBy);
|
||||||
E2D_DECLARE_SMART_PTR(ScaleTo);
|
E2D_DECLARE_SMART_PTR(ActionScaleTo);
|
||||||
E2D_DECLARE_SMART_PTR(OpacityBy);
|
E2D_DECLARE_SMART_PTR(ActionOpacityBy);
|
||||||
E2D_DECLARE_SMART_PTR(OpacityTo);
|
E2D_DECLARE_SMART_PTR(ActionOpacityTo);
|
||||||
E2D_DECLARE_SMART_PTR(FadeIn);
|
E2D_DECLARE_SMART_PTR(ActionFadeIn);
|
||||||
E2D_DECLARE_SMART_PTR(FadeOut);
|
E2D_DECLARE_SMART_PTR(ActionFadeOut);
|
||||||
E2D_DECLARE_SMART_PTR(RotateBy);
|
E2D_DECLARE_SMART_PTR(ActionRotateBy);
|
||||||
E2D_DECLARE_SMART_PTR(RotateTo);
|
E2D_DECLARE_SMART_PTR(ActionRotateTo);
|
||||||
E2D_DECLARE_SMART_PTR(PathAction);
|
E2D_DECLARE_SMART_PTR(ActionPath);
|
||||||
E2D_DECLARE_SMART_PTR(Animation);
|
E2D_DECLARE_SMART_PTR(Animation);
|
||||||
E2D_DECLARE_SMART_PTR(Sequence);
|
E2D_DECLARE_SMART_PTR(ActionSequence);
|
||||||
E2D_DECLARE_SMART_PTR(Spawn);
|
E2D_DECLARE_SMART_PTR(ActionSpawn);
|
||||||
|
|
||||||
E2D_DECLARE_SMART_PTR(Transition);
|
E2D_DECLARE_SMART_PTR(Transition);
|
||||||
E2D_DECLARE_SMART_PTR(FadeTransition);
|
E2D_DECLARE_SMART_PTR(FadeTransition);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue