add: ActionHelper

minor
This commit is contained in:
Nomango 2019-01-24 15:14:55 +08:00 committed by Nomango
parent fd3c70d5f0
commit 1f6fa38e81
34 changed files with 366 additions and 185 deletions

View File

@ -20,7 +20,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\src\core\Action.hpp" /> <ClInclude Include="..\..\src\core\Action.hpp" />
<ClInclude Include="..\..\src\core\ActionCombined.h" /> <ClInclude Include="..\..\src\core\ActionGroup.h" />
<ClInclude Include="..\..\src\core\ActionHelper.h" />
<ClInclude Include="..\..\src\core\ActionTween.h" /> <ClInclude Include="..\..\src\core\ActionTween.h" />
<ClInclude Include="..\..\src\core\ActionManager.h" /> <ClInclude Include="..\..\src\core\ActionManager.h" />
<ClInclude Include="..\..\src\core\Animation.h" /> <ClInclude Include="..\..\src\core\Animation.h" />
@ -88,7 +89,7 @@
<ClInclude Include="..\..\src\utils\Transcoder.h" /> <ClInclude Include="..\..\src\utils\Transcoder.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\src\core\ActionCombined.cpp" /> <ClCompile Include="..\..\src\core\ActionGroup.cpp" />
<ClCompile Include="..\..\src\core\ActionTween.cpp" /> <ClCompile Include="..\..\src\core\ActionTween.cpp" />
<ClCompile Include="..\..\src\core\ActionManager.cpp" /> <ClCompile Include="..\..\src\core\ActionManager.cpp" />
<ClCompile Include="..\..\src\core\Animation.cpp" /> <ClCompile Include="..\..\src\core\Animation.cpp" />

View File

@ -2,9 +2,6 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\src\easy2d.h" /> <ClInclude Include="..\..\src\easy2d.h" />
<ClInclude Include="..\..\src\core\ActionCombined.h">
<Filter>core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\core\Animation.h"> <ClInclude Include="..\..\src\core\Animation.h">
<Filter>core</Filter> <Filter>core</Filter>
</ClInclude> </ClInclude>
@ -200,6 +197,12 @@
<ClInclude Include="..\..\src\core\closure.hpp"> <ClInclude Include="..\..\src\core\closure.hpp">
<Filter>core</Filter> <Filter>core</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\src\core\ActionGroup.h">
<Filter>core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\core\ActionHelper.h">
<Filter>core</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Filter Include="core"> <Filter Include="core">
@ -216,9 +219,6 @@
</Filter> </Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\src\core\ActionCombined.cpp">
<Filter>core</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\Animation.cpp"> <ClCompile Include="..\..\src\core\Animation.cpp">
<Filter>core</Filter> <Filter>core</Filter>
</ClCompile> </ClCompile>
@ -348,5 +348,8 @@
<ClCompile Include="..\..\src\core\Application.cpp"> <ClCompile Include="..\..\src\core\Application.cpp">
<Filter>core</Filter> <Filter>core</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\core\ActionGroup.cpp">
<Filter>core</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -20,7 +20,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\src\core\Action.hpp" /> <ClInclude Include="..\..\src\core\Action.hpp" />
<ClInclude Include="..\..\src\core\ActionCombined.h" /> <ClInclude Include="..\..\src\core\ActionGroup.h" />
<ClInclude Include="..\..\src\core\ActionHelper.h" />
<ClInclude Include="..\..\src\core\ActionTween.h" /> <ClInclude Include="..\..\src\core\ActionTween.h" />
<ClInclude Include="..\..\src\core\ActionManager.h" /> <ClInclude Include="..\..\src\core\ActionManager.h" />
<ClInclude Include="..\..\src\core\Animation.h" /> <ClInclude Include="..\..\src\core\Animation.h" />
@ -88,7 +89,7 @@
<ClInclude Include="..\..\src\utils\Transcoder.h" /> <ClInclude Include="..\..\src\utils\Transcoder.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\src\core\ActionCombined.cpp" /> <ClCompile Include="..\..\src\core\ActionGroup.cpp" />
<ClCompile Include="..\..\src\core\ActionTween.cpp" /> <ClCompile Include="..\..\src\core\ActionTween.cpp" />
<ClCompile Include="..\..\src\core\ActionManager.cpp" /> <ClCompile Include="..\..\src\core\ActionManager.cpp" />
<ClCompile Include="..\..\src\core\Animation.cpp" /> <ClCompile Include="..\..\src\core\Animation.cpp" />

View File

@ -2,9 +2,6 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\src\easy2d.h" /> <ClInclude Include="..\..\src\easy2d.h" />
<ClInclude Include="..\..\src\core\ActionCombined.h">
<Filter>core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\core\Animation.h"> <ClInclude Include="..\..\src\core\Animation.h">
<Filter>core</Filter> <Filter>core</Filter>
</ClInclude> </ClInclude>
@ -200,6 +197,12 @@
<ClInclude Include="..\..\src\core\closure.hpp"> <ClInclude Include="..\..\src\core\closure.hpp">
<Filter>core</Filter> <Filter>core</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\src\core\ActionGroup.h">
<Filter>core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\core\ActionHelper.h">
<Filter>core</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Filter Include="core"> <Filter Include="core">
@ -216,9 +219,6 @@
</Filter> </Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\src\core\ActionCombined.cpp">
<Filter>core</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\Animation.cpp"> <ClCompile Include="..\..\src\core\Animation.cpp">
<Filter>core</Filter> <Filter>core</Filter>
</ClCompile> </ClCompile>
@ -348,5 +348,8 @@
<ClCompile Include="..\..\src\core\Application.cpp"> <ClCompile Include="..\..\src\core\Application.cpp">
<Filter>core</Filter> <Filter>core</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\core\ActionGroup.cpp">
<Filter>core</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -20,7 +20,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\src\core\Action.hpp" /> <ClInclude Include="..\..\src\core\Action.hpp" />
<ClInclude Include="..\..\src\core\ActionCombined.h" /> <ClInclude Include="..\..\src\core\ActionGroup.h" />
<ClInclude Include="..\..\src\core\ActionHelper.h" />
<ClInclude Include="..\..\src\core\ActionTween.h" /> <ClInclude Include="..\..\src\core\ActionTween.h" />
<ClInclude Include="..\..\src\core\ActionManager.h" /> <ClInclude Include="..\..\src\core\ActionManager.h" />
<ClInclude Include="..\..\src\core\Animation.h" /> <ClInclude Include="..\..\src\core\Animation.h" />
@ -88,7 +89,7 @@
<ClInclude Include="..\..\src\utils\Transcoder.h" /> <ClInclude Include="..\..\src\utils\Transcoder.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\src\core\ActionCombined.cpp" /> <ClCompile Include="..\..\src\core\ActionGroup.cpp" />
<ClCompile Include="..\..\src\core\ActionTween.cpp" /> <ClCompile Include="..\..\src\core\ActionTween.cpp" />
<ClCompile Include="..\..\src\core\ActionManager.cpp" /> <ClCompile Include="..\..\src\core\ActionManager.cpp" />
<ClCompile Include="..\..\src\core\Animation.cpp" /> <ClCompile Include="..\..\src\core\Animation.cpp" />

