parent
fd3c70d5f0
commit
1f6fa38e81
|
|
@ -20,7 +20,8 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<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\ActionManager.h" />
|
||||
<ClInclude Include="..\..\src\core\Animation.h" />
|
||||
|
|
@ -88,7 +89,7 @@
|
|||
<ClInclude Include="..\..\src\utils\Transcoder.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\core\ActionCombined.cpp" />
|
||||
<ClCompile Include="..\..\src\core\ActionGroup.cpp" />
|
||||
<ClCompile Include="..\..\src\core\ActionTween.cpp" />
|
||||
<ClCompile Include="..\..\src\core\ActionManager.cpp" />
|
||||
<ClCompile Include="..\..\src\core\Animation.cpp" />
|
||||
|
|
|
|||
|
|
@ -2,9 +2,6 @@
|
|||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\easy2d.h" />
|
||||
<ClInclude Include="..\..\src\core\ActionCombined.h">
|
||||
<Filter>core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\Animation.h">
|
||||
<Filter>core</Filter>
|
||||
</ClInclude>
|
||||
|
|
@ -200,6 +197,12 @@
|
|||
<ClInclude Include="..\..\src\core\closure.hpp">
|
||||
<Filter>core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\ActionGroup.h">
|
||||
<Filter>core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\ActionHelper.h">
|
||||
<Filter>core</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="core">
|
||||
|
|
@ -216,9 +219,6 @@
|
|||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\core\ActionCombined.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\Animation.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
|
|
@ -348,5 +348,8 @@
|
|||
<ClCompile Include="..\..\src\core\Application.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\ActionGroup.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -20,7 +20,8 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<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\ActionManager.h" />
|
||||
<ClInclude Include="..\..\src\core\Animation.h" />
|
||||
|
|
@ -88,7 +89,7 @@
|
|||
<ClInclude Include="..\..\src\utils\Transcoder.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\core\ActionCombined.cpp" />
|
||||
<ClCompile Include="..\..\src\core\ActionGroup.cpp" />
|
||||
<ClCompile Include="..\..\src\core\ActionTween.cpp" />
|
||||
<ClCompile Include="..\..\src\core\ActionManager.cpp" />
|
||||
<ClCompile Include="..\..\src\core\Animation.cpp" />
|
||||
|
|
|
|||
|
|
@ -2,9 +2,6 @@
|
|||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\easy2d.h" />
|
||||
<ClInclude Include="..\..\src\core\ActionCombined.h">
|
||||
<Filter>core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\Animation.h">
|
||||
<Filter>core</Filter>
|
||||
</ClInclude>
|
||||
|
|
@ -200,6 +197,12 @@
|
|||
<ClInclude Include="..\..\src\core\closure.hpp">
|
||||
<Filter>core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\ActionGroup.h">
|
||||
<Filter>core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\ActionHelper.h">
|
||||
<Filter>core</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="core">
|
||||
|
|
@ -216,9 +219,6 @@
|
|||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\core\ActionCombined.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\Animation.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
|
|
@ -348,5 +348,8 @@
|
|||
<ClCompile Include="..\..\src\core\Application.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\ActionGroup.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -20,7 +20,8 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<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\ActionManager.h" />
|
||||
<ClInclude Include="..\..\src\core\Animation.h" />
|
||||
|
|
@ -88,7 +89,7 @@
|
|||
<ClInclude Include="..\..\src\utils\Transcoder.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\core\ActionCombined.cpp" />
|
||||
<ClCompile Include="..\..\src\core\ActionGroup.cpp" />
|
||||
<ClCompile Include="..\..\src\core\ActionTween.cpp" />
|
||||
<ClCompile Include="..\..\src\core\ActionManager.cpp" />
|
||||
<ClCompile Include="..\..\src\core\Animation.cpp" />
|
||||
|
|
|
|||
|
|
@ -2,9 +2,6 @@
|
|||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\easy2d.h" />
|
||||
<ClInclude Include="..\..\src\core\ActionCombined.h">
|
||||
<Filter>core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\Animation.h">
|
||||
<Filter>core</Filter>
|
||||
</ClInclude>
|
||||
|
|
@ -200,6 +197,12 @@
|
|||
<ClInclude Include="..\..\src\core\closure.hpp">
|
||||
<Filter>core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\ActionGroup.h">
|
||||
<Filter>core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\core\ActionHelper.h">
|
||||
<Filter>core</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="core">
|
||||
|
|
@ -216,9 +219,6 @@
|
|||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\core\ActionCombined.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\Animation.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
|
|
@ -348,5 +348,8 @@
|
|||
<ClCompile Include="..\..\src\core\Application.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\core\ActionGroup.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -43,17 +43,14 @@ namespace easy2d
|
|||
|
||||
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;
|
||||
|
|
@ -61,6 +58,9 @@ namespace easy2d
|
|||
// 获取动作的倒转
|
||||
virtual ActionPtr Reverse() const = 0;
|
||||
|
||||
// 设置动作结束时的回调函数
|
||||
void SetCallback(std::function<void()> cb) { cb_ = cb; }
|
||||
|
||||
// 重置动作
|
||||
virtual void Reset()
|
||||
{
|
||||
|
|
@ -68,13 +68,12 @@ namespace easy2d
|
|||
done_ = false;
|
||||
}
|
||||
|
||||
// 设置动作结束时的回调函数
|
||||
void SetCallback(std::function<void()> cb) { cb_ = cb; }
|
||||
|
||||
virtual bool IsDone() const { return done_; }
|
||||
|
||||
virtual bool IsRunning() { return running_; }
|
||||
|
||||
protected:
|
||||
virtual void Start()
|
||||
void Start()
|
||||
{
|
||||
running_ = true;
|
||||
this->Reset();
|
||||
|
|
@ -82,7 +81,7 @@ namespace easy2d
|
|||
|
||||
virtual void Init(Node* target) { initialized_ = true; }
|
||||
|
||||
virtual void Update(Node* target, Duration const& dt)
|
||||
virtual void Update(Node* target, Duration dt)
|
||||
{
|
||||
if (!initialized_)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "ActionCombined.h"
|
||||
#include "ActionGroup.h"
|
||||
#include "logs.h"
|
||||
|
||||
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);
|
||||
|
||||
|
|
@ -141,7 +141,7 @@ namespace easy2d
|
|||
actions_[0]->Init(target);
|
||||
}
|
||||
|
||||
void Sequence::Update(Node* target, Duration const& dt)
|
||||
void Sequence::Update(Node* target, Duration 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);
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ namespace easy2d
|
|||
virtual void Init(Node* target) override;
|
||||
|
||||
// 更新动作
|
||||
virtual void Update(Node* target, Duration const& dt) override;
|
||||
virtual void Update(Node* target, Duration dt) override;
|
||||
|
||||
protected:
|
||||
ActionPtr action_;
|
||||
|
|
@ -97,7 +97,7 @@ namespace easy2d
|
|||
virtual void Init(Node* target) override;
|
||||
|
||||
// 更新动作
|
||||
virtual void Update(Node* target, Duration const& dt) override;
|
||||
virtual void Update(Node* target, Duration dt) override;
|
||||
|
||||
protected:
|
||||
UINT action_index_;
|
||||
|
|
@ -142,7 +142,7 @@ namespace easy2d
|
|||
virtual void Init(Node* target) override;
|
||||
|
||||
// 更新动作
|
||||
virtual void Update(Node* target, Duration const& dt) override;
|
||||
virtual void Update(Node* target, Duration dt) override;
|
||||
|
||||
protected:
|
||||
Array<ActionPtr> actions_;
|
||||
|
|
@ -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));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
namespace easy2d
|
||||
{
|
||||
void ActionManager::UpdateActions(Node* target, Duration const& dt)
|
||||
void ActionManager::UpdateActions(Node* target, Duration dt)
|
||||
{
|
||||
if (actions_.IsEmpty())
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ namespace easy2d
|
|||
Actions const& GetAllActions() const;
|
||||
|
||||
protected:
|
||||
void UpdateActions(Node* target, Duration const& dt);
|
||||
void UpdateActions(Node* target, Duration dt);
|
||||
|
||||
protected:
|
||||
Actions actions_;
|
||||
|
|
|
|||
|
|
@ -27,10 +27,10 @@
|
|||
namespace easy2d
|
||||
{
|
||||
//-------------------------------------------------------
|
||||
// Tween
|
||||
// ActionTween
|
||||
//-------------------------------------------------------
|
||||
|
||||
Tween::Tween()
|
||||
ActionTween::ActionTween()
|
||||
: elapsed_()
|
||||
, duration_()
|
||||
, ease_func_(math::Linear)
|
||||
|
|
@ -38,7 +38,7 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
Tween::Tween(Duration const& duration, EaseFunc func)
|
||||
ActionTween::ActionTween(Duration duration, EaseFunc func)
|
||||
: elapsed_()
|
||||
, ease_func_(math::Linear)
|
||||
, ease_type_(EaseFunc::Linear)
|
||||
|
|
@ -47,7 +47,7 @@ namespace easy2d
|
|||
SetEaseFunction(func);
|
||||
}
|
||||
|
||||
void Tween::SetEaseFunction(EaseFunc func)
|
||||
void ActionTween::SetEaseFunction(EaseFunc func)
|
||||
{
|
||||
ease_type_ = func;
|
||||
switch (func)
|
||||
|
|
@ -150,29 +150,29 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
void Tween::SetEaseFunction(EaseFunction func)
|
||||
void ActionTween::SetEaseFunction(EaseFunction func)
|
||||
{
|
||||
ease_func_ = func;
|
||||
ease_type_ = EaseFunc(-1);
|
||||
}
|
||||
|
||||
void Tween::Reset()
|
||||
void ActionTween::Reset()
|
||||
{
|
||||
Action::Reset();
|
||||
elapsed_ = Duration{};
|
||||
}
|
||||
|
||||
Duration const & Tween::GetDuration() const
|
||||
Duration ActionTween::GetDuration() const
|
||||
{
|
||||
return duration_;
|
||||
}
|
||||
|
||||
void Tween::Init(Node* target)
|
||||
void ActionTween::Init(Node* target)
|
||||
{
|
||||
Action::Init(target);
|
||||
}
|
||||
|
||||
void Tween::Update(Node* target, Duration const& dt)
|
||||
void ActionTween::Update(Node* target, Duration dt)
|
||||
{
|
||||
Action::Update(target, dt);
|
||||
|
||||
|
|
@ -195,7 +195,7 @@ namespace easy2d
|
|||
UpdateStep(target, ease_func_(step));
|
||||
}
|
||||
|
||||
void Tween::SetDuration(Duration const & duration)
|
||||
void ActionTween::SetDuration(Duration duration)
|
||||
{
|
||||
duration_ = duration;
|
||||
}
|
||||
|
|
@ -205,15 +205,15 @@ namespace easy2d
|
|||
// Move Action
|
||||
//-------------------------------------------------------
|
||||
|
||||
MoveBy::MoveBy(Duration const& duration, Point const& vector, EaseFunc func)
|
||||
: Tween(duration, func)
|
||||
MoveBy::MoveBy(Duration duration, Point const& vector, EaseFunc func)
|
||||
: ActionTween(duration, func)
|
||||
{
|
||||
delta_pos_ = vector;
|
||||
}
|
||||
|
||||
void MoveBy::Init(Node* target)
|
||||
{
|
||||
Tween::Init(target);
|
||||
ActionTween::Init(target);
|
||||
|
||||
if (target)
|
||||
{
|
||||
|
|
@ -245,7 +245,7 @@ namespace easy2d
|
|||
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)
|
||||
{
|
||||
end_pos_ = pos;
|
||||
|
|
@ -267,8 +267,8 @@ namespace easy2d
|
|||
// Jump Action
|
||||
//-------------------------------------------------------
|
||||
|
||||
JumpBy::JumpBy(Duration const& duration, Point const& vec, float height, int jumps, EaseFunc func)
|
||||
: Tween(duration, func)
|
||||
JumpBy::JumpBy(Duration duration, Point const& vec, float height, int jumps, EaseFunc func)
|
||||
: ActionTween(duration, func)
|
||||
, delta_pos_(vec)
|
||||
, height_(height)
|
||||
, jumps_(jumps)
|
||||
|
|
@ -287,7 +287,7 @@ namespace easy2d
|
|||
|
||||
void JumpBy::Init(Node* target)
|
||||
{
|
||||
Tween::Init(target);
|
||||
ActionTween::Init(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)
|
||||
, end_pos_(pos)
|
||||
{
|
||||
|
|
@ -336,15 +336,15 @@ namespace easy2d
|
|||
// Scale Action
|
||||
//-------------------------------------------------------
|
||||
|
||||
ScaleBy::ScaleBy(Duration const& duration, float scale, EaseFunc func)
|
||||
: Tween(duration, func)
|
||||
ScaleBy::ScaleBy(Duration duration, float scale, EaseFunc func)
|
||||
: ActionTween(duration, func)
|
||||
{
|
||||
delta_x_ = scale;
|
||||
delta_y_ = scale;
|
||||
}
|
||||
|
||||
ScaleBy::ScaleBy(Duration const& duration, float scale_x, float scale_y, EaseFunc func)
|
||||
: Tween(duration, func)
|
||||
ScaleBy::ScaleBy(Duration duration, float scale_x, float scale_y, EaseFunc func)
|
||||
: ActionTween(duration, func)
|
||||
{
|
||||
delta_x_ = scale_x;
|
||||
delta_y_ = scale_y;
|
||||
|
|
@ -352,7 +352,7 @@ namespace easy2d
|
|||
|
||||
void ScaleBy::Init(Node* target)
|
||||
{
|
||||
Tween::Init(target);
|
||||
ActionTween::Init(target);
|
||||
|
||||
if (target)
|
||||
{
|
||||
|
|
@ -379,14 +379,14 @@ namespace easy2d
|
|||
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)
|
||||
{
|
||||
end_scale_x_ = 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)
|
||||
{
|
||||
end_scale_x_ = scale_x;
|
||||
|
|
@ -410,15 +410,15 @@ namespace easy2d
|
|||
// Opacity Action
|
||||
//-------------------------------------------------------
|
||||
|
||||
OpacityBy::OpacityBy(Duration const& duration, float opacity, EaseFunc func)
|
||||
: Tween(duration, func)
|
||||
OpacityBy::OpacityBy(Duration duration, float opacity, EaseFunc func)
|
||||
: ActionTween(duration, func)
|
||||
{
|
||||
delta_val_ = opacity;
|
||||
}
|
||||
|
||||
void OpacityBy::Init(Node* target)
|
||||
{
|
||||
Tween::Init(target);
|
||||
ActionTween::Init(target);
|
||||
|
||||
if (target)
|
||||
{
|
||||
|
|
@ -444,7 +444,7 @@ namespace easy2d
|
|||
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)
|
||||
{
|
||||
end_val_ = opacity;
|
||||
|
|
@ -461,12 +461,12 @@ namespace easy2d
|
|||
delta_val_ = end_val_ - start_val_;
|
||||
}
|
||||
|
||||
FadeIn::FadeIn(Duration const& duration, EaseFunc func)
|
||||
FadeIn::FadeIn(Duration duration, EaseFunc func)
|
||||
: OpacityTo(duration, 1, func)
|
||||
{
|
||||
}
|
||||
|
||||
FadeOut::FadeOut(Duration const& duration, EaseFunc func)
|
||||
FadeOut::FadeOut(Duration duration, EaseFunc func)
|
||||
: OpacityTo(duration, 0, func)
|
||||
{
|
||||
}
|
||||
|
|
@ -476,15 +476,15 @@ namespace easy2d
|
|||
// Rotate Action
|
||||
//-------------------------------------------------------
|
||||
|
||||
RotateBy::RotateBy(Duration const& duration, float rotation, EaseFunc func)
|
||||
: Tween(duration, func)
|
||||
RotateBy::RotateBy(Duration duration, float rotation, EaseFunc func)
|
||||
: ActionTween(duration, func)
|
||||
, delta_val_(rotation)
|
||||
{
|
||||
}
|
||||
|
||||
void RotateBy::Init(Node* target)
|
||||
{
|
||||
Tween::Init(target);
|
||||
ActionTween::Init(target);
|
||||
|
||||
if (target)
|
||||
{
|
||||
|
|
@ -510,7 +510,7 @@ namespace easy2d
|
|||
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)
|
||||
{
|
||||
end_val_ = rotation;
|
||||
|
|
@ -532,8 +532,8 @@ namespace easy2d
|
|||
// PathAction
|
||||
//-------------------------------------------------------
|
||||
|
||||
PathAction::PathAction(Duration const & duration, GeometryPtr const& geo, bool rotating, float start, float end, EaseFunc func)
|
||||
: Tween(duration, func)
|
||||
PathAction::PathAction(Duration duration, GeometryPtr const& geo, bool rotating, float start, float end, EaseFunc func)
|
||||
: ActionTween(duration, func)
|
||||
, start_(start)
|
||||
, end_(end)
|
||||
, geo_(geo)
|
||||
|
|
@ -553,7 +553,7 @@ namespace easy2d
|
|||
|
||||
void PathAction::Init(Node * target)
|
||||
{
|
||||
Tween::Init(target);
|
||||
ActionTween::Init(target);
|
||||
|
||||
if (target)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -74,14 +74,14 @@ namespace easy2d
|
|||
|
||||
|
||||
// 补间动画
|
||||
class Tween
|
||||
class ActionTween
|
||||
: public Action
|
||||
{
|
||||
public:
|
||||
Tween();
|
||||
ActionTween();
|
||||
|
||||
explicit Tween(
|
||||
Duration const& duration,
|
||||
explicit ActionTween(
|
||||
Duration duration,
|
||||
EaseFunc func
|
||||
);
|
||||
|
||||
|
|
@ -97,14 +97,14 @@ namespace easy2d
|
|||
|
||||
virtual void Reset() override;
|
||||
|
||||
Duration const& GetDuration() const;
|
||||
Duration GetDuration() const;
|
||||
|
||||
void SetDuration(Duration const& duration);
|
||||
void SetDuration(Duration duration);
|
||||
|
||||
protected:
|
||||
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;
|
||||
|
||||
|
|
@ -118,11 +118,11 @@ namespace easy2d
|
|||
|
||||
// 相对位移动作
|
||||
class MoveBy
|
||||
: public Tween
|
||||
: public ActionTween
|
||||
{
|
||||
public:
|
||||
explicit MoveBy(
|
||||
Duration const& duration, /* 持续时长 */
|
||||
Duration duration, /* 持续时长 */
|
||||
Point const& vector, /* 移动距离 */
|
||||
EaseFunc func = EaseFunc::Linear /* 速度变化 */
|
||||
);
|
||||
|
|
@ -151,7 +151,7 @@ namespace easy2d
|
|||
{
|
||||
public:
|
||||
explicit MoveTo(
|
||||
Duration const& duration, /* 持续时长 */
|
||||
Duration duration, /* 持续时长 */
|
||||
Point const& pos, /* 目的坐标 */
|
||||
EaseFunc func = EaseFunc::Linear /* 速度变化 */
|
||||
);
|
||||
|
|
@ -176,11 +176,11 @@ namespace easy2d
|
|||
|
||||
// 相对跳跃动作
|
||||
class JumpBy
|
||||
: public Tween
|
||||
: public ActionTween
|
||||
{
|
||||
public:
|
||||
explicit JumpBy(
|
||||
Duration const& duration, /* 持续时长 */
|
||||
Duration duration, /* 持续时长 */
|
||||
Point const& vec, /* 跳跃距离 */
|
||||
float height, /* 跳跃高度 */
|
||||
int jumps = 1, /* 跳跃次数 */
|
||||
|
|
@ -213,7 +213,7 @@ namespace easy2d
|
|||
{
|
||||
public:
|
||||
explicit JumpTo(
|
||||
Duration const& duration, /* 持续时长 */
|
||||
Duration duration, /* 持续时长 */
|
||||
Point const& pos, /* 目的坐标 */
|
||||
float height, /* 跳跃高度 */
|
||||
int jumps = 1, /* 跳跃次数 */
|
||||
|
|
@ -240,17 +240,17 @@ namespace easy2d
|
|||
|
||||
// 相对缩放动作
|
||||
class ScaleBy
|
||||
: public Tween
|
||||
: public ActionTween
|
||||
{
|
||||
public:
|
||||
explicit ScaleBy(
|
||||
Duration const& duration, /* 持续时长 */
|
||||
Duration duration, /* 持续时长 */
|
||||
float scale, /* 相对变化值 */
|
||||
EaseFunc func = EaseFunc::Linear /* 速度变化 */
|
||||
);
|
||||
|
||||
explicit ScaleBy(
|
||||
Duration const& duration, /* 持续时长 */
|
||||
Duration duration, /* 持续时长 */
|
||||
float scale_x, /* 横向缩放相对变化值 */
|
||||
float scale_y, /* 纵向缩放相对变化值 */
|
||||
EaseFunc func = EaseFunc::Linear /* 速度变化 */
|
||||
|
|
@ -281,13 +281,13 @@ namespace easy2d
|
|||
{
|
||||
public:
|
||||
explicit ScaleTo(
|
||||
Duration const& duration, /* 持续时长 */
|
||||
Duration duration, /* 持续时长 */
|
||||
float scale, /* 目标值 */
|
||||
EaseFunc func = EaseFunc::Linear /* 速度变化 */
|
||||
);
|
||||
|
||||
explicit ScaleTo(
|
||||
Duration const& duration, /* 持续时长 */
|
||||
Duration duration, /* 持续时长 */
|
||||
float scale_x, /* 横向缩放目标值 */
|
||||
float scale_y, /* 纵向缩放目标值 */
|
||||
EaseFunc func = EaseFunc::Linear /* 速度变化 */
|
||||
|
|
@ -314,11 +314,11 @@ namespace easy2d
|
|||
|
||||
// 透明度相对渐变动作
|
||||
class OpacityBy
|
||||
: public Tween
|
||||
: public ActionTween
|
||||
{
|
||||
public:
|
||||
explicit OpacityBy(
|
||||
Duration const& duration, /* 持续时长 */
|
||||
Duration duration, /* 持续时长 */
|
||||
float opacity, /* 相对变化值 */
|
||||
EaseFunc func = EaseFunc::Linear /* 速度变化 */
|
||||
);
|
||||
|
|
@ -346,7 +346,7 @@ namespace easy2d
|
|||
{
|
||||
public:
|
||||
explicit OpacityTo(
|
||||
Duration const& duration, /* 持续时长 */
|
||||
Duration duration, /* 持续时长 */
|
||||
float opacity, /* 目标值 */
|
||||
EaseFunc func = EaseFunc::Linear /* 速度变化 */
|
||||
);
|
||||
|
|
@ -376,7 +376,7 @@ namespace easy2d
|
|||
public:
|
||||
// 创建淡入动作
|
||||
explicit FadeIn(
|
||||
Duration const& duration, /* 持续时长 */
|
||||
Duration duration, /* 持续时长 */
|
||||
EaseFunc func = EaseFunc::Linear /* 速度变化 */
|
||||
);
|
||||
};
|
||||
|
|
@ -389,7 +389,7 @@ namespace easy2d
|
|||
public:
|
||||
// 创建淡出动作
|
||||
explicit FadeOut(
|
||||
Duration const& duration, /* 持续时长 */
|
||||
Duration duration, /* 持续时长 */
|
||||
EaseFunc func = EaseFunc::Linear /* 速度变化 */
|
||||
);
|
||||
};
|
||||
|
|
@ -397,11 +397,11 @@ namespace easy2d
|
|||
|
||||
// 相对旋转动作
|
||||
class RotateBy
|
||||
: public Tween
|
||||
: public ActionTween
|
||||
{
|
||||
public:
|
||||
explicit RotateBy(
|
||||
Duration const& duration, /* 持续时长 */
|
||||
Duration duration, /* 持续时长 */
|
||||
float rotation, /* 相对变化值 */
|
||||
EaseFunc func = EaseFunc::Linear /* 速度变化 */
|
||||
);
|
||||
|
|
@ -429,7 +429,7 @@ namespace easy2d
|
|||
{
|
||||
public:
|
||||
explicit RotateTo(
|
||||
Duration const& duration, /* 持续时长 */
|
||||
Duration duration, /* 持续时长 */
|
||||
float rotation, /* 目标值 */
|
||||
EaseFunc func = EaseFunc::Linear /* 速度变化 */
|
||||
);
|
||||
|
|
@ -454,11 +454,11 @@ namespace easy2d
|
|||
|
||||
// 路径动作
|
||||
class PathAction
|
||||
: public Tween
|
||||
: public ActionTween
|
||||
{
|
||||
public:
|
||||
explicit PathAction(
|
||||
Duration const& duration, /* 持续时长 */
|
||||
Duration duration, /* 持续时长 */
|
||||
GeometryPtr const& geo, /* 几何图形 */
|
||||
bool rotating = false, /* 沿路径切线方向旋转 */
|
||||
float start = 0.f, /* 起点 */
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ namespace easy2d
|
|||
virtual void Init(Node* target) override;
|
||||
|
||||
// 更新动作
|
||||
virtual void Update(Node* target, Duration const& dt) override;
|
||||
virtual void Update(Node* target, Duration dt) override;
|
||||
|
||||
protected:
|
||||
size_t frame_index_;
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ namespace easy2d
|
|||
);
|
||||
}
|
||||
|
||||
void DebugNode::OnUpdate(Duration const & dt)
|
||||
void DebugNode::OnUpdate(Duration dt)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ namespace easy2d
|
|||
|
||||
void OnRender() override;
|
||||
|
||||
void OnUpdate(Duration const& dt) override;
|
||||
void OnUpdate(Duration dt) override;
|
||||
|
||||
protected:
|
||||
TextPtr debug_text_;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
namespace easy2d
|
||||
{
|
||||
Delay::Delay(Duration const& duration)
|
||||
Delay::Delay(Duration duration)
|
||||
: delta_()
|
||||
, delay_(duration)
|
||||
{
|
||||
|
|
@ -39,7 +39,7 @@ namespace easy2d
|
|||
Action::Init(target);
|
||||
}
|
||||
|
||||
void Delay::Update(Node* target, Duration const& dt)
|
||||
void Delay::Update(Node* target, Duration dt)
|
||||
{
|
||||
Action::Update(target, dt);
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace easy2d
|
|||
{
|
||||
public:
|
||||
explicit Delay(
|
||||
Duration const& duration /* ÑÓ³Ùʱ³¤£¨Ã룩 */
|
||||
Duration duration /* ÑÓ³Ùʱ³¤£¨Ã룩 */
|
||||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
|
|
@ -44,7 +44,7 @@ namespace easy2d
|
|||
protected:
|
||||
virtual void Init(Node* target) override;
|
||||
|
||||
virtual void Update(Node* target, Duration const& dt) override;
|
||||
virtual void Update(Node* target, Duration dt) override;
|
||||
|
||||
protected:
|
||||
Duration delay_;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ namespace easy2d
|
|||
this->Add(frames);
|
||||
}
|
||||
|
||||
Frames::Frames(Duration const& interval, Array<ImagePtr> const& frames)
|
||||
Frames::Frames(Duration interval, Array<ImagePtr> const& frames)
|
||||
: interval_(interval)
|
||||
{
|
||||
this->Add(frames);
|
||||
|
|
@ -45,7 +45,7 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
void Frames::SetInterval(Duration const& interval)
|
||||
void Frames::SetInterval(Duration interval)
|
||||
{
|
||||
interval_ = interval;
|
||||
}
|
||||
|
|
@ -68,7 +68,7 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
Duration const& Frames::GetInterval() const
|
||||
Duration Frames::GetInterval() const
|
||||
{
|
||||
return interval_;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace easy2d
|
|||
);
|
||||
|
||||
explicit Frames(
|
||||
Duration const& interval, /* Ö¡¼ä¸ô */
|
||||
Duration interval, /* Ö¡¼ä¸ô */
|
||||
Array<ImagePtr> const& frames /* 关键帧数组 */
|
||||
);
|
||||
|
||||
|
|
@ -53,14 +53,14 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取帧间隔
|
||||
Duration const& GetInterval() const;
|
||||
Duration GetInterval() const;
|
||||
|
||||
// 获取关键帧
|
||||
Array<ImagePtr> const& GetFrames() const;
|
||||
|
||||
// 设置每一帧的时间间隔
|
||||
void SetInterval(
|
||||
Duration const& interval
|
||||
Duration interval
|
||||
);
|
||||
|
||||
// 获取帧动画的拷贝对象
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
void Node::Update(Duration const & dt)
|
||||
void Node::Update(Duration dt)
|
||||
{
|
||||
if (pause_)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ namespace easy2d
|
|||
Node();
|
||||
|
||||
// 更新节点
|
||||
virtual void OnUpdate(Duration const& dt) {}
|
||||
virtual void OnUpdate(Duration dt) {}
|
||||
|
||||
// 渲染节点
|
||||
virtual void OnRender() {}
|
||||
|
|
@ -349,7 +349,7 @@ namespace easy2d
|
|||
);
|
||||
|
||||
protected:
|
||||
void Update(Duration const& dt);
|
||||
void Update(Duration dt);
|
||||
|
||||
void Render();
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
, run_times_(0)
|
||||
, total_times_(times)
|
||||
|
|
@ -48,7 +48,7 @@ namespace easy2d
|
|||
running_ = false;
|
||||
}
|
||||
|
||||
void Task::Update(Duration const& dt, bool& remove_after_update)
|
||||
void Task::Update(Duration dt, bool& remove_after_update)
|
||||
{
|
||||
if (!running_)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ namespace easy2d
|
|||
|
||||
explicit Task(
|
||||
Callback const& func, /* 执行函数 */
|
||||
Duration const& delay, /* 时间间隔(秒) */
|
||||
Duration delay, /* 时间间隔(秒) */
|
||||
int times = -1, /* 执行次数(设 -1 为永久执行) */
|
||||
String const& name = L"" /* 任务名称 */
|
||||
);
|
||||
|
|
@ -64,7 +64,7 @@ namespace easy2d
|
|||
String const& GetName() const;
|
||||
|
||||
protected:
|
||||
void Update(Duration const& dt, bool& remove_after_update);
|
||||
void Update(Duration dt, bool& remove_after_update);
|
||||
|
||||
void Reset();
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
namespace easy2d
|
||||
{
|
||||
void TaskManager::UpdateTasks(Duration const& dt)
|
||||
void TaskManager::UpdateTasks(Duration dt)
|
||||
{
|
||||
if (tasks_.IsEmpty())
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ namespace easy2d
|
|||
const Tasks& GetAllTasks() const;
|
||||
|
||||
protected:
|
||||
void UpdateTasks(Duration const& dt);
|
||||
void UpdateTasks(Duration dt);
|
||||
|
||||
protected:
|
||||
Tasks tasks_;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace easy2d
|
|||
// Transition
|
||||
//-------------------------------------------------------
|
||||
|
||||
Transition::Transition(Duration const& duration)
|
||||
Transition::Transition(Duration duration)
|
||||
: done_(false)
|
||||
, duration_(duration)
|
||||
, delta_()
|
||||
|
|
@ -81,7 +81,7 @@ namespace easy2d
|
|||
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())
|
||||
{
|
||||
|
|
@ -142,7 +142,7 @@ namespace easy2d
|
|||
// BoxTransition
|
||||
//-------------------------------------------------------
|
||||
|
||||
BoxTransition::BoxTransition(Duration const& duration)
|
||||
BoxTransition::BoxTransition(Duration duration)
|
||||
: Transition(duration)
|
||||
{
|
||||
}
|
||||
|
|
@ -154,7 +154,7 @@ namespace easy2d
|
|||
in_layer_prop_.opacity = 0;
|
||||
}
|
||||
|
||||
void BoxTransition::Update(Duration const& dt)
|
||||
void BoxTransition::Update(Duration dt)
|
||||
{
|
||||
Transition::Update(dt);
|
||||
|
||||
|
|
@ -184,7 +184,7 @@ namespace easy2d
|
|||
// EmergeTransition
|
||||
//-------------------------------------------------------
|
||||
|
||||
EmergeTransition::EmergeTransition(Duration const& duration)
|
||||
EmergeTransition::EmergeTransition(Duration duration)
|
||||
: Transition(duration)
|
||||
{
|
||||
}
|
||||
|
|
@ -197,7 +197,7 @@ namespace easy2d
|
|||
in_layer_prop_.opacity = 0;
|
||||
}
|
||||
|
||||
void EmergeTransition::Update(Duration const& dt)
|
||||
void EmergeTransition::Update(Duration dt)
|
||||
{
|
||||
Transition::Update(dt);
|
||||
|
||||
|
|
@ -209,7 +209,7 @@ namespace easy2d
|
|||
// FadeTransition
|
||||
//-------------------------------------------------------
|
||||
|
||||
FadeTransition::FadeTransition(Duration const& duration)
|
||||
FadeTransition::FadeTransition(Duration duration)
|
||||
: Transition(duration)
|
||||
{
|
||||
}
|
||||
|
|
@ -222,7 +222,7 @@ namespace easy2d
|
|||
in_layer_prop_.opacity = 0;
|
||||
}
|
||||
|
||||
void FadeTransition::Update(Duration const& dt)
|
||||
void FadeTransition::Update(Duration dt)
|
||||
{
|
||||
Transition::Update(dt);
|
||||
|
||||
|
|
@ -242,7 +242,7 @@ namespace easy2d
|
|||
// MoveTransition
|
||||
//-------------------------------------------------------
|
||||
|
||||
MoveTransition::MoveTransition(Duration const& duration, Direction direction)
|
||||
MoveTransition::MoveTransition(Duration duration, Direction direction)
|
||||
: Transition(duration)
|
||||
, direction_(direction)
|
||||
{
|
||||
|
|
@ -285,7 +285,7 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
void MoveTransition::Update(Duration const& dt)
|
||||
void MoveTransition::Update(Duration dt)
|
||||
{
|
||||
Transition::Update(dt);
|
||||
|
||||
|
|
@ -321,7 +321,7 @@ namespace easy2d
|
|||
// RotationTransition
|
||||
//-------------------------------------------------------
|
||||
|
||||
RotationTransition::RotationTransition(Duration const& duration, float rotation)
|
||||
RotationTransition::RotationTransition(Duration duration, float rotation)
|
||||
: Transition(duration)
|
||||
, rotation_(rotation)
|
||||
{
|
||||
|
|
@ -349,7 +349,7 @@ namespace easy2d
|
|||
in_layer_prop_.opacity = 0;
|
||||
}
|
||||
|
||||
void RotationTransition::Update(Duration const& dt)
|
||||
void RotationTransition::Update(Duration dt)
|
||||
{
|
||||
Transition::Update(dt);
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace easy2d
|
|||
|
||||
public:
|
||||
explicit Transition(
|
||||
Duration const& duration
|
||||
Duration duration
|
||||
);
|
||||
|
||||
virtual ~Transition();
|
||||
|
|
@ -47,7 +47,7 @@ namespace easy2d
|
|||
ScenePtr const& next
|
||||
);
|
||||
|
||||
virtual void Update(Duration const& dt);
|
||||
virtual void Update(Duration dt);
|
||||
|
||||
virtual void Render();
|
||||
|
||||
|
|
@ -76,12 +76,12 @@ namespace easy2d
|
|||
{
|
||||
public:
|
||||
explicit FadeTransition(
|
||||
Duration const& duration /* 动画持续时长 */
|
||||
Duration duration /* 动画持续时长 */
|
||||
);
|
||||
|
||||
protected:
|
||||
// 更新动画
|
||||
virtual void Update(Duration const& dt) override;
|
||||
virtual void Update(Duration dt) override;
|
||||
|
||||
virtual void Init(
|
||||
ScenePtr const& prev,
|
||||
|
|
@ -96,11 +96,11 @@ namespace easy2d
|
|||
{
|
||||
public:
|
||||
explicit EmergeTransition(
|
||||
Duration const& duration /* 动画持续时长 */
|
||||
Duration duration /* 动画持续时长 */
|
||||
);
|
||||
|
||||
protected:
|
||||
virtual void Update(Duration const& dt) override;
|
||||
virtual void Update(Duration dt) override;
|
||||
|
||||
virtual void Init(
|
||||
ScenePtr const& prev,
|
||||
|
|
@ -115,11 +115,11 @@ namespace easy2d
|
|||
{
|
||||
public:
|
||||
explicit BoxTransition(
|
||||
Duration const& duration /* 动画持续时长 */
|
||||
Duration duration /* 动画持续时长 */
|
||||
);
|
||||
|
||||
protected:
|
||||
virtual void Update(Duration const& dt) override;
|
||||
virtual void Update(Duration dt) override;
|
||||
|
||||
virtual void Init(
|
||||
ScenePtr const& prev,
|
||||
|
|
@ -134,12 +134,12 @@ namespace easy2d
|
|||
{
|
||||
public:
|
||||
explicit MoveTransition(
|
||||
Duration const& moveDuration, /* 动画持续时长 */
|
||||
Duration moveDuration, /* 动画持续时长 */
|
||||
Direction direction /* 移动方向 */
|
||||
);
|
||||
|
||||
protected:
|
||||
virtual void Update(Duration const& dt) override;
|
||||
virtual void Update(Duration dt) override;
|
||||
|
||||
virtual void Init(
|
||||
ScenePtr const& prev,
|
||||
|
|
@ -161,12 +161,12 @@ namespace easy2d
|
|||
{
|
||||
public:
|
||||
explicit RotationTransition(
|
||||
Duration const& moveDuration, /* 动画持续时长 */
|
||||
Duration moveDuration, /* 动画持续时长 */
|
||||
float rotation = 360 /* 旋转度数 */
|
||||
);
|
||||
|
||||
protected:
|
||||
virtual void Update(Duration const& dt) override;
|
||||
virtual void Update(Duration dt) override;
|
||||
|
||||
virtual void Init(
|
||||
ScenePtr const& prev,
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ namespace easy2d
|
|||
E2D_DECLARE_SMART_PTR(GeometryNode);
|
||||
|
||||
E2D_DECLARE_SMART_PTR(Action);
|
||||
E2D_DECLARE_SMART_PTR(Tween);
|
||||
E2D_DECLARE_SMART_PTR(ActionTween);
|
||||
E2D_DECLARE_SMART_PTR(MoveBy);
|
||||
E2D_DECLARE_SMART_PTR(MoveTo);
|
||||
E2D_DECLARE_SMART_PTR(JumpBy);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
return TimePoint{ (dur + dur).Milliseconds() };
|
||||
|
|
@ -100,7 +90,7 @@ namespace easy2d
|
|||
// Duration
|
||||
//-------------------------------------------------------
|
||||
|
||||
const Duration Millisecond = Duration{ 1LL };
|
||||
const Duration Millisecond = 1L;
|
||||
const Duration Second = 1000 * Millisecond;
|
||||
const Duration Minute = 60 * Second;
|
||||
const Duration Hour = 60 * Minute;
|
||||
|
|
|
|||
|
|
@ -36,9 +36,8 @@ namespace easy2d
|
|||
// 1.5 小时: 1.5_h
|
||||
// 3 小时 45 分 15 秒: 3_h + 45_m + 15_s
|
||||
//
|
||||
class Duration
|
||||
struct Duration
|
||||
{
|
||||
public:
|
||||
Duration();
|
||||
|
||||
Duration(
|
||||
|
|
@ -122,22 +121,11 @@ namespace easy2d
|
|||
// TimePoint t1, t2;
|
||||
// int ms = (t2 - t1).Milliseconds(); // 获取两时间相差的毫秒数
|
||||
//
|
||||
class TimePoint
|
||||
struct TimePoint
|
||||
{
|
||||
public:
|
||||
TimePoint();
|
||||
|
||||
TimePoint(
|
||||
long
|
||||
);
|
||||
|
||||
TimePoint(
|
||||
const TimePoint& other
|
||||
);
|
||||
|
||||
TimePoint(
|
||||
TimePoint&& other
|
||||
);
|
||||
TimePoint(long);
|
||||
|
||||
// 是否是零时
|
||||
inline bool IsZero() const { return dur == 0; }
|
||||
|
|
|
|||
|
|
@ -58,8 +58,9 @@
|
|||
#include "core/Task.h"
|
||||
#include "core/TaskManager.h"
|
||||
#include "core/Action.hpp"
|
||||
#include "core/ActionCombined.h"
|
||||
#include "core/ActionGroup.h"
|
||||
#include "core/ActionTween.h"
|
||||
#include "core/ActionHelper.h"
|
||||
#include "core/Animation.h"
|
||||
#include "core/Delay.h"
|
||||
#include "core/ActionManager.h"
|
||||
|
|
|
|||
Loading…
Reference in New Issue