[deploy] Update Action::Clone
This commit is contained in:
parent
876035ccae
commit
d31c66a60e
|
|
@ -155,8 +155,7 @@ FrameSequencePtr FrameSequence::Reverse() const
|
|||
{
|
||||
for (auto iter = frames_.crbegin(), crend = frames_.crend(); iter != crend; ++iter)
|
||||
{
|
||||
if (*iter)
|
||||
frame_seq->AddFrame(*iter);
|
||||
frame_seq->AddFrame(*iter);
|
||||
}
|
||||
}
|
||||
return frame_seq;
|
||||
|
|
|
|||
|
|
@ -105,4 +105,17 @@ void Action::Restart(Actor* target)
|
|||
Init(target);
|
||||
}
|
||||
|
||||
ActionPtr Action::InnerClone(ActionPtr to) const
|
||||
{
|
||||
if (to)
|
||||
{
|
||||
to->SetDelay(this->GetDelay());
|
||||
to->SetDoneCallback(this->GetDoneCallback());
|
||||
to->SetLoopDoneCallback(this->GetLoopDoneCallback());
|
||||
to->SetLoops(this->GetLoops());
|
||||
to->SetName(this->GetName());
|
||||
}
|
||||
return to;
|
||||
}
|
||||
|
||||
} // namespace kiwano
|
||||
|
|
|
|||
|
|
@ -178,6 +178,9 @@ protected:
|
|||
/// @brief 是否可移除
|
||||
bool IsRemoveable() const;
|
||||
|
||||
protected:
|
||||
ActionPtr InnerClone(ActionPtr to) const;
|
||||
|
||||
private:
|
||||
Status status_;
|
||||
bool running_;
|
||||
|
|
|
|||
|
|
@ -35,12 +35,12 @@ ActionDelayPtr ActionDelay::Create(Duration delay)
|
|||
|
||||
ActionPtr ActionDelay::Clone() const
|
||||
{
|
||||
return ActionDelay::Create(GetDelay());
|
||||
return InnerClone(ActionDelay::Create(GetDelay()));
|
||||
}
|
||||
|
||||
ActionPtr ActionDelay::Reverse() const
|
||||
{
|
||||
return ActionDelay::Create(GetDelay());
|
||||
return InnerClone(ActionDelay::Create(GetDelay()));
|
||||
}
|
||||
|
||||
} // namespace kiwano
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ ActionPtr ActionGroup::Clone() const
|
|||
actions.push_back(action->Clone());
|
||||
}
|
||||
}
|
||||
return ActionGroup::Create(actions, sync_);
|
||||
return InnerClone(ActionGroup::Create(actions, sync_));
|
||||
}
|
||||
|
||||
ActionPtr ActionGroup::Reverse() const
|
||||
|
|
@ -143,7 +143,7 @@ ActionPtr ActionGroup::Reverse() const
|
|||
actions.push_back(action->Reverse());
|
||||
}
|
||||
}
|
||||
return ActionGroup::Create(actions, sync_);
|
||||
return InnerClone(ActionGroup::Create(actions, sync_));
|
||||
}
|
||||
|
||||
} // namespace kiwano
|
||||
|
|
|
|||
|
|
@ -129,6 +129,17 @@ void ActionTween::Update(Actor* target, Duration dt)
|
|||
UpdateTween(target, percent);
|
||||
}
|
||||
|
||||
ActionPtr ActionTween::InnerClone(ActionTweenPtr to) const
|
||||
{
|
||||
if (to)
|
||||
{
|
||||
(void)Action::InnerClone(to);
|
||||
to->SetDuration(this->GetDuration());
|
||||
to->SetEaseFunc(this->GetEaseFunc());
|
||||
}
|
||||
return to;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Move Action
|
||||
//-------------------------------------------------------
|
||||
|
|
@ -167,12 +178,12 @@ void ActionMoveBy::UpdateTween(Actor* target, float percent)
|
|||
|
||||
ActionPtr ActionMoveBy::Clone() const
|
||||
{
|
||||
return ActionMoveBy::Create(GetDuration(), displacement_);
|
||||
return InnerClone(ActionMoveBy::Create(GetDuration(), displacement_));
|
||||
}
|
||||
|
||||
ActionPtr ActionMoveBy::Reverse() const
|
||||
{
|
||||
return ActionMoveBy::Create(GetDuration(), -displacement_);
|
||||
return InnerClone(ActionMoveBy::Create(GetDuration(), -displacement_));
|
||||
}
|
||||
|
||||
ActionMoveToPtr ActionMoveTo::Create(Duration duration, Point const& distination)
|
||||
|
|
@ -190,7 +201,7 @@ ActionMoveTo::ActionMoveTo() {}
|
|||
|
||||
ActionPtr ActionMoveTo::Clone() const
|
||||
{
|
||||
return ActionMoveTo::Create(GetDuration(), distination_);
|
||||
return InnerClone(ActionMoveTo::Create(GetDuration(), distination_));
|
||||
}
|
||||
|
||||
void ActionMoveTo::Init(Actor* target)
|
||||
|
|
@ -226,12 +237,12 @@ ActionJumpBy::ActionJumpBy()
|
|||
|
||||
ActionPtr ActionJumpBy::Clone() const
|
||||
{
|
||||
return ActionJumpBy::Create(GetDuration(), displacement_, height_, jump_count_);
|
||||
return InnerClone(ActionJumpBy::Create(GetDuration(), displacement_, height_, jump_count_));
|
||||
}
|
||||
|
||||
ActionPtr ActionJumpBy::Reverse() const
|
||||
{
|
||||
return ActionJumpBy::Create(GetDuration(), -displacement_, height_, jump_count_);
|
||||
return InnerClone(ActionJumpBy::Create(GetDuration(), -displacement_, height_, jump_count_));
|
||||
}
|
||||
|
||||
void ActionJumpBy::Init(Actor* target)
|
||||
|
|
@ -277,7 +288,7 @@ ActionJumpTo::ActionJumpTo() {}
|
|||
|
||||
ActionPtr ActionJumpTo::Clone() const
|
||||
{
|
||||
return ActionJumpTo::Create(GetDuration(), distination_, height_, jump_count_);
|
||||
return InnerClone(ActionJumpTo::Create(GetDuration(), distination_, height_, jump_count_));
|
||||
}
|
||||
|
||||
void ActionJumpTo::Init(Actor* target)
|
||||
|
|
@ -326,12 +337,12 @@ void ActionScaleBy::UpdateTween(Actor* target, float percent)
|
|||
|
||||
ActionPtr ActionScaleBy::Clone() const
|
||||
{
|
||||
return ActionScaleBy::Create(GetDuration(), delta_x_, delta_y_);
|
||||
return InnerClone(ActionScaleBy::Create(GetDuration(), delta_x_, delta_y_));
|
||||
}
|
||||
|
||||
ActionPtr ActionScaleBy::Reverse() const
|
||||
{
|
||||
return ActionScaleBy::Create(GetDuration(), -delta_x_, -delta_y_);
|
||||
return InnerClone(ActionScaleBy::Create(GetDuration(), -delta_x_, -delta_y_));
|
||||
}
|
||||
|
||||
ActionScaleToPtr ActionScaleTo::Create(Duration duration, float scale_x, float scale_y)
|
||||
|
|
@ -354,7 +365,7 @@ ActionScaleTo::ActionScaleTo()
|
|||
|
||||
ActionPtr ActionScaleTo::Clone() const
|
||||
{
|
||||
return ActionScaleTo::Create(GetDuration(), end_scale_x_, end_scale_y_);
|
||||
return InnerClone(ActionScaleTo::Create(GetDuration(), end_scale_x_, end_scale_y_));
|
||||
}
|
||||
|
||||
void ActionScaleTo::Init(Actor* target)
|
||||
|
|
@ -402,7 +413,7 @@ void ActionFadeTo::UpdateTween(Actor* target, float percent)
|
|||
|
||||
ActionPtr ActionFadeTo::Clone() const
|
||||
{
|
||||
return ActionFadeTo::Create(GetDuration(), end_val_);
|
||||
return InnerClone(ActionFadeTo::Create(GetDuration(), end_val_));
|
||||
}
|
||||
|
||||
ActionFadeInPtr ActionFadeIn::Create(Duration duration)
|
||||
|
|
@ -467,12 +478,12 @@ void ActionRotateBy::UpdateTween(Actor* target, float percent)
|
|||
|
||||
ActionPtr ActionRotateBy::Clone() const
|
||||
{
|
||||
return ActionRotateBy::Create(GetDuration(), delta_val_);
|
||||
return InnerClone(ActionRotateBy::Create(GetDuration(), delta_val_));
|
||||
}
|
||||
|
||||
ActionPtr ActionRotateBy::Reverse() const
|
||||
{
|
||||
return ActionRotateBy::Create(GetDuration(), -delta_val_);
|
||||
return InnerClone(ActionRotateBy::Create(GetDuration(), -delta_val_));
|
||||
}
|
||||
|
||||
ActionRotateToPtr ActionRotateTo::Create(Duration duration, float rotation)
|
||||
|
|
@ -493,7 +504,7 @@ ActionRotateTo::ActionRotateTo()
|
|||
|
||||
ActionPtr ActionRotateTo::Clone() const
|
||||
{
|
||||
return ActionRotateTo::Create(GetDuration(), end_val_);
|
||||
return InnerClone(ActionRotateTo::Create(GetDuration(), end_val_));
|
||||
}
|
||||
|
||||
void ActionRotateTo::Init(Actor* target)
|
||||
|
|
@ -521,7 +532,7 @@ ActionCustom::ActionCustom() {}
|
|||
|
||||
ActionPtr ActionCustom::Clone() const
|
||||
{
|
||||
return ActionCustom::Create(GetDuration(), tween_func_);
|
||||
return InnerClone(ActionCustom::Create(GetDuration(), tween_func_));
|
||||
}
|
||||
|
||||
void ActionCustom::Init(Actor* target)
|
||||
|
|
|
|||
|
|
@ -119,6 +119,8 @@ protected:
|
|||
|
||||
virtual void UpdateTween(Actor* target, float percent) = 0;
|
||||
|
||||
ActionPtr InnerClone(ActionTweenPtr to) const;
|
||||
|
||||
private:
|
||||
Duration dur_;
|
||||
EaseFunc ease_func_;
|
||||
|
|
|
|||
|
|
@ -48,12 +48,12 @@ ActionWalk::ActionWalk()
|
|||
|
||||
ActionPtr ActionWalk::Clone() const
|
||||
{
|
||||
return ActionWalk::Create(GetDuration(), path_, rotating_, start_, end_);
|
||||
return InnerClone(ActionWalk::Create(GetDuration(), path_, rotating_, start_, end_));
|
||||
}
|
||||
|
||||
ActionPtr ActionWalk::Reverse() const
|
||||
{
|
||||
return ActionWalk::Create(GetDuration(), path_, rotating_, end_, start_);
|
||||
return InnerClone(ActionWalk::Create(GetDuration(), path_, rotating_, end_, start_));
|
||||
}
|
||||
|
||||
void ActionWalk::Init(Actor* target)
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ ActionPtr Animation::Clone() const
|
|||
{
|
||||
if (frame_seq_)
|
||||
{
|
||||
return Animation::Create(GetDuration(), frame_seq_);
|
||||
return InnerClone(Animation::Create(GetDuration(), frame_seq_));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -101,7 +101,7 @@ ActionPtr Animation::Reverse() const
|
|||
FrameSequencePtr frames = frame_seq_->Reverse();
|
||||
if (frames)
|
||||
{
|
||||
return Animation::Create(GetDuration(), frames);
|
||||
return InnerClone(Animation::Create(GetDuration(), frames));
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
|
|
|
|||
Loading…
Reference in New Issue