View File

@ -2,9 +2,6 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\src\easy2d.h" /> <ClInclude Include="..\..\src\easy2d.h" />
<ClInclude Include="..\..\src\core\ActionCombined.h">
<Filter>core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\core\Animation.h"> <ClInclude Include="..\..\src\core\Animation.h">
<Filter>core</Filter> <Filter>core</Filter>
</ClInclude> </ClInclude>
@ -200,6 +197,12 @@
<ClInclude Include="..\..\src\core\closure.hpp"> <ClInclude Include="..\..\src\core\closure.hpp">
<Filter>core</Filter> <Filter>core</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\src\core\ActionGroup.h">
<Filter>core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\core\ActionHelper.h">
<Filter>core</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Filter Include="core"> <Filter Include="core">
@ -216,9 +219,6 @@
</Filter> </Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\src\core\ActionCombined.cpp">
<Filter>core</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\Animation.cpp"> <ClCompile Include="..\..\src\core\Animation.cpp">
<Filter>core</Filter> <Filter>core</Filter>
</ClCompile> </ClCompile>
@ -348,5 +348,8 @@
<ClCompile Include="..\..\src\core\Application.cpp"> <ClCompile Include="..\..\src\core\Application.cpp">
<Filter>core</Filter> <Filter>core</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\core\ActionGroup.cpp">
<Filter>core</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -43,17 +43,14 @@ namespace easy2d
virtual ~Action() {} virtual ~Action() {}
// 获取动作运行状态
virtual bool IsRunning() { return running_; }
// 继续动作 // 继续动作
virtual void Resume() { running_ = true; } void Resume() { running_ = true; }
// 暂停动作 // 暂停动作
virtual void Pause() { running_ = false; } void Pause() { running_ = false; }
// 停止动作 // 停止动作
virtual void Stop() { if (!done_) { done_ = true; if (cb_) cb_(); } } void Stop() { if (!done_) { done_ = true; if (cb_) cb_(); } }
// 获取动作的拷贝 // 获取动作的拷贝
virtual ActionPtr Clone() const = 0; virtual ActionPtr Clone() const = 0;
@ -61,6 +58,9 @@ namespace easy2d
// 获取动作的倒转 // 获取动作的倒转
virtual ActionPtr Reverse() const = 0; virtual ActionPtr Reverse() const = 0;
// 设置动作结束时的回调函数
void SetCallback(std::function<void()> cb) { cb_ = cb; }
// 重置动作 // 重置动作
virtual void Reset() virtual void Reset()
{ {
@ -68,13 +68,12 @@ namespace easy2d
done_ = false; done_ = false;
} }
// 设置动作结束时的回调函数
void SetCallback(std::function<void()> cb) { cb_ = cb; }
virtual bool IsDone() const { return done_; } virtual bool IsDone() const { return done_; }
virtual bool IsRunning() { return running_; }
protected: protected:
virtual void Start() void Start()
{ {
running_ = true; running_ = true;
this->Reset(); this->Reset();
@ -82,7 +81,7 @@ namespace easy2d
virtual void Init(Node* target) { initialized_ = true; } virtual void Init(Node* target) { initialized_ = true; }
virtual void Update(Node* target, Duration const& dt) virtual void Update(Node* target, Duration dt)
{ {
if (!initialized_) if (!initialized_)
{ {

View File

@ -18,7 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE. // THE SOFTWARE.
#include "ActionCombined.h" #include "ActionGroup.h"
#include "logs.h" #include "logs.h"
namespace easy2d namespace easy2d
@ -75,7 +75,7 @@ namespace easy2d
} }
} }
void Loop::Update(Node* target, Duration const& dt) void Loop::Update(Node* target, Duration dt)
{ {
Action::Update(target, dt); Action::Update(target, dt);
@ -141,7 +141,7 @@ namespace easy2d
actions_[0]->Init(target); actions_[0]->Init(target);
} }
void Sequence::Update(Node* target, Duration const& dt) void Sequence::Update(Node* target, Duration dt)
{ {
Action::Update(target, dt); Action::Update(target, dt);
@ -249,7 +249,7 @@ namespace easy2d
} }
} }
void Spawn::Update(Node* target, Duration const& dt) void Spawn::Update(Node* target, Duration dt)
{ {
Action::Update(target, dt); Action::Update(target, dt);

View File

@ -51,7 +51,7 @@ namespace easy2d
virtual void Init(Node* target) override; virtual void Init(Node* target) override;
// 更新动作 // 更新动作
virtual void Update(Node* target, Duration const& dt) override; virtual void Update(Node* target, Duration dt) override;
protected: protected:
ActionPtr action_; ActionPtr action_;
@ -97,7 +97,7 @@ namespace easy2d
virtual void Init(Node* target) override; virtual void Init(Node* target) override;
// 更新动作 // 更新动作
virtual void Update(Node* target, Duration const& dt) override; virtual void Update(Node* target, Duration dt) override;
protected: protected:
UINT action_index_; UINT action_index_;
@ -142,7 +142,7 @@ namespace easy2d
virtual void Init(Node* target) override; virtual void Init(Node* target) override;
// 更新动作 // 更新动作
virtual void Update(Node* target, Duration const& dt) override; virtual void Update(Node* target, Duration dt) override;
protected: protected:
Array<ActionPtr> actions_; Array<ActionPtr> actions_;

191
src/core/ActionHelper.h Normal file
View File

@ -0,0 +1,191 @@
// Copyright (c) 2016-2018 Easy2D - Nomango
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#pragma once
#include "ActionGroup.h"
#include "ActionTween.h"
#include "Delay.h"
namespace easy2d
{
struct ActionHelper
{
ActionHelper& SetLoopCount(int loop) { this->loop = loop; return (*this); }
ActionHelper(ActionPtr const& base) : base(base), loop(0) {}
operator ActionPtr() const
{
if (loop)
return ActionPtr(new (std::nothrow) Loop(base));
return base;
}
ActionPtr base;
int loop;
};
struct TweenActionHelper
{
TweenActionHelper& SetDuration(Duration dur) { this->dur = dur; return (*this); }
TweenActionHelper& SetLoopCount(int loop) { this->loop = loop; return (*this); }
TweenActionHelper& SetEaseFunc(EaseFunc ease) { this->ease = ease; return (*this); }
TweenActionHelper(ActionTweenPtr const& base) : base(base), dur(), loop(0), ease(EaseFunc::Linear) {}
operator ActionPtr() const
{
base->SetEaseFunction(ease);
base->SetDuration(dur);
if (loop)
return ActionPtr(new (std::nothrow) Loop(base));
return base;
}
ActionTweenPtr base;
Duration dur;
int loop;
EaseFunc ease;
};
struct Tween
{
public:
static inline TweenActionHelper
MoveBy(Point const& vector)
{
return TweenActionHelper(new easy2d::MoveBy(0, vector));
}
static inline TweenActionHelper
MoveTo(Point const& pos)
{
return TweenActionHelper(new easy2d::MoveTo(0, pos));
}
static inline TweenActionHelper
JumpBy(
Point const& pos, /* 目的坐标 */
float height, /* 跳跃高度 */
int jumps = 1) /* 跳跃次数 */
{
return TweenActionHelper(new easy2d::JumpBy(0, pos, height, jumps));
}
static inline TweenActionHelper
JumpTo(
Point const& pos, /* 目的坐标 */
float height, /* 跳跃高度 */
int jumps = 1) /* 跳跃次数 */
{
return TweenActionHelper(new easy2d::JumpTo(0, pos, height, jumps));
}
static inline TweenActionHelper
ScaleBy(float scale)
{
return TweenActionHelper(new easy2d::ScaleBy(0, scale));
}
static inline TweenActionHelper
ScaleBy(float scale_x, float scale_y)
{
return TweenActionHelper(new easy2d::ScaleBy(0, scale_x, scale_y));
}
static inline TweenActionHelper
ScaleTo(float scale)
{
return TweenActionHelper(new easy2d::ScaleTo(0, scale));
}
static inline TweenActionHelper
ScaleTo(float scale_x, float scale_y)
{
return TweenActionHelper(new easy2d::ScaleTo(0, scale_x, scale_y));
}
static inline TweenActionHelper
OpacityBy(float opacity)
{
return TweenActionHelper(new easy2d::OpacityBy(0, opacity));
}
static inline TweenActionHelper
OpacityTo(float opacity)
{
return TweenActionHelper(new easy2d::OpacityTo(0, opacity));
}
static inline TweenActionHelper
FadeIn(Duration dur)
{
return TweenActionHelper(new easy2d::FadeIn(dur));
}
static inline TweenActionHelper
FadeOut(Duration dur)
{
return TweenActionHelper(new easy2d::FadeOut(dur));
}
static inline TweenActionHelper
RotateBy(float rotation)
{
return TweenActionHelper(new easy2d::RotateBy(0, rotation));
}
static inline TweenActionHelper
RotateTo(float rotation)
{
return TweenActionHelper(new easy2d::RotateTo(0, rotation));
}
static inline TweenActionHelper
Path(
GeometryPtr const& geo, /* 几何图形 */
bool rotating = false, /* 沿路径切线方向旋转 */
float start = 0.f, /* 起点 */
float end = 1.f) /* 终点 */
{
return TweenActionHelper(new easy2d::PathAction(0, geo, rotating, start, end));
}
static inline ActionHelper
Delay(Duration dur)
{
return ActionHelper(new easy2d::Delay(dur));
}
static inline ActionHelper
Sequence(Array<ActionPtr> const& actions)
{
return ActionHelper(new easy2d::Sequence(actions));
}
static inline ActionHelper
Spawn(Array<ActionPtr> const& actions)
{
return ActionHelper(new easy2d::Spawn(actions));
}
};
}

View File

@ -23,7 +23,7 @@
namespace easy2d namespace easy2d
{ {
void ActionManager::UpdateActions(Node* target, Duration const& dt) void ActionManager::UpdateActions(Node* target, Duration dt)
{ {
if (actions_.IsEmpty()) if (actions_.IsEmpty())
return; return;

View File

@ -46,7 +46,7 @@ namespace easy2d
Actions const& GetAllActions() const; Actions const& GetAllActions() const;
protected: protected:
void UpdateActions(Node* target, Duration const& dt); void UpdateActions(Node* target, Duration dt);
protected: protected:
Actions actions_; Actions actions_;

View File

@ -27,10 +27,10 @@
namespace easy2d namespace easy2d
{ {
//------------------------------------------------------- //-------------------------------------------------------
// Tween // ActionTween
//------------------------------------------------------- //-------------------------------------------------------
Tween::Tween() ActionTween::ActionTween()
: elapsed_() : elapsed_()
, duration_() , duration_()
, ease_func_(math::Linear) , ease_func_(math::Linear)
@ -38,7 +38,7 @@ namespace easy2d
{ {
} }
Tween::Tween(Duration const& duration, EaseFunc func) ActionTween::ActionTween(Duration duration, EaseFunc func)
: elapsed_() : elapsed_()
, ease_func_(math::Linear) , ease_func_(math::Linear)
, ease_type_(EaseFunc::Linear) , ease_type_(EaseFunc::Linear)
@ -47,7 +47,7 @@ namespace easy2d
SetEaseFunction(func); SetEaseFunction(func);
} }
void Tween::SetEaseFunction(EaseFunc func) void ActionTween::SetEaseFunction(EaseFunc func)
{ {
ease_type_ = func; ease_type_ = func;
switch (func) switch (func)
@ -150,29 +150,29 @@ namespace easy2d
} }
} }
void Tween::SetEaseFunction(EaseFunction func) void ActionTween::SetEaseFunction(EaseFunction func)
{ {
ease_func_ = func; ease_func_ = func;
ease_type_ = EaseFunc(-1); ease_type_ = EaseFunc(-1);
} }
void Tween::Reset() void ActionTween::Reset()
{ {
Action::Reset(); Action::Reset();
elapsed_ = Duration{}; elapsed_ = Duration{};
} }
Duration const & Tween::GetDuration() const Duration ActionTween::GetDuration() const
{ {
return duration_; return duration_;
} }
void Tween::Init(Node* target) void ActionTween::Init(Node* target)
{ {
Action::Init(target); Action::Init(target);
} }
void Tween::Update(Node* target, Duration const& dt) void ActionTween::Update(Node* target, Duration dt)
{ {
Action::Update(target, dt); Action::Update(target, dt);
@ -195,7 +195,7 @@ namespace easy2d
UpdateStep(target, ease_func_(step)); UpdateStep(target, ease_func_(step));
} }
void Tween::SetDuration(Duration const & duration) void ActionTween::SetDuration(Duration duration)
{ {
duration_ = duration; duration_ = duration;
} }
@ -205,15 +205,15 @@ namespace easy2d
// Move Action // Move Action
//------------------------------------------------------- //-------------------------------------------------------
MoveBy::MoveBy(Duration const& duration, Point const& vector, EaseFunc func) MoveBy::MoveBy(Duration duration, Point const& vector, EaseFunc func)
: Tween(duration, func) : ActionTween(duration, func)
{ {
delta_pos_ = vector; delta_pos_ = vector;
} }
void MoveBy::Init(Node* target) void MoveBy::Init(Node* target)
{ {
Tween::Init(target); ActionTween::Init(target);
if (target) if (target)
{ {
@ -245,7 +245,7 @@ namespace easy2d
return new (std::nothrow) MoveBy(duration_, -delta_pos_, ease_type_); return new (std::nothrow) MoveBy(duration_, -delta_pos_, ease_type_);
} }
MoveTo::MoveTo(Duration const& duration, Point const& pos, EaseFunc func) MoveTo::MoveTo(Duration duration, Point const& pos, EaseFunc func)
: MoveBy(duration, Point(), func) : MoveBy(duration, Point(), func)
{ {
end_pos_ = pos; end_pos_ = pos;
@ -267,8 +267,8 @@ namespace easy2d
// Jump Action // Jump Action
//------------------------------------------------------- //-------------------------------------------------------
JumpBy::JumpBy(Duration const& duration, Point const& vec, float height, int jumps, EaseFunc func) JumpBy::JumpBy(Duration duration, Point const& vec, float height, int jumps, EaseFunc func)
: Tween(duration, func) : ActionTween(duration, func)
, delta_pos_(vec) , delta_pos_(vec)
, height_(height) , height_(height)
, jumps_(jumps) , jumps_(jumps)
@ -287,7 +287,7 @@ namespace easy2d
void JumpBy::Init(Node* target) void JumpBy::Init(Node* target)
{ {
Tween::Init(target); ActionTween::Init(target);
if (target) if (target)
{ {
@ -314,7 +314,7 @@ namespace easy2d
} }
} }
JumpTo::JumpTo(Duration const& duration, Point const& pos, float height, int jumps, EaseFunc func) JumpTo::JumpTo(Duration duration, Point const& pos, float height, int jumps, EaseFunc func)
: JumpBy(duration, Point(), height, jumps, func) : JumpBy(duration, Point(), height, jumps, func)
, end_pos_(pos) , end_pos_(pos)
{ {
@ -336,15 +336,15 @@ namespace easy2d
// Scale Action // Scale Action
//------------------------------------------------------- //-------------------------------------------------------
ScaleBy::ScaleBy(Duration const& duration, float scale, EaseFunc func) ScaleBy::ScaleBy(Duration duration, float scale, EaseFunc func)
: Tween(duration, func) : ActionTween(duration, func)
{ {
delta_x_ = scale; delta_x_ = scale;
delta_y_ = scale; delta_y_ = scale;
} }
ScaleBy::ScaleBy(Duration const& duration, float scale_x, float scale_y, EaseFunc func) ScaleBy::ScaleBy(Duration duration, float scale_x, float scale_y, EaseFunc func)
: Tween(duration, func) : ActionTween(duration, func)
{ {
delta_x_ = scale_x; delta_x_ = scale_x;
delta_y_ = scale_y; delta_y_ = scale_y;
@ -352,7 +352,7 @@ namespace easy2d
void ScaleBy::Init(Node* target) void ScaleBy::Init(Node* target)
{ {
Tween::Init(target); ActionTween::Init(target);
if (target) if (target)
{ {
@ -379,14 +379,14 @@ namespace easy2d
return new (std::nothrow) ScaleBy(duration_, -delta_x_, -delta_y_, ease_type_); return new (std::nothrow) ScaleBy(duration_, -delta_x_, -delta_y_, ease_type_);
} }
ScaleTo::ScaleTo(Duration const& duration, float scale, EaseFunc func) ScaleTo::ScaleTo(Duration duration, float scale, EaseFunc func)
: ScaleBy(duration, 0, 0, func) : ScaleBy(duration, 0, 0, func)
{ {
end_scale_x_ = scale; end_scale_x_ = scale;
end_scale_y_ = scale; end_scale_y_ = scale;
} }
ScaleTo::ScaleTo(Duration const& duration, float scale_x, float scale_y, EaseFunc func) ScaleTo::ScaleTo(Duration duration, float scale_x, float scale_y, EaseFunc func)
: ScaleBy(duration, 0, 0, func) : ScaleBy(duration, 0, 0, func)
{ {
end_scale_x_ = scale_x; end_scale_x_ = scale_x;
@ -410,15 +410,15 @@ namespace easy2d
// Opacity Action // Opacity Action
//------------------------------------------------------- //-------------------------------------------------------
OpacityBy::OpacityBy(Duration const& duration, float opacity, EaseFunc func) OpacityBy::OpacityBy(Duration duration, float opacity, EaseFunc func)
: Tween(duration, func) : ActionTween(duration, func)
{ {
delta_val_ = opacity; delta_val_ = opacity;
} }
void OpacityBy::Init(Node* target) void OpacityBy::Init(Node* target)
{ {
Tween::Init(target); ActionTween::Init(target);
if (target) if (target)
{ {
@ -444,7 +444,7 @@ namespace easy2d
return new (std::nothrow) OpacityBy(duration_, -delta_val_, ease_type_); return new (std::nothrow) OpacityBy(duration_, -delta_val_, ease_type_);
} }
OpacityTo::OpacityTo(Duration const& duration, float opacity, EaseFunc func) OpacityTo::OpacityTo(Duration duration, float opacity, EaseFunc func)
: OpacityBy(duration, 0, func) : OpacityBy(duration, 0, func)
{ {
end_val_ = opacity; end_val_ = opacity;
@ -461,12 +461,12 @@ namespace easy2d
delta_val_ = end_val_ - start_val_; delta_val_ = end_val_ - start_val_;
} }
FadeIn::FadeIn(Duration const& duration, EaseFunc func) FadeIn::FadeIn(Duration duration, EaseFunc func)
: OpacityTo(duration, 1, func) : OpacityTo(duration, 1, func)
{ {
} }
FadeOut::FadeOut(Duration const& duration, EaseFunc func) FadeOut::FadeOut(Duration duration, EaseFunc func)
: OpacityTo(duration, 0, func) : OpacityTo(duration, 0, func)
{ {
} }
@ -476,15 +476,15 @@ namespace easy2d
// Rotate Action // Rotate Action
//------------------------------------------------------- //-------------------------------------------------------
RotateBy::RotateBy(Duration const& duration, float rotation, EaseFunc func) RotateBy::RotateBy(Duration duration, float rotation, EaseFunc func)
: Tween(duration, func) : ActionTween(duration, func)
, delta_val_(rotation) , delta_val_(rotation)
{ {
} }
void RotateBy::Init(Node* target) void RotateBy::Init(Node* target)
{ {
Tween::Init(target); ActionTween::Init(target);
if (target) if (target)
{ {
@ -510,7 +510,7 @@ namespace easy2d
return new (std::nothrow) RotateBy(duration_, -delta_val_, ease_type_); return new (std::nothrow) RotateBy(duration_, -delta_val_, ease_type_);
} }
RotateTo::RotateTo(Duration const& duration, float rotation, EaseFunc func) RotateTo::RotateTo(Duration duration, float rotation, EaseFunc func)
: RotateBy(duration, 0, func) : RotateBy(duration, 0, func)
{ {
end_val_ = rotation; end_val_ = rotation;
@ -532,8 +532,8 @@ namespace easy2d
// PathAction // PathAction
//------------------------------------------------------- //-------------------------------------------------------
PathAction::PathAction(Duration const & duration, GeometryPtr const& geo, bool rotating, float start, float end, EaseFunc func) PathAction::PathAction(Duration duration, GeometryPtr const& geo, bool rotating, float start, float end, EaseFunc func)
: Tween(duration, func) : ActionTween(duration, func)
, start_(start) , start_(start)
, end_(end) , end_(end)
, geo_(geo) , geo_(geo)
@ -553,7 +553,7 @@ namespace easy2d
void PathAction::Init(Node * target) void PathAction::Init(Node * target)
{ {
Tween::Init(target); ActionTween::Init(target);
if (target) if (target)
{ {

View File

@ -74,14 +74,14 @@ namespace easy2d
// 补间动画 // 补间动画
class Tween class ActionTween
: public Action : public Action
{ {
public: public:
Tween(); ActionTween();
explicit Tween( explicit ActionTween(
Duration const& duration, Duration duration,
EaseFunc func EaseFunc func
); );
@ -97,14 +97,14 @@ namespace easy2d
virtual void Reset() override; virtual void Reset() override;
Duration const& GetDuration() const; Duration GetDuration() const;
void SetDuration(Duration const& duration); void SetDuration(Duration duration);
protected: protected:
virtual void Init(Node* target) override; virtual void Init(Node* target) override;
virtual void Update(Node* target, Duration const& dt) override; virtual void Update(Node* target, Duration dt) override;
virtual void UpdateStep(Node* target, float step) = 0; virtual void UpdateStep(Node* target, float step) = 0;
@ -118,11 +118,11 @@ namespace easy2d
// 相对位移动作 // 相对位移动作
class MoveBy class MoveBy
: public Tween : public ActionTween
{ {
public: public:
explicit MoveBy( explicit MoveBy(
Duration const& duration, /* 持续时长 */ Duration duration, /* 持续时长 */
Point const& vector, /* 移动距离 */ Point const& vector, /* 移动距离 */
EaseFunc func = EaseFunc::Linear /* 速度变化 */ EaseFunc func = EaseFunc::Linear /* 速度变化 */
); );
@ -151,7 +151,7 @@ namespace easy2d
{ {
public: public:
explicit MoveTo( explicit MoveTo(
Duration const& duration, /* 持续时长 */ Duration duration, /* 持续时长 */
Point const& pos, /* 目的坐标 */ Point const& pos, /* 目的坐标 */
EaseFunc func = EaseFunc::Linear /* 速度变化 */ EaseFunc func = EaseFunc::Linear /* 速度变化 */
); );
@ -176,11 +176,11 @@ namespace easy2d
// 相对跳跃动作 // 相对跳跃动作
class JumpBy class JumpBy
: public Tween : public ActionTween
{ {
public: public:
explicit JumpBy( explicit JumpBy(
Duration const& duration, /* 持续时长 */ Duration duration, /* 持续时长 */
Point const& vec, /* 跳跃距离 */ Point const& vec, /* 跳跃距离 */
float height, /* 跳跃高度 */ float height, /* 跳跃高度 */
int jumps = 1, /* 跳跃次数 */ int jumps = 1, /* 跳跃次数 */
@ -213,7 +213,7 @@ namespace easy2d
{ {
public: public:
explicit JumpTo( explicit JumpTo(
Duration const& duration, /* 持续时长 */ Duration duration, /* 持续时长 */
Point const& pos, /* 目的坐标 */ Point const& pos, /* 目的坐标 */
float height, /* 跳跃高度 */ float height, /* 跳跃高度 */
int jumps = 1, /* 跳跃次数 */ int jumps = 1, /* 跳跃次数 */
@ -240,17 +240,17 @@ namespace easy2d
// 相对缩放动作 // 相对缩放动作
class ScaleBy class ScaleBy
: public Tween : public ActionTween
{ {
public: public:
explicit ScaleBy( explicit ScaleBy(
Duration const& duration, /* 持续时长 */ Duration duration, /* 持续时长 */
float scale, /* 相对变化值 */ float scale, /* 相对变化值 */
EaseFunc func = EaseFunc::Linear /* 速度变化 */ EaseFunc func = EaseFunc::Linear /* 速度变化 */
); );
explicit ScaleBy( explicit ScaleBy(
Duration const& duration, /* 持续时长 */ Duration duration, /* 持续时长 */
float scale_x, /* 横向缩放相对变化值 */ float scale_x, /* 横向缩放相对变化值 */
float scale_y, /* 纵向缩放相对变化值 */ float scale_y, /* 纵向缩放相对变化值 */
EaseFunc func = EaseFunc::Linear /* 速度变化 */ EaseFunc func = EaseFunc::Linear /* 速度变化 */
@ -281,13 +281,13 @@ namespace easy2d
{ {
public: public:
explicit ScaleTo( explicit ScaleTo(
Duration const& duration, /* 持续时长 */ Duration duration, /* 持续时长 */
float scale, /* 目标值 */ float scale, /* 目标值 */
EaseFunc func = EaseFunc::Linear /* 速度变化 */ EaseFunc func = EaseFunc::Linear /* 速度变化 */
); );
explicit ScaleTo( explicit ScaleTo(
Duration const& duration, /* 持续时长 */ Duration duration, /* 持续时长 */
float scale_x, /* 横向缩放目标值 */ float scale_x, /* 横向缩放目标值 */
float scale_y, /* 纵向缩放目标值 */ float scale_y, /* 纵向缩放目标值 */
EaseFunc func = EaseFunc::Linear /* 速度变化 */ EaseFunc func = EaseFunc::Linear /* 速度变化 */
@ -314,11 +314,11 @@ namespace easy2d
// 透明度相对渐变动作 // 透明度相对渐变动作
class OpacityBy class OpacityBy
: public Tween : public ActionTween
{ {
public: public:
explicit OpacityBy( explicit OpacityBy(
Duration const& duration, /* 持续时长 */ Duration duration, /* 持续时长 */
float opacity, /* 相对变化值 */ float opacity, /* 相对变化值 */
EaseFunc func = EaseFunc::Linear /* 速度变化 */ EaseFunc func = EaseFunc::Linear /* 速度变化 */
); );
@ -346,7 +346,7 @@ namespace easy2d
{ {
public: public:
explicit OpacityTo( explicit OpacityTo(
Duration const& duration, /* 持续时长 */ Duration duration, /* 持续时长 */
float opacity, /* 目标值 */ float opacity, /* 目标值 */
EaseFunc func = EaseFunc::Linear /* 速度变化 */ EaseFunc func = EaseFunc::Linear /* 速度变化 */
); );
@ -376,7 +376,7 @@ namespace easy2d
public: public:
// 创建淡入动作 // 创建淡入动作
explicit FadeIn( explicit FadeIn(
Duration const& duration, /* 持续时长 */ Duration duration, /* 持续时长 */
EaseFunc func = EaseFunc::Linear /* 速度变化 */ EaseFunc func = EaseFunc::Linear /* 速度变化 */
); );
}; };
@ -389,7 +389,7 @@ namespace easy2d
public: public:
// 创建淡出动作 // 创建淡出动作
explicit FadeOut( explicit FadeOut(
Duration const& duration, /* 持续时长 */ Duration duration, /* 持续时长 */
EaseFunc func = EaseFunc::Linear /* 速度变化 */ EaseFunc func = EaseFunc::Linear /* 速度变化 */
); );
}; };
@ -397,11 +397,11 @@ namespace easy2d
// 相对旋转动作 // 相对旋转动作
class RotateBy class RotateBy
: public Tween : public ActionTween
{ {
public: public:
explicit RotateBy( explicit RotateBy(
Duration const& duration, /* 持续时长 */ Duration duration, /* 持续时长 */
float rotation, /* 相对变化值 */ float rotation, /* 相对变化值 */
EaseFunc func = EaseFunc::Linear /* 速度变化 */ EaseFunc func = EaseFunc::Linear /* 速度变化 */
); );
@ -429,7 +429,7 @@ namespace easy2d
{ {
public: public:
explicit RotateTo( explicit RotateTo(
Duration const& duration, /* 持续时长 */ Duration duration, /* 持续时长 */
float rotation, /* 目标值 */ float rotation, /* 目标值 */
EaseFunc func = EaseFunc::Linear /* 速度变化 */ EaseFunc func = EaseFunc::Linear /* 速度变化 */
); );
@ -454,11 +454,11 @@ namespace easy2d
// 路径动作 // 路径动作
class PathAction class PathAction
: public Tween : public ActionTween
{ {
public: public:
explicit PathAction( explicit PathAction(
Duration const& duration, /* 持续时长 */ Duration duration, /* 持续时长 */
GeometryPtr const& geo, /* 几何图形 */ GeometryPtr const& geo, /* 几何图形 */
bool rotating = false, /* 沿路径切线方向旋转 */ bool rotating = false, /* 沿路径切线方向旋转 */
float start = 0.f, /* 起点 */ float start = 0.f, /* 起点 */

View File

@ -68,7 +68,7 @@ namespace easy2d
} }
} }
void Animation::Update(Node* target, Duration const& dt) void Animation::Update(Node* target, Duration dt)
{ {
Action::Update(target, dt); Action::Update(target, dt);

View File

@ -58,7 +58,7 @@ namespace easy2d
virtual void Init(Node* target) override; virtual void Init(Node* target) override;
// 更新动作 // 更新动作
virtual void Update(Node* target, Duration const& dt) override; virtual void Update(Node* target, Duration dt) override;
protected: protected:
size_t frame_index_; size_t frame_index_;

View File

@ -82,7 +82,7 @@ namespace easy2d
); );
} }
void DebugNode::OnUpdate(Duration const & dt) void DebugNode::OnUpdate(Duration dt)
{ {
try try
{ {

View File

@ -42,7 +42,7 @@ namespace easy2d
void OnRender() override; void OnRender() override;
void OnUpdate(Duration const& dt) override; void OnUpdate(Duration dt) override;
protected: protected:
TextPtr debug_text_; TextPtr debug_text_;

View File

@ -22,7 +22,7 @@
namespace easy2d namespace easy2d
{ {
Delay::Delay(Duration const& duration) Delay::Delay(Duration duration)
: delta_() : delta_()
, delay_(duration) , delay_(duration)
{ {
@ -39,7 +39,7 @@ namespace easy2d
Action::Init(target); Action::Init(target);
} }
void Delay::Update(Node* target, Duration const& dt) void Delay::Update(Node* target, Duration dt)
{ {
Action::Update(target, dt); Action::Update(target, dt);

View File

@ -29,7 +29,7 @@ namespace easy2d
{ {
public: public:
explicit Delay( explicit Delay(
Duration const& duration /* ÑÓ³Ùʱ³¤£¨Ã룩 */ Duration duration /* ÑÓ³Ùʱ³¤£¨Ã룩 */
); );
// 获取该动作的拷贝对象 // 获取该动作的拷贝对象
@ -44,7 +44,7 @@ namespace easy2d
protected: protected:
virtual void Init(Node* target) override; virtual void Init(Node* target) override;
virtual void Update(Node* target, Duration const& dt) override; virtual void Update(Node* target, Duration dt) override;
protected: protected:
Duration delay_; Duration delay_;

View File

@ -35,7 +35,7 @@ namespace easy2d
this->Add(frames); this->Add(frames);
} }
Frames::Frames(Duration const& interval, Array<ImagePtr> const& frames) Frames::Frames(Duration interval, Array<ImagePtr> const& frames)
: interval_(interval) : interval_(interval)
{ {
this->Add(frames); this->Add(frames);
@ -45,7 +45,7 @@ namespace easy2d
{ {
} }
void Frames::SetInterval(Duration const& interval) void Frames::SetInterval(Duration interval)
{ {
interval_ = interval; interval_ = interval;
} }
@ -68,7 +68,7 @@ namespace easy2d
} }
} }
Duration const& Frames::GetInterval() const Duration Frames::GetInterval() const
{ {
return interval_; return interval_;
} }

View File

@ -36,7 +36,7 @@ namespace easy2d
); );
explicit Frames( explicit Frames(
Duration const& interval, /* Ö¡¼ä¸ô */ Duration interval, /* Ö¡¼ä¸ô */
Array<ImagePtr> const& frames /* 关键帧数组 */ Array<ImagePtr> const& frames /* 关键帧数组 */
); );
@ -53,14 +53,14 @@ namespace easy2d
); );
// 获取帧间隔 // 获取帧间隔
Duration const& GetInterval() const; Duration GetInterval() const;
// 获取关键帧 // 获取关键帧
Array<ImagePtr> const& GetFrames() const; Array<ImagePtr> const& GetFrames() const;
// 设置每一帧的时间间隔 // 设置每一帧的时间间隔
void SetInterval( void SetInterval(
Duration const& interval Duration interval
); );
// 获取帧动画的拷贝对象 // 获取帧动画的拷贝对象

View File

@ -54,7 +54,7 @@ namespace easy2d
{ {
} }
void Node::Update(Duration const & dt) void Node::Update(Duration dt)
{ {
if (pause_) if (pause_)
return; return;

View File

@ -50,7 +50,7 @@ namespace easy2d
Node(); Node();
// 更新节点 // 更新节点
virtual void OnUpdate(Duration const& dt) {} virtual void OnUpdate(Duration dt) {}
// 渲染节点 // 渲染节点
virtual void OnRender() {} virtual void OnRender() {}
@ -349,7 +349,7 @@ namespace easy2d
); );
protected: protected:
void Update(Duration const& dt); void Update(Duration dt);
void Render(); void Render();

View File

@ -27,7 +27,7 @@ namespace easy2d
{ {
} }
Task::Task(Callback const& func, Duration const& delay, int times, String const& name) Task::Task(Callback const& func, Duration delay, int times, String const& name)
: running_(true) : running_(true)
, run_times_(0) , run_times_(0)
, total_times_(times) , total_times_(times)
@ -48,7 +48,7 @@ namespace easy2d
running_ = false; running_ = false;
} }
void Task::Update(Duration const& dt, bool& remove_after_update) void Task::Update(Duration dt, bool& remove_after_update)
{ {
if (!running_) if (!running_)
return; return;

View File

@ -46,7 +46,7 @@ namespace easy2d
explicit Task( explicit Task(
Callback const& func, /* 执行函数 */ Callback const& func, /* 执行函数 */
Duration const& delay, /* 时间间隔(秒) */ Duration delay, /* 时间间隔(秒) */
int times = -1, /* 执行次数(设 -1 为永久执行) */ int times = -1, /* 执行次数(设 -1 为永久执行) */
String const& name = L"" /* 任务名称 */ String const& name = L"" /* 任务名称 */
); );
@ -64,7 +64,7 @@ namespace easy2d
String const& GetName() const; String const& GetName() const;
protected: protected:
void Update(Duration const& dt, bool& remove_after_update); void Update(Duration dt, bool& remove_after_update);
void Reset(); void Reset();

View File

@ -23,7 +23,7 @@
namespace easy2d namespace easy2d
{ {
void TaskManager::UpdateTasks(Duration const& dt) void TaskManager::UpdateTasks(Duration dt)
{ {
if (tasks_.IsEmpty()) if (tasks_.IsEmpty())
return; return;

View File

@ -61,7 +61,7 @@ namespace easy2d
const Tasks& GetAllTasks() const; const Tasks& GetAllTasks() const;
protected: protected:
void UpdateTasks(Duration const& dt); void UpdateTasks(Duration dt);
protected: protected:
Tasks tasks_; Tasks tasks_;

View File

@ -31,7 +31,7 @@ namespace easy2d
// Transition // Transition
//------------------------------------------------------- //-------------------------------------------------------
Transition::Transition(Duration const& duration) Transition::Transition(Duration duration)
: done_(false) : done_(false)
, duration_(duration) , duration_(duration)
, delta_() , delta_()
@ -81,7 +81,7 @@ namespace easy2d
out_layer_prop_ = in_layer_prop_ = LayerProperties{ Rect(Point(), window_size_),1.f }; out_layer_prop_ = in_layer_prop_ = LayerProperties{ Rect(Point(), window_size_),1.f };
} }
void Transition::Update(Duration const& dt) void Transition::Update(Duration dt)
{ {
if (duration_.IsZero()) if (duration_.IsZero())
{ {
@ -142,7 +142,7 @@ namespace easy2d
// BoxTransition // BoxTransition
//------------------------------------------------------- //-------------------------------------------------------
BoxTransition::BoxTransition(Duration const& duration) BoxTransition::BoxTransition(Duration duration)
: Transition(duration) : Transition(duration)
{ {
} }
@ -154,7 +154,7 @@ namespace easy2d
in_layer_prop_.opacity = 0; in_layer_prop_.opacity = 0;
} }
void BoxTransition::Update(Duration const& dt) void BoxTransition::Update(Duration dt)
{ {
Transition::Update(dt); Transition::Update(dt);
@ -184,7 +184,7 @@ namespace easy2d
// EmergeTransition // EmergeTransition
//------------------------------------------------------- //-------------------------------------------------------
EmergeTransition::EmergeTransition(Duration const& duration) EmergeTransition::EmergeTransition(Duration duration)
: Transition(duration) : Transition(duration)
{ {
} }
@ -197,7 +197,7 @@ namespace easy2d
in_layer_prop_.opacity = 0; in_layer_prop_.opacity = 0;
} }
void EmergeTransition::Update(Duration const& dt) void EmergeTransition::Update(Duration dt)
{ {
Transition::Update(dt); Transition::Update(dt);
@ -209,7 +209,7 @@ namespace easy2d
// FadeTransition // FadeTransition
//------------------------------------------------------- //-------------------------------------------------------
FadeTransition::FadeTransition(Duration const& duration) FadeTransition::FadeTransition(Duration duration)
: Transition(duration) : Transition(duration)
{ {
} }
@ -222,7 +222,7 @@ namespace easy2d
in_layer_prop_.opacity = 0; in_layer_prop_.opacity = 0;
} }
void FadeTransition::Update(Duration const& dt) void FadeTransition::Update(Duration dt)
{ {
Transition::Update(dt); Transition::Update(dt);
@ -242,7 +242,7 @@ namespace easy2d
// MoveTransition // MoveTransition
//------------------------------------------------------- //-------------------------------------------------------
MoveTransition::MoveTransition(Duration const& duration, Direction direction) MoveTransition::MoveTransition(Duration duration, Direction direction)
: Transition(duration) : Transition(duration)
, direction_(direction) , direction_(direction)
{ {
@ -285,7 +285,7 @@ namespace easy2d
} }
} }
void MoveTransition::Update(Duration const& dt) void MoveTransition::Update(Duration dt)
{ {
Transition::Update(dt); Transition::Update(dt);
@ -321,7 +321,7 @@ namespace easy2d
// RotationTransition // RotationTransition
//------------------------------------------------------- //-------------------------------------------------------
RotationTransition::RotationTransition(Duration const& duration, float rotation) RotationTransition::RotationTransition(Duration duration, float rotation)
: Transition(duration) : Transition(duration)
, rotation_(rotation) , rotation_(rotation)
{ {
@ -349,7 +349,7 @@ namespace easy2d
in_layer_prop_.opacity = 0; in_layer_prop_.opacity = 0;
} }
void RotationTransition::Update(Duration const& dt) void RotationTransition::Update(Duration dt)
{ {
Transition::Update(dt); Transition::Update(dt);

View File

@ -34,7 +34,7 @@ namespace easy2d
public: public:
explicit Transition( explicit Transition(
Duration const& duration Duration duration
); );
virtual ~Transition(); virtual ~Transition();
@ -47,7 +47,7 @@ namespace easy2d
ScenePtr const& next ScenePtr const& next
); );
virtual void Update(Duration const& dt); virtual void Update(Duration dt);
virtual void Render(); virtual void Render();
@ -76,12 +76,12 @@ namespace easy2d
{ {
public: public:
explicit FadeTransition( explicit FadeTransition(
Duration const& duration /* 动画持续时长 */ Duration duration /* 动画持续时长 */
); );
protected: protected:
// 更新动画 // 更新动画
virtual void Update(Duration const& dt) override; virtual void Update(Duration dt) override;
virtual void Init( virtual void Init(
ScenePtr const& prev, ScenePtr const& prev,
@ -96,11 +96,11 @@ namespace easy2d
{ {
public: public:
explicit EmergeTransition( explicit EmergeTransition(
Duration const& duration /* 动画持续时长 */ Duration duration /* 动画持续时长 */
); );
protected: protected:
virtual void Update(Duration const& dt) override; virtual void Update(Duration dt) override;
virtual void Init( virtual void Init(
ScenePtr const& prev, ScenePtr const& prev,
@ -115,11 +115,11 @@ namespace easy2d
{ {
public: public:
explicit BoxTransition( explicit BoxTransition(
Duration const& duration /* 动画持续时长 */ Duration duration /* 动画持续时长 */
); );
protected: protected:
virtual void Update(Duration const& dt) override; virtual void Update(Duration dt) override;
virtual void Init( virtual void Init(
ScenePtr const& prev, ScenePtr const& prev,
@ -134,12 +134,12 @@ namespace easy2d
{ {
public: public:
explicit MoveTransition( explicit MoveTransition(
Duration const& moveDuration, /* 动画持续时长 */ Duration moveDuration, /* 动画持续时长 */
Direction direction /* 移动方向 */ Direction direction /* 移动方向 */
); );
protected: protected:
virtual void Update(Duration const& dt) override; virtual void Update(Duration dt) override;
virtual void Init( virtual void Init(
ScenePtr const& prev, ScenePtr const& prev,
@ -161,12 +161,12 @@ namespace easy2d
{ {
public: public:
explicit RotationTransition( explicit RotationTransition(
Duration const& moveDuration, /* 动画持续时长 */ Duration moveDuration, /* 动画持续时长 */
float rotation = 360 /* 旋转度数 */ float rotation = 360 /* 旋转度数 */
); );
protected: protected:
virtual void Update(Duration const& dt) override; virtual void Update(Duration dt) override;
virtual void Init( virtual void Init(
ScenePtr const& prev, ScenePtr const& prev,

View File

@ -97,7 +97,7 @@ namespace easy2d
E2D_DECLARE_SMART_PTR(GeometryNode); E2D_DECLARE_SMART_PTR(GeometryNode);
E2D_DECLARE_SMART_PTR(Action); E2D_DECLARE_SMART_PTR(Action);
E2D_DECLARE_SMART_PTR(Tween); E2D_DECLARE_SMART_PTR(ActionTween);
E2D_DECLARE_SMART_PTR(MoveBy); E2D_DECLARE_SMART_PTR(MoveBy);
E2D_DECLARE_SMART_PTR(MoveTo); E2D_DECLARE_SMART_PTR(MoveTo);
E2D_DECLARE_SMART_PTR(JumpBy); E2D_DECLARE_SMART_PTR(JumpBy);

View File

@ -40,16 +40,6 @@ namespace easy2d
{ {
} }
TimePoint::TimePoint(const TimePoint & other)
: dur(other.dur)
{
}
TimePoint::TimePoint(TimePoint && other)
: dur(std::move(other.dur))
{
}
const TimePoint TimePoint::operator+(const Duration & dur) const const TimePoint TimePoint::operator+(const Duration & dur) const
{ {
return TimePoint{ (dur + dur).Milliseconds() }; return TimePoint{ (dur + dur).Milliseconds() };
@ -100,7 +90,7 @@ namespace easy2d
// Duration // Duration
//------------------------------------------------------- //-------------------------------------------------------
const Duration Millisecond = Duration{ 1LL }; const Duration Millisecond = 1L;
const Duration Second = 1000 * Millisecond; const Duration Second = 1000 * Millisecond;
const Duration Minute = 60 * Second; const Duration Minute = 60 * Second;
const Duration Hour = 60 * Minute; const Duration Hour = 60 * Minute;

View File

@ -36,9 +36,8 @@ namespace easy2d
// 1.5 小时: 1.5_h // 1.5 小时: 1.5_h
// 3 小时 45 分 15 秒: 3_h + 45_m + 15_s // 3 小时 45 分 15 秒: 3_h + 45_m + 15_s
// //
class Duration struct Duration
{ {
public:
Duration(); Duration();
Duration( Duration(
@ -122,22 +121,11 @@ namespace easy2d
// TimePoint t1, t2; // TimePoint t1, t2;
// int ms = (t2 - t1).Milliseconds(); // 获取两时间相差的毫秒数 // int ms = (t2 - t1).Milliseconds(); // 获取两时间相差的毫秒数
// //
class TimePoint struct TimePoint
{ {
public:
TimePoint(); TimePoint();
TimePoint( TimePoint(long);
long
);
TimePoint(
const TimePoint& other
);
TimePoint(
TimePoint&& other
);
// 是否是零时 // 是否是零时
inline bool IsZero() const { return dur == 0; } inline bool IsZero() const { return dur == 0; }

View File

@ -58,8 +58,9 @@
#include "core/Task.h" #include "core/Task.h"
#include "core/TaskManager.h" #include "core/TaskManager.h"
#include "core/Action.hpp" #include "core/Action.hpp"
#include "core/ActionCombined.h" #include "core/ActionGroup.h"
#include "core/ActionTween.h" #include "core/ActionTween.h"
#include "core/ActionHelper.h"
#include "core/Animation.h" #include "core/Animation.h"
#include "core/Delay.h" #include "core/Delay.h"
#include "core/ActionManager.h" #include "core/ActionManager.h"