add: TweenAction
refactoring TweenAction(s) & remove CallFunc & rename Animation to Frames
This commit is contained in:
parent
ab2c6092e8
commit
00ee7002f3
|
|
@ -53,9 +53,7 @@ namespace easy2d
|
||||||
virtual void Pause() { running_ = false; }
|
virtual void Pause() { running_ = false; }
|
||||||
|
|
||||||
// 停止动作
|
// 停止动作
|
||||||
virtual void Stop() { done_ = true; }
|
virtual void Stop() { if (!done_) { done_ = true; cb_(); } }
|
||||||
|
|
||||||
virtual bool IsDone() const { return done_; }
|
|
||||||
|
|
||||||
// 获取动作的拷贝
|
// 获取动作的拷贝
|
||||||
virtual spAction Clone() const = 0;
|
virtual spAction Clone() const = 0;
|
||||||
|
|
@ -70,6 +68,11 @@ namespace easy2d
|
||||||
done_ = false;
|
done_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 设置动作结束时的回调函数
|
||||||
|
void SetCallback(std::function<void()> cb) { cb_ = cb; }
|
||||||
|
|
||||||
|
virtual bool IsDone() const { return done_; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Start()
|
virtual void Start()
|
||||||
{
|
{
|
||||||
|
|
@ -91,5 +94,6 @@ namespace easy2d
|
||||||
bool running_;
|
bool running_;
|
||||||
bool done_;
|
bool done_;
|
||||||
bool initialized_;
|
bool initialized_;
|
||||||
|
std::function<void()> cb_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,54 +18,125 @@
|
||||||
// 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 "ActionInterval.h"
|
#include "ActionTween.h"
|
||||||
#include "Geometry.h"
|
#include "Geometry.h"
|
||||||
#include "base.hpp"
|
#include "base.hpp"
|
||||||
#include "Node.h"
|
#include "Node.h"
|
||||||
|
#include "../math/ease.hpp"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cfloat>
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
// IntervalAction
|
// Tween
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
IntervalAction::IntervalAction(Duration const& duration)
|
Tween::Tween()
|
||||||
: process_(0)
|
: elapsed_()
|
||||||
, duration_(duration)
|
, duration_()
|
||||||
|
, ease_func_(math::Linear)
|
||||||
|
, ease_type_(EaseFunc::Linear)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntervalAction::Reset()
|
Tween::Tween(Duration const& duration, EaseFunc func)
|
||||||
|
: elapsed_()
|
||||||
|
, ease_func_(math::Linear)
|
||||||
|
, ease_type_(EaseFunc::Linear)
|
||||||
|
{
|
||||||
|
SetDuration(duration);
|
||||||
|
SetEaseFunction(func);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Tween::SetEaseFunction(EaseFunc func)
|
||||||
|
{
|
||||||
|
ease_type_ = func;
|
||||||
|
switch (func)
|
||||||
|
{
|
||||||
|
case EaseFunc::Linear:
|
||||||
|
ease_func_ = math::Linear;
|
||||||
|
break;
|
||||||
|
case EaseFunc::EaseIn:
|
||||||
|
ease_func_ = std::bind(math::EaseIn, std::placeholders::_1, 2.f);
|
||||||
|
break;
|
||||||
|
case EaseFunc::EaseOut:
|
||||||
|
ease_func_ = std::bind(math::EaseOut, std::placeholders::_1, 2.f);
|
||||||
|
break;
|
||||||
|
case EaseFunc::EaseInOut:
|
||||||
|
ease_func_ = std::bind(math::EaseInOut, std::placeholders::_1, 2.f);
|
||||||
|
break;
|
||||||
|
case EaseFunc::EaseExponentialIn:
|
||||||
|
ease_func_ = math::EaseExponentialIn;
|
||||||
|
break;
|
||||||
|
case EaseFunc::EaseExponentialOut:
|
||||||
|
ease_func_ = math::EaseExponentialOut;
|
||||||
|
break;
|
||||||
|
case EaseFunc::EaseExponentialInOut:
|
||||||
|
ease_func_ = math::EaseExponentialInOut;
|
||||||
|
break;
|
||||||
|
case EaseFunc::EaseSineIn:
|
||||||
|
ease_func_ = math::EaseSineIn;
|
||||||
|
break;
|
||||||
|
case EaseFunc::EaseSineOut:
|
||||||
|
ease_func_ = math::EaseSineOut;
|
||||||
|
break;
|
||||||
|
case EaseFunc::EaseSineInOut:
|
||||||
|
ease_func_ = math::EaseSineInOut;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Tween::SetEaseFunction(std::function<float(float)> func)
|
||||||
|
{
|
||||||
|
ease_func_ = func;
|
||||||
|
ease_type_ = EaseFunc(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Tween::Reset()
|
||||||
{
|
{
|
||||||
Action::Reset();
|
Action::Reset();
|
||||||
process_ = 0;
|
elapsed_ = Duration{};
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntervalAction::Init(Node* target)
|
Duration const & Tween::GetDuration() const
|
||||||
|
{
|
||||||
|
return duration_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Tween::Init(Node* target)
|
||||||
{
|
{
|
||||||
Action::Init(target);
|
Action::Init(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntervalAction::Update(Node* target, Duration const& dt)
|
void Tween::Update(Node* target, Duration const& dt)
|
||||||
{
|
{
|
||||||
Action::Update(target, dt);
|
Action::Update(target, dt);
|
||||||
|
|
||||||
|
float step;
|
||||||
if (duration_.IsZero())
|
if (duration_.IsZero())
|
||||||
{
|
{
|
||||||
process_ = 1.f;
|
step = 1.f;
|
||||||
this->Stop();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
process_ += dt / duration_;
|
elapsed_ += dt;
|
||||||
process_ = std::min(process_, 1.f);
|
step = std::min(elapsed_ / duration_, 1.f);
|
||||||
|
|
||||||
if (process_ >= 1)
|
|
||||||
{
|
|
||||||
this->Stop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((1.f - step) <= FLT_EPSILON)
|
||||||
|
{
|
||||||
|
this->Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateStep(target, ease_func_(step));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Tween::SetDuration(Duration const & duration)
|
||||||
|
{
|
||||||
|
duration_ = duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -73,15 +144,15 @@ namespace easy2d
|
||||||
// Move Action
|
// Move Action
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
MoveBy::MoveBy(Duration const& duration, Point const& vector)
|
MoveBy::MoveBy(Duration const& duration, Point const& vector, EaseFunc func)
|
||||||
: IntervalAction(duration)
|
: Tween(duration, func)
|
||||||
{
|
{
|
||||||
delta_pos_ = vector;
|
delta_pos_ = vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveBy::Init(Node* target)
|
void MoveBy::Init(Node* target)
|
||||||
{
|
{
|
||||||
IntervalAction::Init(target);
|
Tween::Init(target);
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
|
|
@ -89,16 +160,14 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveBy::Update(Node* target, Duration const& dt)
|
void MoveBy::UpdateStep(Node* target, float step)
|
||||||
{
|
{
|
||||||
IntervalAction::Update(target, dt);
|
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
Point diff = target->GetPosition() - prev_pos_;
|
Point diff = target->GetPosition() - prev_pos_;
|
||||||
start_pos_ = start_pos_ + diff;
|
start_pos_ = start_pos_ + diff;
|
||||||
|
|
||||||
Point new_pos = start_pos_ + (delta_pos_ * process_);
|
Point new_pos = start_pos_ + (delta_pos_ * step);
|
||||||
target->SetPosition(new_pos);
|
target->SetPosition(new_pos);
|
||||||
|
|
||||||
prev_pos_ = new_pos;
|
prev_pos_ = new_pos;
|
||||||
|
|
@ -107,23 +176,23 @@ namespace easy2d
|
||||||
|
|
||||||
spAction MoveBy::Clone() const
|
spAction MoveBy::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) MoveBy(duration_, delta_pos_);
|
return new (std::nothrow) MoveBy(duration_, delta_pos_, ease_type_);
|
||||||
}
|
}
|
||||||
|
|
||||||
spAction MoveBy::Reverse() const
|
spAction MoveBy::Reverse() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) MoveBy(duration_, -delta_pos_);
|
return new (std::nothrow) MoveBy(duration_, -delta_pos_, ease_type_);
|
||||||
}
|
}
|
||||||
|
|
||||||
MoveTo::MoveTo(Duration const& duration, Point const& pos)
|
MoveTo::MoveTo(Duration const& duration, Point const& pos, EaseFunc func)
|
||||||
: MoveBy(duration, Point())
|
: MoveBy(duration, Point(), func)
|
||||||
{
|
{
|
||||||
end_pos_ = pos;
|
end_pos_ = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
spAction MoveTo::Clone() const
|
spAction MoveTo::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) MoveTo(duration_, end_pos_);
|
return new (std::nothrow) MoveTo(duration_, end_pos_, ease_type_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveTo::Init(Node* target)
|
void MoveTo::Init(Node* target)
|
||||||
|
|
@ -137,8 +206,8 @@ namespace easy2d
|
||||||
// Jump Action
|
// Jump Action
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
JumpBy::JumpBy(Duration const& duration, Point const& vec, float height, int jumps)
|
JumpBy::JumpBy(Duration const& duration, Point const& vec, float height, int jumps, EaseFunc func)
|
||||||
: IntervalAction(duration)
|
: Tween(duration, func)
|
||||||
, delta_pos_(vec)
|
, delta_pos_(vec)
|
||||||
, height_(height)
|
, height_(height)
|
||||||
, jumps_(jumps)
|
, jumps_(jumps)
|
||||||
|
|
@ -147,17 +216,17 @@ namespace easy2d
|
||||||
|
|
||||||
spAction JumpBy::Clone() const
|
spAction JumpBy::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) JumpBy(duration_, delta_pos_, height_, jumps_);
|
return new (std::nothrow) JumpBy(duration_, delta_pos_, height_, jumps_, ease_type_);
|
||||||
}
|
}
|
||||||
|
|
||||||
spAction JumpBy::Reverse() const
|
spAction JumpBy::Reverse() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) JumpBy(duration_, -delta_pos_, height_, jumps_);
|
return new (std::nothrow) JumpBy(duration_, -delta_pos_, height_, jumps_, ease_type_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JumpBy::Init(Node* target)
|
void JumpBy::Init(Node* target)
|
||||||
{
|
{
|
||||||
IntervalAction::Init(target);
|
Tween::Init(target);
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
|
|
@ -165,16 +234,14 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void JumpBy::Update(Node* target, Duration const& dt)
|
void JumpBy::UpdateStep(Node* target, float step)
|
||||||
{
|
{
|
||||||
IntervalAction::Update(target, dt);
|
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
float frac = fmod(process_ * jumps_, 1.f);
|
float frac = fmod(step * jumps_, 1.f);
|
||||||
float x = delta_pos_.x * process_;
|
float x = delta_pos_.x * step;
|
||||||
float y = height_ * 4 * frac * (1 - frac);
|
float y = height_ * 4 * frac * (1 - frac);
|
||||||
y += delta_pos_.y * process_;
|
y += delta_pos_.y * step;
|
||||||
|
|
||||||
Point diff = target->GetPosition() - prev_pos_;
|
Point diff = target->GetPosition() - prev_pos_;
|
||||||
start_pos_ = diff + start_pos_;
|
start_pos_ = diff + start_pos_;
|
||||||
|
|
@ -186,15 +253,15 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JumpTo::JumpTo(Duration const& duration, Point const& pos, float height, int jumps)
|
JumpTo::JumpTo(Duration const& duration, Point const& pos, float height, int jumps, EaseFunc func)
|
||||||
: JumpBy(duration, Point(), height, jumps)
|
: JumpBy(duration, Point(), height, jumps, func)
|
||||||
, end_pos_(pos)
|
, end_pos_(pos)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
spAction JumpTo::Clone() const
|
spAction JumpTo::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) JumpTo(duration_, end_pos_, height_, jumps_);
|
return new (std::nothrow) JumpTo(duration_, end_pos_, height_, jumps_, ease_type_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JumpTo::Init(Node* target)
|
void JumpTo::Init(Node* target)
|
||||||
|
|
@ -208,15 +275,15 @@ namespace easy2d
|
||||||
// Scale Action
|
// Scale Action
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
ScaleBy::ScaleBy(Duration const& duration, float scale)
|
ScaleBy::ScaleBy(Duration const& duration, float scale, EaseFunc func)
|
||||||
: IntervalAction(duration)
|
: Tween(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)
|
ScaleBy::ScaleBy(Duration const& duration, float scale_x, float scale_y, EaseFunc func)
|
||||||
: IntervalAction(duration)
|
: Tween(duration, func)
|
||||||
{
|
{
|
||||||
delta_x_ = scale_x;
|
delta_x_ = scale_x;
|
||||||
delta_y_ = scale_y;
|
delta_y_ = scale_y;
|
||||||
|
|
@ -224,7 +291,7 @@ namespace easy2d
|
||||||
|
|
||||||
void ScaleBy::Init(Node* target)
|
void ScaleBy::Init(Node* target)
|
||||||
{
|
{
|
||||||
IntervalAction::Init(target);
|
Tween::Init(target);
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
|
|
@ -233,35 +300,33 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScaleBy::Update(Node* target, Duration const& dt)
|
void ScaleBy::UpdateStep(Node* target, float step)
|
||||||
{
|
{
|
||||||
IntervalAction::Update(target, dt);
|
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
target->SetScale(start_scale_x_ + delta_x_ * process_, start_scale_y_ + delta_y_ * process_);
|
target->SetScale(start_scale_x_ + delta_x_ * step, start_scale_y_ + delta_y_ * step);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spAction ScaleBy::Clone() const
|
spAction ScaleBy::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) ScaleBy(duration_, delta_x_, delta_y_);
|
return new (std::nothrow) ScaleBy(duration_, delta_x_, delta_y_, ease_type_);
|
||||||
}
|
}
|
||||||
|
|
||||||
spAction ScaleBy::Reverse() const
|
spAction ScaleBy::Reverse() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) ScaleBy(duration_, -delta_x_, -delta_y_);
|
return new (std::nothrow) ScaleBy(duration_, -delta_x_, -delta_y_, ease_type_);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScaleTo::ScaleTo(Duration const& duration, float scale)
|
ScaleTo::ScaleTo(Duration const& duration, float scale, EaseFunc func)
|
||||||
: ScaleBy(duration, 0, 0)
|
: 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)
|
ScaleTo::ScaleTo(Duration const& duration, float scale_x, float scale_y, EaseFunc func)
|
||||||
: ScaleBy(duration, 0, 0)
|
: ScaleBy(duration, 0, 0, func)
|
||||||
{
|
{
|
||||||
end_scale_x_ = scale_x;
|
end_scale_x_ = scale_x;
|
||||||
end_scale_y_ = scale_y;
|
end_scale_y_ = scale_y;
|
||||||
|
|
@ -269,7 +334,7 @@ namespace easy2d
|
||||||
|
|
||||||
spAction ScaleTo::Clone() const
|
spAction ScaleTo::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) ScaleTo(duration_, end_scale_x_, end_scale_y_);
|
return new (std::nothrow) ScaleTo(duration_, end_scale_x_, end_scale_y_, ease_type_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScaleTo::Init(Node* target)
|
void ScaleTo::Init(Node* target)
|
||||||
|
|
@ -284,15 +349,15 @@ namespace easy2d
|
||||||
// Opacity Action
|
// Opacity Action
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
OpacityBy::OpacityBy(Duration const& duration, float opacity)
|
OpacityBy::OpacityBy(Duration const& duration, float opacity, EaseFunc func)
|
||||||
: IntervalAction(duration)
|
: Tween(duration, func)
|
||||||
{
|
{
|
||||||
delta_val_ = opacity;
|
delta_val_ = opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpacityBy::Init(Node* target)
|
void OpacityBy::Init(Node* target)
|
||||||
{
|
{
|
||||||
IntervalAction::Init(target);
|
Tween::Init(target);
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
|
|
@ -300,35 +365,33 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpacityBy::Update(Node* target, Duration const& dt)
|
void OpacityBy::UpdateStep(Node* target, float step)
|
||||||
{
|
{
|
||||||
IntervalAction::Update(target, dt);
|
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
target->SetOpacity(start_val_ + delta_val_ * process_);
|
target->SetOpacity(start_val_ + delta_val_ * step);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spAction OpacityBy::Clone() const
|
spAction OpacityBy::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) OpacityBy(duration_, delta_val_);
|
return new (std::nothrow) OpacityBy(duration_, delta_val_, ease_type_);
|
||||||
}
|
}
|
||||||
|
|
||||||
spAction OpacityBy::Reverse() const
|
spAction OpacityBy::Reverse() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) OpacityBy(duration_, -delta_val_);
|
return new (std::nothrow) OpacityBy(duration_, -delta_val_, ease_type_);
|
||||||
}
|
}
|
||||||
|
|
||||||
OpacityTo::OpacityTo(Duration const& duration, float opacity)
|
OpacityTo::OpacityTo(Duration const& duration, float opacity, EaseFunc func)
|
||||||
: OpacityBy(duration, 0)
|
: OpacityBy(duration, 0, func)
|
||||||
{
|
{
|
||||||
end_val_ = opacity;
|
end_val_ = opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
spAction OpacityTo::Clone() const
|
spAction OpacityTo::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) OpacityTo(duration_, end_val_);
|
return new (std::nothrow) OpacityTo(duration_, end_val_, ease_type_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpacityTo::Init(Node* target)
|
void OpacityTo::Init(Node* target)
|
||||||
|
|
@ -337,13 +400,13 @@ namespace easy2d
|
||||||
delta_val_ = end_val_ - start_val_;
|
delta_val_ = end_val_ - start_val_;
|
||||||
}
|
}
|
||||||
|
|
||||||
FadeIn::FadeIn(Duration const& duration)
|
FadeIn::FadeIn(Duration const& duration, EaseFunc func)
|
||||||
: OpacityTo(duration, 1)
|
: OpacityTo(duration, 1, func)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FadeOut::FadeOut(Duration const& duration)
|
FadeOut::FadeOut(Duration const& duration, EaseFunc func)
|
||||||
: OpacityTo(duration, 0)
|
: OpacityTo(duration, 0, func)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -352,15 +415,15 @@ namespace easy2d
|
||||||
// Rotate Action
|
// Rotate Action
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
RotateBy::RotateBy(Duration const& duration, float rotation)
|
RotateBy::RotateBy(Duration const& duration, float rotation, EaseFunc func)
|
||||||
: IntervalAction(duration)
|
: Tween(duration, func)
|
||||||
, delta_val_(rotation)
|
, delta_val_(rotation)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void RotateBy::Init(Node* target)
|
void RotateBy::Init(Node* target)
|
||||||
{
|
{
|
||||||
IntervalAction::Init(target);
|
Tween::Init(target);
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
|
|
@ -368,35 +431,33 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RotateBy::Update(Node* target, Duration const& dt)
|
void RotateBy::UpdateStep(Node* target, float step)
|
||||||
{
|
{
|
||||||
IntervalAction::Update(target, dt);
|
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
target->SetRotation(start_val_ + delta_val_ * process_);
|
target->SetRotation(start_val_ + delta_val_ * step);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spAction RotateBy::Clone() const
|
spAction RotateBy::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) RotateBy(duration_, delta_val_);
|
return new (std::nothrow) RotateBy(duration_, delta_val_, ease_type_);
|
||||||
}
|
}
|
||||||
|
|
||||||
spAction RotateBy::Reverse() const
|
spAction RotateBy::Reverse() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) RotateBy(duration_, -delta_val_);
|
return new (std::nothrow) RotateBy(duration_, -delta_val_, ease_type_);
|
||||||
}
|
}
|
||||||
|
|
||||||
RotateTo::RotateTo(Duration const& duration, float rotation)
|
RotateTo::RotateTo(Duration const& duration, float rotation, EaseFunc func)
|
||||||
: RotateBy(duration, 0)
|
: RotateBy(duration, 0, func)
|
||||||
{
|
{
|
||||||
end_val_ = rotation;
|
end_val_ = rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
spAction RotateTo::Clone() const
|
spAction RotateTo::Clone() const
|
||||||
{
|
{
|
||||||
return new (std::nothrow) RotateTo(duration_, end_val_);
|
return new (std::nothrow) RotateTo(duration_, end_val_, ease_type_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RotateTo::Init(Node* target)
|
void RotateTo::Init(Node* target)
|
||||||
|
|
@ -410,8 +471,8 @@ namespace easy2d
|
||||||
// PathAction
|
// PathAction
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
PathAction::PathAction(Duration const & duration, spGeometry const& geo, bool rotating, float start, float end)
|
PathAction::PathAction(Duration const & duration, spGeometry const& geo, bool rotating, float start, float end, EaseFunc func)
|
||||||
: IntervalAction(duration)
|
: Tween(duration, func)
|
||||||
, start_(start)
|
, start_(start)
|
||||||
, end_(end)
|
, end_(end)
|
||||||
, geo_(geo)
|
, geo_(geo)
|
||||||
|
|
@ -421,22 +482,20 @@ namespace easy2d
|
||||||
|
|
||||||
spAction PathAction::Clone() const
|
spAction PathAction::Clone() const
|
||||||
{
|
{
|
||||||
return new PathAction(duration_, geo_, rotating_, start_, end_);
|
return new PathAction(duration_, geo_, rotating_, start_, end_, ease_type_);
|
||||||
}
|
}
|
||||||
|
|
||||||
spAction PathAction::Reverse() const
|
spAction PathAction::Reverse() const
|
||||||
{
|
{
|
||||||
return new PathAction(duration_, geo_, rotating_, end_, start_);
|
return new PathAction(duration_, geo_, rotating_, end_, start_, ease_type_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathAction::Update(Node * target, Duration const & dt)
|
void PathAction::UpdateStep(Node* target, float step)
|
||||||
{
|
{
|
||||||
IntervalAction::Update(target, dt);
|
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
float percent = std::min(std::max((end_ - start_) * process_ + start_, 0.f), 1.f);
|
float length = geo_->GetLength() * std::min(std::max((end_ - start_) * step + start_, 0.f), 1.f);
|
||||||
float length = geo_->GetLength() * percent;
|
|
||||||
Point point, tangent;
|
Point point, tangent;
|
||||||
if (geo_->ComputePointAt(length, &point, &tangent))
|
if (geo_->ComputePointAt(length, &point, &tangent))
|
||||||
{
|
{
|
||||||
|
|
@ -452,48 +511,4 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------
|
|
||||||
// Delay
|
|
||||||
//-------------------------------------------------------
|
|
||||||
|
|
||||||
Delay::Delay(Duration const& duration)
|
|
||||||
: delta_()
|
|
||||||
, delay_(duration)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Delay::Reset()
|
|
||||||
{
|
|
||||||
Action::Reset();
|
|
||||||
delta_ = Duration{};
|
|
||||||
}
|
|
||||||
|
|
||||||
void Delay::Init(Node* target)
|
|
||||||
{
|
|
||||||
Action::Init(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Delay::Update(Node* target, Duration const& dt)
|
|
||||||
{
|
|
||||||
Action::Update(target, dt);
|
|
||||||
|
|
||||||
delta_ += dt;
|
|
||||||
|
|
||||||
if (delta_ >= delay_)
|
|
||||||
{
|
|
||||||
this->Stop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
spAction Delay::Clone() const
|
|
||||||
{
|
|
||||||
return new (std::nothrow) Delay(delay_);
|
|
||||||
}
|
|
||||||
|
|
||||||
spAction Delay::Reverse() const
|
|
||||||
{
|
|
||||||
return new (std::nothrow) Delay(delay_);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -24,35 +24,71 @@
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
class IntervalAction
|
enum class EaseFunc
|
||||||
|
{
|
||||||
|
Linear, // 线性
|
||||||
|
EaseIn, // 由慢变快
|
||||||
|
EaseOut, // 由快变慢
|
||||||
|
EaseInOut, // 由慢变快, 再由快变慢
|
||||||
|
EaseExponentialIn, // 由慢变极快
|
||||||
|
EaseExponentialOut, // 由极快变慢
|
||||||
|
EaseExponentialInOut, // 由慢至极快, 再由极快边慢
|
||||||
|
EaseSineIn, // 由快变慢, 采用正弦变换速度
|
||||||
|
EaseSineOut, // 由慢变快, 采用正弦变换速度
|
||||||
|
EaseSineInOut // 由慢至快, 再由快至慢, 采用正弦变换速度
|
||||||
|
};
|
||||||
|
|
||||||
|
class Tween
|
||||||
: public Action
|
: public Action
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit IntervalAction(
|
Tween();
|
||||||
Duration const& duration
|
|
||||||
|
explicit Tween(
|
||||||
|
Duration const& duration,
|
||||||
|
EaseFunc func
|
||||||
|
);
|
||||||
|
|
||||||
|
// 设置速度变化曲线
|
||||||
|
void SetEaseFunction(
|
||||||
|
EaseFunc func
|
||||||
|
);
|
||||||
|
|
||||||
|
// 自定义速度变化曲线
|
||||||
|
void SetEaseFunction(
|
||||||
|
std::function<float(float)> func
|
||||||
);
|
);
|
||||||
|
|
||||||
virtual void Reset() override;
|
virtual void Reset() override;
|
||||||
|
|
||||||
|
Duration const& GetDuration() const;
|
||||||
|
|
||||||
|
void SetDuration(Duration const& 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 const& dt) override;
|
||||||
|
|
||||||
|
virtual void UpdateStep(Node* target, float step) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Duration duration_;
|
Duration duration_;
|
||||||
float process_;
|
Duration elapsed_;
|
||||||
|
EaseFunc ease_type_;
|
||||||
|
std::function<float(float)> ease_func_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 相对位移动作
|
// 相对位移动作
|
||||||
class MoveBy
|
class MoveBy
|
||||||
: public IntervalAction
|
: public Tween
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit MoveBy(
|
explicit MoveBy(
|
||||||
Duration const& duration, /* 持续时长 */
|
Duration const& duration, /* 持续时长 */
|
||||||
Point const& vector /* 移动距离 */
|
Point const& vector, /* 移动距离 */
|
||||||
|
EaseFunc func = EaseFunc::Linear /* 速度变化 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取该动作的拷贝对象
|
// 获取该动作的拷贝对象
|
||||||
|
|
@ -64,7 +100,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 UpdateStep(Node* target, float step) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Point start_pos_;
|
Point start_pos_;
|
||||||
|
|
@ -79,8 +115,9 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit MoveTo(
|
explicit MoveTo(
|
||||||
Duration const& duration, /* 持续时长 */
|
Duration const& duration, /* 持续时长 */
|
||||||
Point const& pos /* 目的坐标 */
|
Point const& pos, /* 目的坐标 */
|
||||||
|
EaseFunc func = EaseFunc::Linear /* 速度变化 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取该动作的拷贝对象
|
// 获取该动作的拷贝对象
|
||||||
|
|
@ -103,14 +140,15 @@ namespace easy2d
|
||||||
|
|
||||||
// 相对跳跃动作
|
// 相对跳跃动作
|
||||||
class JumpBy
|
class JumpBy
|
||||||
: public IntervalAction
|
: public Tween
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit JumpBy(
|
explicit JumpBy(
|
||||||
Duration const& duration, /* 持续时长 */
|
Duration const& duration, /* 持续时长 */
|
||||||
Point const& vec, /* 跳跃距离 */
|
Point const& vec, /* 跳跃距离 */
|
||||||
float height, /* 跳跃高度 */
|
float height, /* 跳跃高度 */
|
||||||
int jumps = 1 /* 跳跃次数 */
|
int jumps = 1, /* 跳跃次数 */
|
||||||
|
EaseFunc func = EaseFunc::Linear /* 速度变化 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取该动作的拷贝对象
|
// 获取该动作的拷贝对象
|
||||||
|
|
@ -122,7 +160,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 UpdateStep(Node* target, float step) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Point start_pos_;
|
Point start_pos_;
|
||||||
|
|
@ -139,10 +177,11 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit JumpTo(
|
explicit JumpTo(
|
||||||
Duration const& duration, /* 持续时长 */
|
Duration const& duration, /* 持续时长 */
|
||||||
Point const& pos, /* 目的坐标 */
|
Point const& pos, /* 目的坐标 */
|
||||||
float height, /* 跳跃高度 */
|
float height, /* 跳跃高度 */
|
||||||
int jumps = 1 /* 跳跃次数 */
|
int jumps = 1, /* 跳跃次数 */
|
||||||
|
EaseFunc func = EaseFunc::Linear /* 速度变化 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取该动作的拷贝对象
|
// 获取该动作的拷贝对象
|
||||||
|
|
@ -165,18 +204,20 @@ namespace easy2d
|
||||||
|
|
||||||
// 相对缩放动作
|
// 相对缩放动作
|
||||||
class ScaleBy
|
class ScaleBy
|
||||||
: public IntervalAction
|
: public Tween
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ScaleBy(
|
explicit ScaleBy(
|
||||||
Duration const& duration, /* 持续时长 */
|
Duration const& duration, /* 持续时长 */
|
||||||
float scale /* 相对变化值 */
|
float scale, /* 相对变化值 */
|
||||||
|
EaseFunc func = EaseFunc::Linear /* 速度变化 */
|
||||||
);
|
);
|
||||||
|
|
||||||
explicit ScaleBy(
|
explicit ScaleBy(
|
||||||
Duration const& duration, /* 持续时长 */
|
Duration const& duration, /* 持续时长 */
|
||||||
float scale_x, /* 横向缩放相对变化值 */
|
float scale_x, /* 横向缩放相对变化值 */
|
||||||
float scale_y /* 纵向缩放相对变化值 */
|
float scale_y, /* 纵向缩放相对变化值 */
|
||||||
|
EaseFunc func = EaseFunc::Linear /* 速度变化 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取该动作的拷贝对象
|
// 获取该动作的拷贝对象
|
||||||
|
|
@ -188,7 +229,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 UpdateStep(Node* target, float step) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
float start_scale_x_;
|
float start_scale_x_;
|
||||||
|
|
@ -204,14 +245,16 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ScaleTo(
|
explicit ScaleTo(
|
||||||
Duration const& duration, /* 持续时长 */
|
Duration const& duration, /* 持续时长 */
|
||||||
float scale /* 目标值 */
|
float scale, /* 目标值 */
|
||||||
|
EaseFunc func = EaseFunc::Linear /* 速度变化 */
|
||||||
);
|
);
|
||||||
|
|
||||||
explicit ScaleTo(
|
explicit ScaleTo(
|
||||||
Duration const& duration, /* 持续时长 */
|
Duration const& duration, /* 持续时长 */
|
||||||
float scale_x, /* 横向缩放目标值 */
|
float scale_x, /* 横向缩放目标值 */
|
||||||
float scale_y /* 纵向缩放目标值 */
|
float scale_y, /* 纵向缩放目标值 */
|
||||||
|
EaseFunc func = EaseFunc::Linear /* 速度变化 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取该动作的拷贝对象
|
// 获取该动作的拷贝对象
|
||||||
|
|
@ -235,12 +278,13 @@ namespace easy2d
|
||||||
|
|
||||||
// 透明度相对渐变动作
|
// 透明度相对渐变动作
|
||||||
class OpacityBy
|
class OpacityBy
|
||||||
: public IntervalAction
|
: public Tween
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit OpacityBy(
|
explicit OpacityBy(
|
||||||
Duration const& duration, /* 持续时长 */
|
Duration const& duration, /* 持续时长 */
|
||||||
float opacity /* 相对变化值 */
|
float opacity, /* 相对变化值 */
|
||||||
|
EaseFunc func = EaseFunc::Linear /* 速度变化 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取该动作的拷贝对象
|
// 获取该动作的拷贝对象
|
||||||
|
|
@ -252,7 +296,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 UpdateStep(Node* target, float step) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
float start_val_;
|
float start_val_;
|
||||||
|
|
@ -266,8 +310,9 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit OpacityTo(
|
explicit OpacityTo(
|
||||||
Duration const& duration, /* 持续时长 */
|
Duration const& duration, /* 持续时长 */
|
||||||
float opacity /* 目标值 */
|
float opacity, /* 目标值 */
|
||||||
|
EaseFunc func = EaseFunc::Linear /* 速度变化 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取该动作的拷贝对象
|
// 获取该动作的拷贝对象
|
||||||
|
|
@ -295,7 +340,8 @@ namespace easy2d
|
||||||
public:
|
public:
|
||||||
// 创建淡入动作
|
// 创建淡入动作
|
||||||
explicit FadeIn(
|
explicit FadeIn(
|
||||||
Duration const& duration /* 持续时长 */
|
Duration const& duration, /* 持续时长 */
|
||||||
|
EaseFunc func = EaseFunc::Linear /* 速度变化 */
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -307,19 +353,21 @@ namespace easy2d
|
||||||
public:
|
public:
|
||||||
// 创建淡出动作
|
// 创建淡出动作
|
||||||
explicit FadeOut(
|
explicit FadeOut(
|
||||||
Duration const& duration /* 持续时长 */
|
Duration const& duration, /* 持续时长 */
|
||||||
|
EaseFunc func = EaseFunc::Linear /* 速度变化 */
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 相对旋转动作
|
// 相对旋转动作
|
||||||
class RotateBy
|
class RotateBy
|
||||||
: public IntervalAction
|
: public Tween
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit RotateBy(
|
explicit RotateBy(
|
||||||
Duration const& duration, /* 持续时长 */
|
Duration const& duration, /* 持续时长 */
|
||||||
float rotation /* 相对变化值 */
|
float rotation, /* 相对变化值 */
|
||||||
|
EaseFunc func = EaseFunc::Linear /* 速度变化 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取该动作的拷贝对象
|
// 获取该动作的拷贝对象
|
||||||
|
|
@ -331,7 +379,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 UpdateStep(Node* target, float step) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
float start_val_;
|
float start_val_;
|
||||||
|
|
@ -345,8 +393,9 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit RotateTo(
|
explicit RotateTo(
|
||||||
Duration const& duration, /* 持续时长 */
|
Duration const& duration, /* 持续时长 */
|
||||||
float rotation /* 目标值 */
|
float rotation, /* 目标值 */
|
||||||
|
EaseFunc func = EaseFunc::Linear /* 速度变化 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取该动作的拷贝对象
|
// 获取该动作的拷贝对象
|
||||||
|
|
@ -369,15 +418,16 @@ namespace easy2d
|
||||||
|
|
||||||
// 路径动作
|
// 路径动作
|
||||||
class PathAction
|
class PathAction
|
||||||
: public IntervalAction
|
: public Tween
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit PathAction(
|
explicit PathAction(
|
||||||
Duration const& duration, /* 持续时长 */
|
Duration const& duration, /* 持续时长 */
|
||||||
spGeometry const& geo, /* 几何图形 */
|
spGeometry const& geo, /* 几何图形 */
|
||||||
bool rotating = false, /* 沿路径切线方向旋转 */
|
bool rotating = false, /* 沿路径切线方向旋转 */
|
||||||
float start = 0.f, /* 起点 */
|
float start = 0.f, /* 起点 */
|
||||||
float end = 1.f /* 终点 */
|
float end = 1.f, /* 终点 */
|
||||||
|
EaseFunc func = EaseFunc::Linear /* 速度变化 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取该动作的拷贝对象
|
// 获取该动作的拷贝对象
|
||||||
|
|
@ -387,7 +437,7 @@ namespace easy2d
|
||||||
virtual spAction Reverse() const override;
|
virtual spAction Reverse() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Update(Node* target, Duration const& dt) override;
|
virtual void UpdateStep(Node* target, float step) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool rotating_;
|
bool rotating_;
|
||||||
|
|
@ -395,33 +445,4 @@ namespace easy2d
|
||||||
float end_;
|
float end_;
|
||||||
spGeometry geo_;
|
spGeometry geo_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 延时动作
|
|
||||||
class Delay
|
|
||||||
: public Action
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit Delay(
|
|
||||||
Duration const& duration /* 延迟时长(秒) */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 获取该动作的拷贝对象
|
|
||||||
virtual spAction Clone() const override;
|
|
||||||
|
|
||||||
// 获取该动作的倒转
|
|
||||||
virtual spAction Reverse() const override;
|
|
||||||
|
|
||||||
// 重置动作
|
|
||||||
virtual void Reset() override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void Init(Node* target) override;
|
|
||||||
|
|
||||||
virtual void Update(Node* target, Duration const& dt) override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
Duration delay_;
|
|
||||||
Duration delta_;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
@ -19,73 +19,69 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#include "Animation.h"
|
#include "Animation.h"
|
||||||
|
#include "Frames.h"
|
||||||
#include "Image.h"
|
#include "Image.h"
|
||||||
#include "Sprite.h"
|
#include "Sprite.h"
|
||||||
#include "logs.h"
|
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
//-------------------------------------------------------
|
Animation::Animation()
|
||||||
// Animate
|
|
||||||
//-------------------------------------------------------
|
|
||||||
|
|
||||||
Animate::Animate()
|
|
||||||
: frame_index_(0)
|
: frame_index_(0)
|
||||||
, animation_(nullptr)
|
, frames_(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Animate::Animate(spAnimation const& animation)
|
Animation::Animation(spFrames const& animation)
|
||||||
: frame_index_(0)
|
: frame_index_(0)
|
||||||
, animation_(nullptr)
|
, frames_(nullptr)
|
||||||
{
|
{
|
||||||
this->SetAnimation(animation);
|
this->SetAnimation(animation);
|
||||||
}
|
}
|
||||||
|
|
||||||
Animate::~Animate()
|
Animation::~Animation()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
spAnimation Animate::GetAnimation() const
|
spFrames Animation::GetAnimation() const
|
||||||
{
|
{
|
||||||
return animation_;
|
return frames_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animate::SetAnimation(spAnimation const& animation)
|
void Animation::SetAnimation(spFrames const& animation)
|
||||||
{
|
{
|
||||||
if (animation && animation != animation_)
|
if (animation && animation != frames_)
|
||||||
{
|
{
|
||||||
animation_ = animation;
|
frames_ = animation;
|
||||||
frame_index_ = 0;
|
frame_index_ = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animate::Init(Node* target)
|
void Animation::Init(Node* target)
|
||||||
{
|
{
|
||||||
Action::Init(target);
|
Action::Init(target);
|
||||||
|
|
||||||
auto sprite_target = dynamic_cast<Sprite*>(target);
|
auto sprite_target = dynamic_cast<Sprite*>(target);
|
||||||
if (sprite_target && animation_)
|
if (sprite_target && frames_)
|
||||||
{
|
{
|
||||||
sprite_target->Load(animation_->GetFrames()[frame_index_]);
|
sprite_target->Load(frames_->GetFrames()[frame_index_]);
|
||||||
++frame_index_;
|
++frame_index_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animate::Update(Node* target, Duration const& dt)
|
void Animation::Update(Node* target, Duration const& dt)
|
||||||
{
|
{
|
||||||
Action::Update(target, dt);
|
Action::Update(target, dt);
|
||||||
|
|
||||||
if (!animation_)
|
if (!frames_)
|
||||||
{
|
{
|
||||||
this->Stop();
|
this->Stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
delta_ += dt;
|
delta_ += dt;
|
||||||
while (delta_ >= animation_->GetInterval())
|
while (delta_ >= frames_->GetInterval())
|
||||||
{
|
{
|
||||||
auto& frames = animation_->GetFrames();
|
auto& frames = frames_->GetFrames();
|
||||||
auto sprite_target = dynamic_cast<Sprite*>(target);
|
auto sprite_target = dynamic_cast<Sprite*>(target);
|
||||||
|
|
||||||
if (sprite_target)
|
if (sprite_target)
|
||||||
|
|
@ -93,7 +89,7 @@ namespace easy2d
|
||||||
sprite_target->Load(frames[frame_index_]);
|
sprite_target->Load(frames[frame_index_]);
|
||||||
}
|
}
|
||||||
|
|
||||||
delta_ -= animation_->GetInterval();
|
delta_ -= frames_->GetInterval();
|
||||||
++frame_index_;
|
++frame_index_;
|
||||||
|
|
||||||
if (frame_index_ == frames.size())
|
if (frame_index_ == frames.size())
|
||||||
|
|
@ -104,123 +100,32 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animate::Reset()
|
void Animation::Reset()
|
||||||
{
|
{
|
||||||
Action::Reset();
|
Action::Reset();
|
||||||
frame_index_ = 0;
|
frame_index_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
spAction Animate::Clone() const
|
spAction Animation::Clone() const
|
||||||
{
|
{
|
||||||
if (animation_)
|
if (frames_)
|
||||||
{
|
{
|
||||||
return new (std::nothrow) Animate(animation_);
|
return new (std::nothrow) Animation(frames_);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
spAction Animate::Reverse() const
|
spAction Animation::Reverse() const
|
||||||
{
|
{
|
||||||
if (animation_)
|
if (frames_)
|
||||||
{
|
{
|
||||||
auto animation = animation_->Reverse();
|
auto animation = frames_->Reverse();
|
||||||
if (animation)
|
if (animation)
|
||||||
{
|
{
|
||||||
return new (std::nothrow) Animate(animation);
|
return new (std::nothrow) Animation(animation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------
|
|
||||||
// Animation
|
|
||||||
//-------------------------------------------------------
|
|
||||||
|
|
||||||
Animation::Animation()
|
|
||||||
: interval_(1)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Animation::Animation(const Images& frames)
|
|
||||||
: interval_(1)
|
|
||||||
{
|
|
||||||
this->Add(frames);
|
|
||||||
}
|
|
||||||
|
|
||||||
Animation::Animation(Duration const& interval)
|
|
||||||
: interval_(interval)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Animation::Animation(Duration const& interval, const Images& frames)
|
|
||||||
: interval_(interval)
|
|
||||||
{
|
|
||||||
this->Add(frames);
|
|
||||||
}
|
|
||||||
|
|
||||||
Animation::~Animation()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Animation::SetInterval(Duration const& interval)
|
|
||||||
{
|
|
||||||
interval_ = interval;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Animation::Add(spImage const& frame)
|
|
||||||
{
|
|
||||||
if (!frame)
|
|
||||||
logs::Warningln("Animation::Add failed, frame is nullptr.");
|
|
||||||
|
|
||||||
if (frame)
|
|
||||||
{
|
|
||||||
frames_.push_back(frame);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Animation::Add(const Images& frames)
|
|
||||||
{
|
|
||||||
for (const auto &image : frames)
|
|
||||||
{
|
|
||||||
this->Add(image);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Duration const& Animation::GetInterval() const
|
|
||||||
{
|
|
||||||
return interval_;
|
|
||||||
}
|
|
||||||
|
|
||||||
Animation::Images const& Animation::GetFrames() const
|
|
||||||
{
|
|
||||||
return frames_;
|
|
||||||
}
|
|
||||||
|
|
||||||
spAnimation Animation::Clone() const
|
|
||||||
{
|
|
||||||
auto animation = new (std::nothrow) Animation(interval_);
|
|
||||||
if (animation)
|
|
||||||
{
|
|
||||||
for (const auto& frame : frames_)
|
|
||||||
{
|
|
||||||
animation->Add(frame);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return animation;
|
|
||||||
}
|
|
||||||
|
|
||||||
spAnimation Animation::Reverse() const
|
|
||||||
{
|
|
||||||
auto animation = new (std::nothrow) Animation(interval_);
|
|
||||||
if (!frames_.empty())
|
|
||||||
{
|
|
||||||
for (auto iter = frames_.crbegin(), crend = frames_.crend(); iter != crend; ++iter)
|
|
||||||
{
|
|
||||||
if (*iter)
|
|
||||||
animation->Add(*iter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return animation;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -25,80 +25,23 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
// 帧动画
|
// 帧动画
|
||||||
class Animation
|
class Animation
|
||||||
: public ObjectBase
|
: public Action
|
||||||
{
|
{
|
||||||
using Images = std::vector< spImage >;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Animation();
|
Animation();
|
||||||
|
|
||||||
explicit Animation(
|
explicit Animation(
|
||||||
const Images& frames /* 关键帧数组 */
|
spFrames const& animation
|
||||||
);
|
|
||||||
|
|
||||||
explicit Animation(
|
|
||||||
Duration const& interval /* 帧间隔(秒) */
|
|
||||||
);
|
|
||||||
|
|
||||||
explicit Animation(
|
|
||||||
Duration const& interval, /* 帧间隔(秒) */
|
|
||||||
const Images& frames /* 关键帧数组 */
|
|
||||||
);
|
);
|
||||||
|
|
||||||
virtual ~Animation();
|
virtual ~Animation();
|
||||||
|
|
||||||
// 添加关键帧
|
|
||||||
void Add(
|
|
||||||
spImage const& frame /* 关键帧 */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 添加多个关键帧
|
|
||||||
void Add(
|
|
||||||
const Images& frames /* 关键帧数组 */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 获取帧间隔
|
|
||||||
Duration const& GetInterval() const;
|
|
||||||
|
|
||||||
// 获取关键帧
|
|
||||||
Images const& GetFrames() const;
|
|
||||||
|
|
||||||
// 设置每一帧的时间间隔
|
|
||||||
void SetInterval(
|
|
||||||
Duration const& interval /* 帧间隔(秒) */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 获取帧动画的拷贝对象
|
|
||||||
spAnimation Clone() const;
|
|
||||||
|
|
||||||
// 获取帧动画的倒转
|
|
||||||
spAnimation Reverse() const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
Duration interval_;
|
|
||||||
Images frames_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// 精灵动作
|
|
||||||
class Animate
|
|
||||||
: public Action
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Animate();
|
|
||||||
|
|
||||||
explicit Animate(
|
|
||||||
spAnimation const& animation
|
|
||||||
);
|
|
||||||
|
|
||||||
virtual ~Animate();
|
|
||||||
|
|
||||||
// 获取动画
|
// 获取动画
|
||||||
spAnimation GetAnimation() const;
|
spFrames GetAnimation() const;
|
||||||
|
|
||||||
// 设置动画
|
// 设置动画
|
||||||
void SetAnimation(
|
void SetAnimation(
|
||||||
spAnimation const& animation
|
spFrames const& animation
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取该动作的拷贝对象
|
// 获取该动作的拷贝对象
|
||||||
|
|
@ -120,6 +63,6 @@ namespace easy2d
|
||||||
protected:
|
protected:
|
||||||
size_t frame_index_;
|
size_t frame_index_;
|
||||||
Duration delta_;
|
Duration delta_;
|
||||||
spAnimation animation_;
|
spFrames frames_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,32 +18,47 @@
|
||||||
// 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 "CallFunc.h"
|
#include "Delay.h"
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
CallFunc::CallFunc(const Callback& func) :
|
Delay::Delay(Duration const& duration)
|
||||||
callback_(func)
|
: delta_()
|
||||||
|
, delay_(duration)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
spAction CallFunc::Clone() const
|
void Delay::Reset()
|
||||||
{
|
{
|
||||||
return new CallFunc(callback_);
|
Action::Reset();
|
||||||
|
delta_ = Duration{};
|
||||||
}
|
}
|
||||||
|
|
||||||
spAction CallFunc::Reverse() const
|
void Delay::Init(Node* target)
|
||||||
{
|
{
|
||||||
return new CallFunc(callback_);
|
Action::Init(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CallFunc::Init(Node*)
|
void Delay::Update(Node* target, Duration const& dt)
|
||||||
{
|
{
|
||||||
|
Action::Update(target, dt);
|
||||||
|
|
||||||
|
delta_ += dt;
|
||||||
|
|
||||||
|
if (delta_ >= delay_)
|
||||||
|
{
|
||||||
|
this->Stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CallFunc::Update(Node*, Duration const&)
|
spAction Delay::Clone() const
|
||||||
{
|
{
|
||||||
callback_();
|
return new (std::nothrow) Delay(delay_);
|
||||||
this->Stop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spAction Delay::Reverse() const
|
||||||
|
{
|
||||||
|
return new (std::nothrow) Delay(delay_);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -20,19 +20,16 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "Action.hpp"
|
#include "Action.hpp"
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
namespace easy2d
|
namespace easy2d
|
||||||
{
|
{
|
||||||
// 回调动作
|
// 延时
|
||||||
class CallFunc
|
class Delay
|
||||||
: public Action
|
: public Action
|
||||||
{
|
{
|
||||||
typedef std::function<void()> Callback;
|
public:
|
||||||
|
explicit Delay(
|
||||||
public:
|
Duration const& duration /* 延迟时长(秒) */
|
||||||
explicit CallFunc(
|
|
||||||
const Callback &func /* 函数对象 */
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取该动作的拷贝对象
|
// 获取该动作的拷贝对象
|
||||||
|
|
@ -41,14 +38,16 @@ namespace easy2d
|
||||||
// 获取该动作的倒转
|
// 获取该动作的倒转
|
||||||
virtual spAction Reverse() const override;
|
virtual spAction Reverse() const override;
|
||||||
|
|
||||||
protected:
|
// 重置动作
|
||||||
// 初始化动作
|
virtual void Reset() override;
|
||||||
virtual void Init(Node*) override;
|
|
||||||
|
|
||||||
// 更新动作
|
protected:
|
||||||
virtual void Update(Node*, Duration const&) override;
|
virtual void Init(Node* target) override;
|
||||||
|
|
||||||
protected:
|
virtual void Update(Node* target, Duration const& dt) override;
|
||||||
Callback callback_;
|
|
||||||
|
protected:
|
||||||
|
Duration delay_;
|
||||||
|
Duration delta_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,114 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
#include "Frames.h"
|
||||||
|
#include "Image.h"
|
||||||
|
#include "logs.h"
|
||||||
|
|
||||||
|
namespace easy2d
|
||||||
|
{
|
||||||
|
Frames::Frames()
|
||||||
|
: interval_(1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Frames::Frames(Images const& frames)
|
||||||
|
: interval_(1)
|
||||||
|
{
|
||||||
|
this->Add(frames);
|
||||||
|
}
|
||||||
|
|
||||||
|
Frames::Frames(Duration const& interval)
|
||||||
|
: interval_(interval)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Frames::Frames(Duration const& interval, Images const& frames)
|
||||||
|
: interval_(interval)
|
||||||
|
{
|
||||||
|
this->Add(frames);
|
||||||
|
}
|
||||||
|
|
||||||
|
Frames::~Frames()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Frames::SetInterval(Duration const& interval)
|
||||||
|
{
|
||||||
|
interval_ = interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Frames::Add(spImage const& frame)
|
||||||
|
{
|
||||||
|
if (!frame)
|
||||||
|
logs::Warningln("Frames::Add failed, frame is nullptr.");
|
||||||
|
|
||||||
|
if (frame)
|
||||||
|
{
|
||||||
|
frames_.push_back(frame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Frames::Add(Images const& frames)
|
||||||
|
{
|
||||||
|
for (const auto &image : frames)
|
||||||
|
{
|
||||||
|
this->Add(image);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Duration const& Frames::GetInterval() const
|
||||||
|
{
|
||||||
|
return interval_;
|
||||||
|
}
|
||||||
|
|
||||||
|
Frames::Images const& Frames::GetFrames() const
|
||||||
|
{
|
||||||
|
return frames_;
|
||||||
|
}
|
||||||
|
|
||||||
|
spFrames Frames::Clone() const
|
||||||
|
{
|
||||||
|
auto animation = new (std::nothrow) Frames(interval_);
|
||||||
|
if (animation)
|
||||||
|
{
|
||||||
|
for (const auto& frame : frames_)
|
||||||
|
{
|
||||||
|
animation->Add(frame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return animation;
|
||||||
|
}
|
||||||
|
|
||||||
|
spFrames Frames::Reverse() const
|
||||||
|
{
|
||||||
|
auto animation = new (std::nothrow) Frames(interval_);
|
||||||
|
if (!frames_.empty())
|
||||||
|
{
|
||||||
|
for (auto iter = frames_.crbegin(), crend = frames_.crend(); iter != crend; ++iter)
|
||||||
|
{
|
||||||
|
if (*iter)
|
||||||
|
animation->Add(*iter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return animation;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,82 @@
|
||||||
|
// 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 "base.hpp"
|
||||||
|
#include "time.h"
|
||||||
|
|
||||||
|
namespace easy2d
|
||||||
|
{
|
||||||
|
// 帧集合
|
||||||
|
class Frames
|
||||||
|
: public ObjectBase
|
||||||
|
{
|
||||||
|
using Images = std::vector< spImage >;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Frames();
|
||||||
|
|
||||||
|
explicit Frames(
|
||||||
|
Images const& frames /* 关键帧数组 */
|
||||||
|
);
|
||||||
|
|
||||||
|
explicit Frames(
|
||||||
|
Duration const& interval /* 帧间隔(秒) */
|
||||||
|
);
|
||||||
|
|
||||||
|
explicit Frames(
|
||||||
|
Duration const& interval, /* 帧间隔(秒) */
|
||||||
|
Images const& frames /* 关键帧数组 */
|
||||||
|
);
|
||||||
|
|
||||||
|
virtual ~Frames();
|
||||||
|
|
||||||
|
// 添加关键帧
|
||||||
|
void Add(
|
||||||
|
spImage const& frame /* 关键帧 */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 添加多个关键帧
|
||||||
|
void Add(
|
||||||
|
Images const& frames /* 关键帧数组 */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 获取帧间隔
|
||||||
|
Duration const& GetInterval() const;
|
||||||
|
|
||||||
|
// 获取关键帧
|
||||||
|
Images const& GetFrames() const;
|
||||||
|
|
||||||
|
// 设置每一帧的时间间隔
|
||||||
|
void SetInterval(
|
||||||
|
Duration const& interval /* 帧间隔(秒) */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 获取帧动画的拷贝对象
|
||||||
|
spFrames Clone() const;
|
||||||
|
|
||||||
|
// 获取帧动画的倒转
|
||||||
|
spFrames Reverse() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Duration interval_;
|
||||||
|
Images frames_;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -43,6 +43,7 @@ namespace easy2d
|
||||||
E2D_DECLARE_SMART_PTR(Image);
|
E2D_DECLARE_SMART_PTR(Image);
|
||||||
E2D_DECLARE_SMART_PTR(Music);
|
E2D_DECLARE_SMART_PTR(Music);
|
||||||
E2D_DECLARE_SMART_PTR(Task);
|
E2D_DECLARE_SMART_PTR(Task);
|
||||||
|
E2D_DECLARE_SMART_PTR(Frames);
|
||||||
|
|
||||||
E2D_DECLARE_SMART_PTR(Geometry);
|
E2D_DECLARE_SMART_PTR(Geometry);
|
||||||
E2D_DECLARE_SMART_PTR(LineGeometry);
|
E2D_DECLARE_SMART_PTR(LineGeometry);
|
||||||
|
|
@ -60,6 +61,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(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);
|
||||||
|
|
@ -75,8 +77,6 @@ namespace easy2d
|
||||||
E2D_DECLARE_SMART_PTR(PathAction);
|
E2D_DECLARE_SMART_PTR(PathAction);
|
||||||
E2D_DECLARE_SMART_PTR(Delay);
|
E2D_DECLARE_SMART_PTR(Delay);
|
||||||
E2D_DECLARE_SMART_PTR(Animation);
|
E2D_DECLARE_SMART_PTR(Animation);
|
||||||
E2D_DECLARE_SMART_PTR(Animate);
|
|
||||||
E2D_DECLARE_SMART_PTR(CallFunc);
|
|
||||||
E2D_DECLARE_SMART_PTR(Loop);
|
E2D_DECLARE_SMART_PTR(Loop);
|
||||||
E2D_DECLARE_SMART_PTR(Sequence);
|
E2D_DECLARE_SMART_PTR(Sequence);
|
||||||
E2D_DECLARE_SMART_PTR(Spawn);
|
E2D_DECLARE_SMART_PTR(Spawn);
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@
|
||||||
#include "base/Task.h"
|
#include "base/Task.h"
|
||||||
#include "base/Action.hpp"
|
#include "base/Action.hpp"
|
||||||
#include "base/ActionCombined.h"
|
#include "base/ActionCombined.h"
|
||||||
#include "base/ActionInterval.h"
|
#include "base/ActionTween.h"
|
||||||
#include "base/Animation.h"
|
#include "base/Animation.h"
|
||||||
#include "base/CallFunc.h"
|
#include "base/CallFunc.h"
|
||||||
#include "base/Transition.h"
|
#include "base/Transition.h"
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,82 @@
|
||||||
|
// 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 "scalar.hpp"
|
||||||
|
|
||||||
|
namespace easy2d
|
||||||
|
{
|
||||||
|
namespace math
|
||||||
|
{
|
||||||
|
inline float Linear(float step)
|
||||||
|
{
|
||||||
|
return step;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float EaseIn(float step, float rate)
|
||||||
|
{
|
||||||
|
return math::Pow(step, rate);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float EaseOut(float step, float rate)
|
||||||
|
{
|
||||||
|
return math::Pow(step, 1.f / rate);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float EaseInOut(float step, float rate)
|
||||||
|
{
|
||||||
|
if (step < .5f)
|
||||||
|
return .5f * math::Pow(2 * step, rate);
|
||||||
|
return 1.f - .5f * math::Pow(2.f - 2 * step, rate);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float EaseExponentialIn(float step)
|
||||||
|
{
|
||||||
|
return math::Pow(2.f, 10 * (step - 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float EaseExponentialOut(float step)
|
||||||
|
{
|
||||||
|
return 1.f - math::Pow(2.f, -10 * step);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float EaseExponentialInOut(float step)
|
||||||
|
{
|
||||||
|
if (step < .5f)
|
||||||
|
return .5f * math::Pow(2.f, 10 * (2 * step - 1));
|
||||||
|
return 0.5f * (2 - math::Pow(2, -10 * (step * 2 - 1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float EaseSineIn(float step)
|
||||||
|
{
|
||||||
|
return 1.f - math::Cos(step * 90);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float EaseSineOut(float step)
|
||||||
|
{
|
||||||
|
return math::Sin(step * 90);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float EaseSineInOut(float step)
|
||||||
|
{
|
||||||
|
return -0.5f * (math::Cos(step * 180) - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -34,8 +34,10 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
namespace constants
|
namespace constants
|
||||||
{
|
{
|
||||||
E2D_CONSTEXPR auto PIf = 3.14159265358979f;
|
E2D_CONSTEXPR auto PI_F = 3.141592653589793f;
|
||||||
E2D_CONSTEXPR auto PId = 3.14159265358979323846;
|
E2D_CONSTEXPR auto PI_F_2 = 1.570796326794896f;
|
||||||
|
E2D_CONSTEXPR auto PI_D = 3.14159265358979323846;
|
||||||
|
E2D_CONSTEXPR auto PI_D_2 = 1.57079632679489661923;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int Abs(int val) { return ::abs(val); }
|
inline int Abs(int val) { return ::abs(val); }
|
||||||
|
|
@ -48,35 +50,39 @@ namespace easy2d
|
||||||
|
|
||||||
inline double Sqrt(double val) { return ::sqrt(val); }
|
inline double Sqrt(double val) { return ::sqrt(val); }
|
||||||
|
|
||||||
|
inline float Pow(float base, float exponent) { return ::powf(base, exponent); }
|
||||||
|
|
||||||
|
inline double Pow(double base, double exponent) { return ::pow(base, exponent); }
|
||||||
|
|
||||||
inline int Sign(int val) { return val < 0 ? -1 : 1; }
|
inline int Sign(int val) { return val < 0 ? -1 : 1; }
|
||||||
|
|
||||||
inline float Sign(float val) { return val < 0 ? -1.f : 1.f; }
|
inline float Sign(float val) { return val < 0 ? -1.f : 1.f; }
|
||||||
|
|
||||||
inline double Sign(double val) { return val < 0 ? -1.0 : 1.0; }
|
inline double Sign(double val) { return val < 0 ? -1.0 : 1.0; }
|
||||||
|
|
||||||
inline float Sin(float val) { return ::sinf(val * constants::PIf / 180.f); }
|
inline float Sin(float val) { return ::sinf(val * constants::PI_F / 180.f); }
|
||||||
|
|
||||||
inline double Sin(double val) { return ::sin(val * constants::PId / 180.0); }
|
inline double Sin(double val) { return ::sin(val * constants::PI_D / 180.0); }
|
||||||
|
|
||||||
inline float Cos(float val) { return ::cosf(val * constants::PIf / 180.f); }
|
inline float Cos(float val) { return ::cosf(val * constants::PI_F / 180.f); }
|
||||||
|
|
||||||
inline double Cos(double val) { return ::cos(val * constants::PId / 180.0); }
|
inline double Cos(double val) { return ::cos(val * constants::PI_D / 180.0); }
|
||||||
|
|
||||||
inline float Tan(float val) { return ::tanf(val * constants::PIf / 180.f); }
|
inline float Tan(float val) { return ::tanf(val * constants::PI_F / 180.f); }
|
||||||
|
|
||||||
inline double Tan(double val) { return ::tan(val * constants::PId / 180.0); }
|
inline double Tan(double val) { return ::tan(val * constants::PI_D / 180.0); }
|
||||||
|
|
||||||
inline float Asin(float val) { return ::asinf(val) * 180.f / constants::PIf; }
|
inline float Asin(float val) { return ::asinf(val) * 180.f / constants::PI_F; }
|
||||||
|
|
||||||
inline double Asin(double val) { return ::asin(val) * 180.f / constants::PIf; }
|
inline double Asin(double val) { return ::asin(val) * 180.f / constants::PI_F; }
|
||||||
|
|
||||||
inline float Acos(float val) { return ::acosf(val) * 180.f / constants::PIf; }
|
inline float Acos(float val) { return ::acosf(val) * 180.f / constants::PI_F; }
|
||||||
|
|
||||||
inline double Acos(double val) { return ::acos(val) * 180.f / constants::PIf; }
|
inline double Acos(double val) { return ::acos(val) * 180.f / constants::PI_F; }
|
||||||
|
|
||||||
inline float Atan(float val) { return ::atanf(val) * 180.f / constants::PIf; }
|
inline float Atan(float val) { return ::atanf(val) * 180.f / constants::PI_F; }
|
||||||
|
|
||||||
inline double Atan(double val) { return ::atan(val) * 180.f / constants::PIf; }
|
inline double Atan(double val) { return ::atan(val) * 180.f / constants::PI_F; }
|
||||||
|
|
||||||
inline float Ceil(float val) { return ::ceil(val); }
|
inline float Ceil(float val) { return ::ceil(val); }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,18 +21,19 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\core\base\Action.hpp" />
|
<ClInclude Include="..\..\core\base\Action.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\ActionCombined.h" />
|
<ClInclude Include="..\..\core\base\ActionCombined.h" />
|
||||||
<ClInclude Include="..\..\core\base\ActionInterval.h" />
|
<ClInclude Include="..\..\core\base\ActionTween.h" />
|
||||||
<ClInclude Include="..\..\core\base\ActionManager.h" />
|
<ClInclude Include="..\..\core\base\ActionManager.h" />
|
||||||
<ClInclude Include="..\..\core\base\Animation.h" />
|
<ClInclude Include="..\..\core\base\Animation.h" />
|
||||||
<ClInclude Include="..\..\core\base\audio.h" />
|
<ClInclude Include="..\..\core\base\audio.h" />
|
||||||
<ClInclude Include="..\..\core\base\base.hpp" />
|
<ClInclude Include="..\..\core\base\base.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\BaseTypes.hpp" />
|
<ClInclude Include="..\..\core\base\BaseTypes.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\CallFunc.h" />
|
|
||||||
<ClInclude Include="..\..\core\base\Canvas.h" />
|
<ClInclude Include="..\..\core\base\Canvas.h" />
|
||||||
<ClInclude Include="..\..\core\base\Color.h" />
|
<ClInclude Include="..\..\core\base\Color.h" />
|
||||||
<ClInclude Include="..\..\core\base\d2dres.hpp" />
|
<ClInclude Include="..\..\core\base\d2dres.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\Debuger.h" />
|
<ClInclude Include="..\..\core\base\Debuger.h" />
|
||||||
|
<ClInclude Include="..\..\core\base\Delay.h" />
|
||||||
<ClInclude Include="..\..\core\base\Font.hpp" />
|
<ClInclude Include="..\..\core\base\Font.hpp" />
|
||||||
|
<ClInclude Include="..\..\core\base\Frames.h" />
|
||||||
<ClInclude Include="..\..\core\base\Game.h" />
|
<ClInclude Include="..\..\core\base\Game.h" />
|
||||||
<ClInclude Include="..\..\core\base\Geometry.h" />
|
<ClInclude Include="..\..\core\base\Geometry.h" />
|
||||||
<ClInclude Include="..\..\core\base\GeometryNode.h" />
|
<ClInclude Include="..\..\core\base\GeometryNode.h" />
|
||||||
|
|
@ -69,6 +70,7 @@
|
||||||
<ClInclude Include="..\..\core\base\Unit.h" />
|
<ClInclude Include="..\..\core\base\Unit.h" />
|
||||||
<ClInclude Include="..\..\core\base\window.h" />
|
<ClInclude Include="..\..\core\base\window.h" />
|
||||||
<ClInclude Include="..\..\core\easy2d.h" />
|
<ClInclude Include="..\..\core\easy2d.h" />
|
||||||
|
<ClInclude Include="..\..\core\math\ease.hpp" />
|
||||||
<ClInclude Include="..\..\core\math\Matrix.hpp" />
|
<ClInclude Include="..\..\core\math\Matrix.hpp" />
|
||||||
<ClInclude Include="..\..\core\math\rand.h" />
|
<ClInclude Include="..\..\core\math\rand.h" />
|
||||||
<ClInclude Include="..\..\core\math\scalar.hpp" />
|
<ClInclude Include="..\..\core\math\scalar.hpp" />
|
||||||
|
|
@ -84,14 +86,15 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\core\base\ActionCombined.cpp" />
|
<ClCompile Include="..\..\core\base\ActionCombined.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\ActionInterval.cpp" />
|
<ClCompile Include="..\..\core\base\ActionTween.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\ActionManager.cpp" />
|
<ClCompile Include="..\..\core\base\ActionManager.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Animation.cpp" />
|
<ClCompile Include="..\..\core\base\Animation.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\audio.cpp" />
|
<ClCompile Include="..\..\core\base\audio.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\CallFunc.cpp" />
|
|
||||||
<ClCompile Include="..\..\core\base\Canvas.cpp" />
|
<ClCompile Include="..\..\core\base\Canvas.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Color.cpp" />
|
<ClCompile Include="..\..\core\base\Color.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Debuger.cpp" />
|
<ClCompile Include="..\..\core\base\Debuger.cpp" />
|
||||||
|
<ClCompile Include="..\..\core\base\Delay.cpp" />
|
||||||
|
<ClCompile Include="..\..\core\base\Frames.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Game.cpp" />
|
<ClCompile Include="..\..\core\base\Game.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Geometry.cpp" />
|
<ClCompile Include="..\..\core\base\Geometry.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\GeometryNode.cpp" />
|
<ClCompile Include="..\..\core\base\GeometryNode.cpp" />
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,6 @@
|
||||||
<ClInclude Include="..\..\core\base\audio.h">
|
<ClInclude Include="..\..\core\base\audio.h">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\core\base\CallFunc.h">
|
|
||||||
<Filter>base</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\core\base\Canvas.h">
|
<ClInclude Include="..\..\core\base\Canvas.h">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
@ -182,7 +179,16 @@
|
||||||
<ClInclude Include="..\..\core\base\Unit.h">
|
<ClInclude Include="..\..\core\base\Unit.h">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\core\base\ActionInterval.h">
|
<ClInclude Include="..\..\core\math\ease.hpp">
|
||||||
|
<Filter>math</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\core\base\ActionTween.h">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\core\base\Delay.h">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\core\base\Frames.h">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
@ -213,9 +219,6 @@
|
||||||
<ClCompile Include="..\..\core\base\audio.cpp">
|
<ClCompile Include="..\..\core\base\audio.cpp">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\core\base\CallFunc.cpp">
|
|
||||||
<Filter>base</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\core\base\Canvas.cpp">
|
<ClCompile Include="..\..\core\base\Canvas.cpp">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
@ -327,7 +330,13 @@
|
||||||
<ClCompile Include="..\..\core\base\Unit.cpp">
|
<ClCompile Include="..\..\core\base\Unit.cpp">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\core\base\ActionInterval.cpp">
|
<ClCompile Include="..\..\core\base\ActionTween.cpp">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\base\Delay.cpp">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\base\Frames.cpp">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -21,18 +21,19 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\core\base\Action.hpp" />
|
<ClInclude Include="..\..\core\base\Action.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\ActionCombined.h" />
|
<ClInclude Include="..\..\core\base\ActionCombined.h" />
|
||||||
<ClInclude Include="..\..\core\base\ActionInterval.h" />
|
<ClInclude Include="..\..\core\base\ActionTween.h" />
|
||||||
<ClInclude Include="..\..\core\base\ActionManager.h" />
|
<ClInclude Include="..\..\core\base\ActionManager.h" />
|
||||||
<ClInclude Include="..\..\core\base\Animation.h" />
|
<ClInclude Include="..\..\core\base\Animation.h" />
|
||||||
<ClInclude Include="..\..\core\base\audio.h" />
|
<ClInclude Include="..\..\core\base\audio.h" />
|
||||||
<ClInclude Include="..\..\core\base\base.hpp" />
|
<ClInclude Include="..\..\core\base\base.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\BaseTypes.hpp" />
|
<ClInclude Include="..\..\core\base\BaseTypes.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\CallFunc.h" />
|
|
||||||
<ClInclude Include="..\..\core\base\Canvas.h" />
|
<ClInclude Include="..\..\core\base\Canvas.h" />
|
||||||
<ClInclude Include="..\..\core\base\Color.h" />
|
<ClInclude Include="..\..\core\base\Color.h" />
|
||||||
<ClInclude Include="..\..\core\base\d2dres.hpp" />
|
<ClInclude Include="..\..\core\base\d2dres.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\Debuger.h" />
|
<ClInclude Include="..\..\core\base\Debuger.h" />
|
||||||
|
<ClInclude Include="..\..\core\base\Delay.h" />
|
||||||
<ClInclude Include="..\..\core\base\Font.hpp" />
|
<ClInclude Include="..\..\core\base\Font.hpp" />
|
||||||
|
<ClInclude Include="..\..\core\base\Frames.h" />
|
||||||
<ClInclude Include="..\..\core\base\Game.h" />
|
<ClInclude Include="..\..\core\base\Game.h" />
|
||||||
<ClInclude Include="..\..\core\base\Geometry.h" />
|
<ClInclude Include="..\..\core\base\Geometry.h" />
|
||||||
<ClInclude Include="..\..\core\base\GeometryNode.h" />
|
<ClInclude Include="..\..\core\base\GeometryNode.h" />
|
||||||
|
|
@ -69,6 +70,7 @@
|
||||||
<ClInclude Include="..\..\core\base\Unit.h" />
|
<ClInclude Include="..\..\core\base\Unit.h" />
|
||||||
<ClInclude Include="..\..\core\base\window.h" />
|
<ClInclude Include="..\..\core\base\window.h" />
|
||||||
<ClInclude Include="..\..\core\easy2d.h" />
|
<ClInclude Include="..\..\core\easy2d.h" />
|
||||||
|
<ClInclude Include="..\..\core\math\ease.hpp" />
|
||||||
<ClInclude Include="..\..\core\math\Matrix.hpp" />
|
<ClInclude Include="..\..\core\math\Matrix.hpp" />
|
||||||
<ClInclude Include="..\..\core\math\rand.h" />
|
<ClInclude Include="..\..\core\math\rand.h" />
|
||||||
<ClInclude Include="..\..\core\math\scalar.hpp" />
|
<ClInclude Include="..\..\core\math\scalar.hpp" />
|
||||||
|
|
@ -84,14 +86,15 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\core\base\ActionCombined.cpp" />
|
<ClCompile Include="..\..\core\base\ActionCombined.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\ActionInterval.cpp" />
|
<ClCompile Include="..\..\core\base\ActionTween.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\ActionManager.cpp" />
|
<ClCompile Include="..\..\core\base\ActionManager.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Animation.cpp" />
|
<ClCompile Include="..\..\core\base\Animation.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\audio.cpp" />
|
<ClCompile Include="..\..\core\base\audio.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\CallFunc.cpp" />
|
|
||||||
<ClCompile Include="..\..\core\base\Canvas.cpp" />
|
<ClCompile Include="..\..\core\base\Canvas.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Color.cpp" />
|
<ClCompile Include="..\..\core\base\Color.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Debuger.cpp" />
|
<ClCompile Include="..\..\core\base\Debuger.cpp" />
|
||||||
|
<ClCompile Include="..\..\core\base\Delay.cpp" />
|
||||||
|
<ClCompile Include="..\..\core\base\Frames.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Game.cpp" />
|
<ClCompile Include="..\..\core\base\Game.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Geometry.cpp" />
|
<ClCompile Include="..\..\core\base\Geometry.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\GeometryNode.cpp" />
|
<ClCompile Include="..\..\core\base\GeometryNode.cpp" />
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,6 @@
|
||||||
<ClInclude Include="..\..\core\base\audio.h">
|
<ClInclude Include="..\..\core\base\audio.h">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\core\base\CallFunc.h">
|
|
||||||
<Filter>base</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\core\base\Canvas.h">
|
<ClInclude Include="..\..\core\base\Canvas.h">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
@ -182,7 +179,16 @@
|
||||||
<ClInclude Include="..\..\core\base\Unit.h">
|
<ClInclude Include="..\..\core\base\Unit.h">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\core\base\ActionInterval.h">
|
<ClInclude Include="..\..\core\math\ease.hpp">
|
||||||
|
<Filter>math</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\core\base\ActionTween.h">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\core\base\Delay.h">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\core\base\Frames.h">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
@ -213,9 +219,6 @@
|
||||||
<ClCompile Include="..\..\core\base\audio.cpp">
|
<ClCompile Include="..\..\core\base\audio.cpp">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\core\base\CallFunc.cpp">
|
|
||||||
<Filter>base</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\core\base\Canvas.cpp">
|
<ClCompile Include="..\..\core\base\Canvas.cpp">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
@ -327,7 +330,13 @@
|
||||||
<ClCompile Include="..\..\core\base\Unit.cpp">
|
<ClCompile Include="..\..\core\base\Unit.cpp">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\core\base\ActionInterval.cpp">
|
<ClCompile Include="..\..\core\base\ActionTween.cpp">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\base\Delay.cpp">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\base\Frames.cpp">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -21,18 +21,19 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\core\base\Action.hpp" />
|
<ClInclude Include="..\..\core\base\Action.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\ActionCombined.h" />
|
<ClInclude Include="..\..\core\base\ActionCombined.h" />
|
||||||
<ClInclude Include="..\..\core\base\ActionInterval.h" />
|
<ClInclude Include="..\..\core\base\ActionTween.h" />
|
||||||
<ClInclude Include="..\..\core\base\ActionManager.h" />
|
<ClInclude Include="..\..\core\base\ActionManager.h" />
|
||||||
<ClInclude Include="..\..\core\base\Animation.h" />
|
<ClInclude Include="..\..\core\base\Animation.h" />
|
||||||
<ClInclude Include="..\..\core\base\audio.h" />
|
<ClInclude Include="..\..\core\base\audio.h" />
|
||||||
<ClInclude Include="..\..\core\base\base.hpp" />
|
<ClInclude Include="..\..\core\base\base.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\BaseTypes.hpp" />
|
<ClInclude Include="..\..\core\base\BaseTypes.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\CallFunc.h" />
|
|
||||||
<ClInclude Include="..\..\core\base\Canvas.h" />
|
<ClInclude Include="..\..\core\base\Canvas.h" />
|
||||||
<ClInclude Include="..\..\core\base\Color.h" />
|
<ClInclude Include="..\..\core\base\Color.h" />
|
||||||
<ClInclude Include="..\..\core\base\d2dres.hpp" />
|
<ClInclude Include="..\..\core\base\d2dres.hpp" />
|
||||||
<ClInclude Include="..\..\core\base\Debuger.h" />
|
<ClInclude Include="..\..\core\base\Debuger.h" />
|
||||||
|
<ClInclude Include="..\..\core\base\Delay.h" />
|
||||||
<ClInclude Include="..\..\core\base\Font.hpp" />
|
<ClInclude Include="..\..\core\base\Font.hpp" />
|
||||||
|
<ClInclude Include="..\..\core\base\Frames.h" />
|
||||||
<ClInclude Include="..\..\core\base\Game.h" />
|
<ClInclude Include="..\..\core\base\Game.h" />
|
||||||
<ClInclude Include="..\..\core\base\Geometry.h" />
|
<ClInclude Include="..\..\core\base\Geometry.h" />
|
||||||
<ClInclude Include="..\..\core\base\GeometryNode.h" />
|
<ClInclude Include="..\..\core\base\GeometryNode.h" />
|
||||||
|
|
@ -69,6 +70,7 @@
|
||||||
<ClInclude Include="..\..\core\base\Unit.h" />
|
<ClInclude Include="..\..\core\base\Unit.h" />
|
||||||
<ClInclude Include="..\..\core\base\window.h" />
|
<ClInclude Include="..\..\core\base\window.h" />
|
||||||
<ClInclude Include="..\..\core\easy2d.h" />
|
<ClInclude Include="..\..\core\easy2d.h" />
|
||||||
|
<ClInclude Include="..\..\core\math\ease.hpp" />
|
||||||
<ClInclude Include="..\..\core\math\Matrix.hpp" />
|
<ClInclude Include="..\..\core\math\Matrix.hpp" />
|
||||||
<ClInclude Include="..\..\core\math\rand.h" />
|
<ClInclude Include="..\..\core\math\rand.h" />
|
||||||
<ClInclude Include="..\..\core\math\scalar.hpp" />
|
<ClInclude Include="..\..\core\math\scalar.hpp" />
|
||||||
|
|
@ -84,14 +86,15 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\core\base\ActionCombined.cpp" />
|
<ClCompile Include="..\..\core\base\ActionCombined.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\ActionInterval.cpp" />
|
<ClCompile Include="..\..\core\base\ActionTween.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\ActionManager.cpp" />
|
<ClCompile Include="..\..\core\base\ActionManager.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Animation.cpp" />
|
<ClCompile Include="..\..\core\base\Animation.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\audio.cpp" />
|
<ClCompile Include="..\..\core\base\audio.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\CallFunc.cpp" />
|
|
||||||
<ClCompile Include="..\..\core\base\Canvas.cpp" />
|
<ClCompile Include="..\..\core\base\Canvas.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Color.cpp" />
|
<ClCompile Include="..\..\core\base\Color.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Debuger.cpp" />
|
<ClCompile Include="..\..\core\base\Debuger.cpp" />
|
||||||
|
<ClCompile Include="..\..\core\base\Delay.cpp" />
|
||||||
|
<ClCompile Include="..\..\core\base\Frames.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Game.cpp" />
|
<ClCompile Include="..\..\core\base\Game.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\Geometry.cpp" />
|
<ClCompile Include="..\..\core\base\Geometry.cpp" />
|
||||||
<ClCompile Include="..\..\core\base\GeometryNode.cpp" />
|
<ClCompile Include="..\..\core\base\GeometryNode.cpp" />
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,6 @@
|
||||||
<ClInclude Include="..\..\core\base\audio.h">
|
<ClInclude Include="..\..\core\base\audio.h">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\core\base\CallFunc.h">
|
|
||||||
<Filter>base</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\core\base\Canvas.h">
|
<ClInclude Include="..\..\core\base\Canvas.h">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
@ -182,7 +179,16 @@
|
||||||
<ClInclude Include="..\..\core\base\Unit.h">
|
<ClInclude Include="..\..\core\base\Unit.h">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\core\base\ActionInterval.h">
|
<ClInclude Include="..\..\core\math\ease.hpp">
|
||||||
|
<Filter>math</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\core\base\ActionTween.h">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\core\base\Delay.h">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\core\base\Frames.h">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
@ -213,9 +219,6 @@
|
||||||
<ClCompile Include="..\..\core\base\audio.cpp">
|
<ClCompile Include="..\..\core\base\audio.cpp">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\core\base\CallFunc.cpp">
|
|
||||||
<Filter>base</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\core\base\Canvas.cpp">
|
<ClCompile Include="..\..\core\base\Canvas.cpp">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
@ -327,7 +330,13 @@
|
||||||
<ClCompile Include="..\..\core\base\Unit.cpp">
|
<ClCompile Include="..\..\core\base\Unit.cpp">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\core\base\ActionInterval.cpp">
|
<ClCompile Include="..\..\core\base\ActionTween.cpp">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\base\Delay.cpp">
|
||||||
|
<Filter>base</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\base\Frames.cpp">
|
||||||
<Filter>base</Filter>
|
<Filter>base</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue