OpacityTo renamed to FadeTo
This commit is contained in:
parent
080cd5523b
commit
5bc2a39f7c
|
|
@ -46,9 +46,9 @@ namespace kiwano
|
||||||
inline ActionHelper& SetName(String const& name) { base->SetName(name); return (*this); }
|
inline ActionHelper& SetName(String const& name) { base->SetName(name); return (*this); }
|
||||||
|
|
||||||
// »ñȡָÕë
|
// »ñȡָÕë
|
||||||
inline ActionPtr Get() const { return base; }
|
inline ActionPtr Get() const { return base; }
|
||||||
|
|
||||||
inline ActionHelper(ActionPtr base) : base(base) {}
|
inline ActionHelper(ActionPtr base) : base(base) {}
|
||||||
|
|
||||||
inline operator ActionPtr() const { return base; }
|
inline operator ActionPtr() const { return base; }
|
||||||
|
|
||||||
|
|
@ -154,15 +154,9 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline TweenHelper
|
static inline TweenHelper
|
||||||
OpacityBy(float opacity)
|
FadeTo(float opacity)
|
||||||
{
|
{
|
||||||
return TweenHelper(new kiwano::ActionOpacityBy(0, opacity));
|
return TweenHelper(new kiwano::ActionFadeTo(0, opacity));
|
||||||
}
|
|
||||||
|
|
||||||
static inline TweenHelper
|
|
||||||
OpacityTo(float opacity)
|
|
||||||
{
|
|
||||||
return TweenHelper(new kiwano::ActionOpacityTo(0, opacity));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline TweenHelper
|
static inline TweenHelper
|
||||||
|
|
@ -232,6 +226,21 @@ namespace kiwano
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable : 4996)
|
#pragma warning(disable : 4996)
|
||||||
|
|
||||||
|
KGE_DEPRECATED("Tween::OpacityBy has been removed, use Tween::FadeTo instead")
|
||||||
|
static inline TweenHelper
|
||||||
|
OpacityBy(float opacity)
|
||||||
|
{
|
||||||
|
KGE_ASSERT("Tween::OpacityBy has been removed, use Tween::FadeTo instead");
|
||||||
|
return TweenHelper(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
KGE_DEPRECATED("Tween::OpacityTo is deprecated, use Tween::FadeTo instead")
|
||||||
|
static inline TweenHelper
|
||||||
|
OpacityTo(float opacity)
|
||||||
|
{
|
||||||
|
return TweenHelper(new kiwano::ActionFadeTo(0, opacity));
|
||||||
|
}
|
||||||
|
|
||||||
KGE_DEPRECATED("Tween::Sequence is deprecated, use Tween::Group instead")
|
KGE_DEPRECATED("Tween::Sequence is deprecated, use Tween::Group instead")
|
||||||
static inline ActionHelper
|
static inline ActionHelper
|
||||||
Sequence(Array<ActionPtr> const& actions)
|
Sequence(Array<ActionPtr> const& actions)
|
||||||
|
|
|
||||||
|
|
@ -326,59 +326,39 @@ namespace kiwano
|
||||||
// Opacity Action
|
// Opacity Action
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
ActionOpacityBy::ActionOpacityBy(Duration duration, float opacity, EaseFunc func)
|
ActionFadeTo::ActionFadeTo(Duration duration, float opacity, EaseFunc func)
|
||||||
: ActionTween(duration, func)
|
: ActionTween(duration, func)
|
||||||
, delta_val_(opacity)
|
, delta_val_(0.f)
|
||||||
|
, end_val_(opacity)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionOpacityBy::Init(NodePtr target)
|
void ActionFadeTo::Init(NodePtr target)
|
||||||
{
|
{
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
start_val_ = target->GetOpacity();
|
start_val_ = target->GetOpacity();
|
||||||
|
delta_val_ = end_val_ - start_val_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionOpacityBy::UpdateTween(NodePtr target, float percent)
|
void ActionFadeTo::UpdateTween(NodePtr target, float percent)
|
||||||
{
|
{
|
||||||
target->SetOpacity(start_val_ + delta_val_ * percent);
|
target->SetOpacity(start_val_ + delta_val_ * percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionPtr ActionOpacityBy::Clone() const
|
ActionPtr ActionFadeTo::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) ActionOpacityBy(dur_, delta_val_, ease_func_);
|
return new (std::nothrow) ActionFadeTo(dur_, end_val_, ease_func_);
|
||||||
}
|
|
||||||
|
|
||||||
ActionPtr ActionOpacityBy::Reverse() const
|
|
||||||
{
|
|
||||||
return new (std::nothrow) ActionOpacityBy(dur_, -delta_val_, ease_func_);
|
|
||||||
}
|
|
||||||
|
|
||||||
ActionOpacityTo::ActionOpacityTo(Duration duration, float opacity, EaseFunc func)
|
|
||||||
: ActionOpacityBy(duration, 0, func)
|
|
||||||
{
|
|
||||||
end_val_ = opacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
ActionPtr ActionOpacityTo::Clone() const
|
|
||||||
{
|
|
||||||
return new (std::nothrow) ActionOpacityTo(dur_, end_val_, ease_func_);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ActionOpacityTo::Init(NodePtr target)
|
|
||||||
{
|
|
||||||
ActionOpacityBy::Init(target);
|
|
||||||
delta_val_ = end_val_ - start_val_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionFadeIn::ActionFadeIn(Duration duration, EaseFunc func)
|
ActionFadeIn::ActionFadeIn(Duration duration, EaseFunc func)
|
||||||
: ActionOpacityTo(duration, 1, func)
|
: ActionFadeTo(duration, 1, func)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionFadeOut::ActionFadeOut(Duration duration, EaseFunc func)
|
ActionFadeOut::ActionFadeOut(Duration duration, EaseFunc func)
|
||||||
: ActionOpacityTo(duration, 0, func)
|
: ActionFadeTo(duration, 0, func)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -296,40 +296,12 @@ namespace kiwano
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 透明度相对渐变动作
|
// 透明度渐变动作
|
||||||
class KGE_API ActionOpacityBy
|
class KGE_API ActionFadeTo
|
||||||
: public ActionTween
|
: public ActionTween
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ActionOpacityBy(
|
ActionFadeTo(
|
||||||
Duration duration, /* 持续时长 */
|
|
||||||
float opacity, /* 相对变化值 */
|
|
||||||
EaseFunc func = nullptr /* 速度变化 */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 获取该动作的拷贝对象
|
|
||||||
ActionPtr Clone() const override;
|
|
||||||
|
|
||||||
// 获取该动作的倒转
|
|
||||||
ActionPtr Reverse() const override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void Init(NodePtr target) override;
|
|
||||||
|
|
||||||
void UpdateTween(NodePtr target, float percent) override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
float start_val_;
|
|
||||||
float delta_val_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// 透明度渐变动作
|
|
||||||
class KGE_API ActionOpacityTo
|
|
||||||
: public ActionOpacityBy
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ActionOpacityTo(
|
|
||||||
Duration duration, /* 持续时长 */
|
Duration duration, /* 持续时长 */
|
||||||
float opacity, /* 目标值 */
|
float opacity, /* 目标值 */
|
||||||
EaseFunc func = nullptr /* 速度变化 */
|
EaseFunc func = nullptr /* 速度变化 */
|
||||||
|
|
@ -341,21 +313,25 @@ namespace kiwano
|
||||||
// 获取该动作的倒转
|
// 获取该动作的倒转
|
||||||
virtual ActionPtr Reverse() const override
|
virtual ActionPtr Reverse() const override
|
||||||
{
|
{
|
||||||
KGE_ERROR_LOG(L"Reverse() not supported in ActionOpacityTo");
|
KGE_ERROR_LOG(L"Reverse() not supported in ActionFadeTo");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Init(NodePtr target) override;
|
void Init(NodePtr target) override;
|
||||||
|
|
||||||
|
void UpdateTween(NodePtr target, float percent) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
float start_val_;
|
||||||
|
float delta_val_;
|
||||||
float end_val_;
|
float end_val_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 淡入动作
|
// 淡入动作
|
||||||
class KGE_API ActionFadeIn
|
class KGE_API ActionFadeIn
|
||||||
: public ActionOpacityTo
|
: public ActionFadeTo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// 创建淡入动作
|
// 创建淡入动作
|
||||||
|
|
@ -368,7 +344,7 @@ namespace kiwano
|
||||||
|
|
||||||
// 淡出动作
|
// 淡出动作
|
||||||
class KGE_API ActionFadeOut
|
class KGE_API ActionFadeOut
|
||||||
: public ActionOpacityTo
|
: public ActionFadeTo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// 创建淡出动作
|
// 创建淡出动作
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,7 @@ namespace kiwano
|
||||||
KGE_DECLARE_SMART_PTR(ActionJumpTo);
|
KGE_DECLARE_SMART_PTR(ActionJumpTo);
|
||||||
KGE_DECLARE_SMART_PTR(ActionScaleBy);
|
KGE_DECLARE_SMART_PTR(ActionScaleBy);
|
||||||
KGE_DECLARE_SMART_PTR(ActionScaleTo);
|
KGE_DECLARE_SMART_PTR(ActionScaleTo);
|
||||||
KGE_DECLARE_SMART_PTR(ActionOpacityBy);
|
KGE_DECLARE_SMART_PTR(ActionFadeTo);
|
||||||
KGE_DECLARE_SMART_PTR(ActionOpacityTo);
|
|
||||||
KGE_DECLARE_SMART_PTR(ActionFadeIn);
|
KGE_DECLARE_SMART_PTR(ActionFadeIn);
|
||||||
KGE_DECLARE_SMART_PTR(ActionFadeOut);
|
KGE_DECLARE_SMART_PTR(ActionFadeOut);
|
||||||
KGE_DECLARE_SMART_PTR(ActionRotateBy);
|
KGE_DECLARE_SMART_PTR(ActionRotateBy);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue