add: use intrusive pointers to solve memory management problems
minor improves
This commit is contained in:
parent
b44f71e251
commit
ccba1363a0
|
|
@ -1,106 +0,0 @@
|
|||
// 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 "Action.h"
|
||||
#include "base.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
Action::Action()
|
||||
: running_(false), done_(false), initialized_(false), target_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
Action::~Action()
|
||||
{
|
||||
}
|
||||
|
||||
bool Action::IsRunning()
|
||||
{
|
||||
return running_;
|
||||
}
|
||||
|
||||
void Action::Resume()
|
||||
{
|
||||
running_ = true;
|
||||
}
|
||||
|
||||
void Action::Pause()
|
||||
{
|
||||
running_ = false;
|
||||
}
|
||||
|
||||
void Action::Stop()
|
||||
{
|
||||
done_ = true;
|
||||
}
|
||||
|
||||
const String& Action::GetName() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
void Action::SetName(const String& name)
|
||||
{
|
||||
name_ = name;
|
||||
}
|
||||
|
||||
Node * Action::GetTarget()
|
||||
{
|
||||
return target_;
|
||||
}
|
||||
|
||||
void Action::Reset()
|
||||
{
|
||||
initialized_ = false;
|
||||
done_ = false;
|
||||
started_ = time::Now();
|
||||
}
|
||||
|
||||
bool Action::IsDone() const
|
||||
{
|
||||
return done_;
|
||||
}
|
||||
|
||||
void Action::StartWithTarget(Node* target)
|
||||
{
|
||||
target_ = target;
|
||||
running_ = true;
|
||||
this->Reset();
|
||||
}
|
||||
|
||||
void Action::Initialize()
|
||||
{
|
||||
initialized_ = true;
|
||||
started_ = time::Now();
|
||||
}
|
||||
|
||||
void Action::Update()
|
||||
{
|
||||
if (!initialized_)
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
}
|
||||
|
||||
void Action::ResetTime()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -21,85 +21,86 @@
|
|||
#pragma once
|
||||
#include "base.h"
|
||||
#include "time.h"
|
||||
#include "RefCounter.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
class Node;
|
||||
class Loop;
|
||||
class Sequence;
|
||||
class Spawn;
|
||||
|
||||
// 基础动作
|
||||
class Action
|
||||
: public RefCounter
|
||||
{
|
||||
E2D_DISABLE_COPY(Action);
|
||||
|
||||
friend class Node;
|
||||
friend class Loop;
|
||||
friend class Sequence;
|
||||
friend class Spawn;
|
||||
|
||||
E2D_DISABLE_COPY(Action);
|
||||
|
||||
public:
|
||||
Action();
|
||||
Action() : running_(false), done_(false), initialized_(false) {}
|
||||
|
||||
virtual ~Action();
|
||||
virtual ~Action() {}
|
||||
|
||||
// 获取动作运行状态
|
||||
virtual bool IsRunning();
|
||||
inline bool IsRunning() { return running_; }
|
||||
|
||||
// 继续动作
|
||||
virtual void Resume();
|
||||
inline void Resume() { running_ = true; }
|
||||
|
||||
// 暂停动作
|
||||
virtual void Pause();
|
||||
inline void Pause() { running_ = false; }
|
||||
|
||||
// 停止动作
|
||||
virtual void Stop();
|
||||
inline void Stop() { done_ = true; }
|
||||
|
||||
// 获取动作名称
|
||||
virtual const String& GetName() const;
|
||||
inline const String& GetName() const { return name_; }
|
||||
|
||||
// 设置动作名称
|
||||
virtual void SetName(
|
||||
const String& name
|
||||
);
|
||||
inline void SetName(const String& name) { name_ = name; }
|
||||
|
||||
inline bool IsDone() const { return done_; }
|
||||
|
||||
// 获取动作的拷贝
|
||||
virtual Action * Clone() const = 0;
|
||||
virtual spAction Clone() const = 0;
|
||||
|
||||
// 获取动作的倒转
|
||||
virtual Action * Reverse() const = 0;
|
||||
virtual spAction Reverse() const = 0;
|
||||
|
||||
// 重置动作
|
||||
virtual void Reset();
|
||||
virtual void Reset()
|
||||
{
|
||||
initialized_ = false;
|
||||
done_ = false;
|
||||
started_ = time::Now();
|
||||
}
|
||||
|
||||
// 获取该动作的执行目标
|
||||
virtual Node * GetTarget();
|
||||
protected:
|
||||
virtual void Start()
|
||||
{
|
||||
running_ = true;
|
||||
this->Reset();
|
||||
}
|
||||
|
||||
// 开始动作
|
||||
virtual void StartWithTarget(
|
||||
Node* target
|
||||
);
|
||||
virtual void Init(Node* target)
|
||||
{
|
||||
initialized_ = true;
|
||||
started_ = time::Now();
|
||||
}
|
||||
|
||||
// 初始化动作
|
||||
virtual void Initialize();
|
||||
virtual void Update(Node* target)
|
||||
{
|
||||
if (!initialized_)
|
||||
{
|
||||
Init(target);
|
||||
}
|
||||
}
|
||||
|
||||
// 更新动作
|
||||
virtual void Update();
|
||||
|
||||
// 重置动作时间
|
||||
virtual void ResetTime();
|
||||
|
||||
// 获取动作结束状态
|
||||
virtual bool IsDone() const;
|
||||
virtual void ResetTime() {}
|
||||
|
||||
protected:
|
||||
String name_;
|
||||
bool running_;
|
||||
bool done_;
|
||||
bool initialized_;
|
||||
Node* target_;
|
||||
time::TimePoint started_;
|
||||
TimePoint started_;
|
||||
};
|
||||
}
|
||||
|
|
@ -27,30 +27,25 @@ namespace easy2d
|
|||
// Loop
|
||||
//-------------------------------------------------------
|
||||
|
||||
Loop::Loop(Action * action, int times)
|
||||
Loop::Loop(spAction const& action, int times)
|
||||
: action_(action)
|
||||
, times_(0)
|
||||
, total_times_(times)
|
||||
{
|
||||
E2D_WARNING_IF(action == nullptr, "Loop NULL pointer exception!");
|
||||
E2D_WARNING_IF(!action, "Loop NULL pointer exception!");
|
||||
|
||||
if (action)
|
||||
{
|
||||
action_ = action;
|
||||
action_->Retain();
|
||||
}
|
||||
}
|
||||
|
||||
Loop::~Loop()
|
||||
{
|
||||
SafeRelease(action_);
|
||||
}
|
||||
|
||||
Loop * Loop::Clone() const
|
||||
spAction Loop::Clone() const
|
||||
{
|
||||
if (action_)
|
||||
{
|
||||
return new Loop(action_->Clone());
|
||||
return new (std::nothrow) Loop(action_->Clone());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -58,11 +53,11 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
Loop * Loop::Reverse() const
|
||||
spAction Loop::Reverse() const
|
||||
{
|
||||
if (action_)
|
||||
{
|
||||
return new Loop(action_->Clone());
|
||||
return new (std::nothrow) Loop(action_->Clone());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -70,20 +65,19 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
void Loop::Initialize()
|
||||
void Loop::Init(Node* target)
|
||||
{
|
||||
Action::Initialize();
|
||||
Action::Init(target);
|
||||
|
||||
if (action_)
|
||||
{
|
||||
action_->target_ = target_;
|
||||
action_->Initialize();
|
||||
action_->Init(target);
|
||||
}
|
||||
}
|
||||
|
||||
void Loop::Update()
|
||||
void Loop::Update(Node* target)
|
||||
{
|
||||
Action::Update();
|
||||
Action::Update(target);
|
||||
|
||||
if (times_ == total_times_)
|
||||
{
|
||||
|
|
@ -93,7 +87,7 @@ namespace easy2d
|
|||
|
||||
if (action_)
|
||||
{
|
||||
action_->Update();
|
||||
action_->Update(target);
|
||||
|
||||
if (action_->IsDone())
|
||||
{
|
||||
|
|
@ -140,33 +134,20 @@ namespace easy2d
|
|||
|
||||
Sequence::~Sequence()
|
||||
{
|
||||
for (auto action : actions_)
|
||||
{
|
||||
SafeRelease(action);
|
||||
}
|
||||
}
|
||||
|
||||
void Sequence::Initialize()
|
||||
void Sequence::Init(Node* target)
|
||||
{
|
||||
Action::Initialize();
|
||||
// 将所有动作与目标绑定
|
||||
if (target_)
|
||||
{
|
||||
for (const auto& action : actions_)
|
||||
{
|
||||
action->target_ = target_;
|
||||
}
|
||||
}
|
||||
// 初始化第一个动作
|
||||
actions_[0]->Initialize();
|
||||
Action::Init(target);
|
||||
actions_[0]->Init(target);
|
||||
}
|
||||
|
||||
void Sequence::Update()
|
||||
void Sequence::Update(Node* target)
|
||||
{
|
||||
Action::Update();
|
||||
Action::Update(target);
|
||||
|
||||
auto &action = actions_[action_index_];
|
||||
action->Update();
|
||||
action->Update(target);
|
||||
|
||||
if (action->IsDone())
|
||||
{
|
||||
|
|
@ -177,7 +158,7 @@ namespace easy2d
|
|||
}
|
||||
else
|
||||
{
|
||||
actions_[action_index_]->Initialize();
|
||||
actions_[action_index_]->Init(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -200,12 +181,11 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
void Sequence::Add(Action * action)
|
||||
void Sequence::Add(spAction const& action)
|
||||
{
|
||||
if (action)
|
||||
{
|
||||
actions_.push_back(action);
|
||||
action->Retain();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -217,9 +197,11 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
Sequence * Sequence::Clone() const
|
||||
spAction Sequence::Clone() const
|
||||
{
|
||||
auto sequence = new (std::nothrow) Sequence();
|
||||
if (sequence)
|
||||
{
|
||||
auto sequence = new Sequence();
|
||||
for (const auto& action : actions_)
|
||||
{
|
||||
if (action)
|
||||
|
|
@ -227,20 +209,20 @@ namespace easy2d
|
|||
sequence->Add(action->Clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
return sequence;
|
||||
}
|
||||
|
||||
Sequence * Sequence::Reverse() const
|
||||
spAction Sequence::Reverse() const
|
||||
{
|
||||
auto sequence = new Sequence();
|
||||
auto sequence = new (std::nothrow) Sequence();
|
||||
if (sequence && !actions_.empty())
|
||||
{
|
||||
std::vector<Action*> newActions(actions_.size());
|
||||
for (auto iter = actions_.crbegin(), iterCrend = actions_.crend(); iter != iterCrend; ++iter)
|
||||
for (auto iter = actions_.crbegin(), crend = actions_.crend(); iter != crend; ++iter)
|
||||
{
|
||||
newActions.push_back((*iter)->Reverse());
|
||||
if (*iter)
|
||||
sequence->Add((*iter)->Reverse());
|
||||
}
|
||||
sequence->Add(newActions);
|
||||
}
|
||||
return sequence;
|
||||
}
|
||||
|
|
@ -261,29 +243,24 @@ namespace easy2d
|
|||
|
||||
Spawn::~Spawn()
|
||||
{
|
||||
for (auto action : actions_)
|
||||
{
|
||||
SafeRelease(action);
|
||||
}
|
||||
}
|
||||
|
||||
void Spawn::Initialize()
|
||||
void Spawn::Init(Node* target)
|
||||
{
|
||||
Action::Initialize();
|
||||
Action::Init(target);
|
||||
|
||||
if (target_)
|
||||
if (target)
|
||||
{
|
||||
for (const auto& action : actions_)
|
||||
{
|
||||
action->target_ = target_;
|
||||
action->Initialize();
|
||||
action->Init(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Spawn::Update()
|
||||
void Spawn::Update(Node* target)
|
||||
{
|
||||
Action::Update();
|
||||
Action::Update(target);
|
||||
|
||||
size_t done_num = 0;
|
||||
for (const auto& action : actions_)
|
||||
|
|
@ -294,7 +271,7 @@ namespace easy2d
|
|||
}
|
||||
else
|
||||
{
|
||||
action->Update();
|
||||
action->Update(target);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -321,12 +298,11 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
void Spawn::Add(Action * action)
|
||||
void Spawn::Add(spAction const& action)
|
||||
{
|
||||
if (action)
|
||||
{
|
||||
actions_.push_back(action);
|
||||
action->Retain();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -338,9 +314,11 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
Spawn * Spawn::Clone() const
|
||||
spAction Spawn::Clone() const
|
||||
{
|
||||
auto spawn = new (std::nothrow) Spawn();
|
||||
if (spawn)
|
||||
{
|
||||
auto spawn = new Spawn();
|
||||
for (const auto& action : actions_)
|
||||
{
|
||||
if (action)
|
||||
|
|
@ -348,20 +326,20 @@ namespace easy2d
|
|||
spawn->Add(action->Clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
return spawn;
|
||||
}
|
||||
|
||||
Spawn * Spawn::Reverse() const
|
||||
spAction Spawn::Reverse() const
|
||||
{
|
||||
auto spawn = new Spawn();
|
||||
auto spawn = new (std::nothrow) Spawn();
|
||||
if (spawn && !actions_.empty())
|
||||
{
|
||||
std::vector<Action*> newActions(actions_.size());
|
||||
for (auto iter = actions_.crbegin(), iterCrend = actions_.crend(); iter != iterCrend; ++iter)
|
||||
for (auto iter = actions_.crbegin(), crend = actions_.crend(); iter != crend; ++iter)
|
||||
{
|
||||
newActions.push_back((*iter)->Reverse());
|
||||
if (*iter)
|
||||
spawn->Add((*iter)->Reverse());
|
||||
}
|
||||
spawn->Add(newActions);
|
||||
}
|
||||
return spawn;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include "Action.h"
|
||||
#include "Action.hpp"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -31,33 +31,33 @@ namespace easy2d
|
|||
|
||||
public:
|
||||
explicit Loop(
|
||||
Action * action, /* Ö´ÐÐÑ»·µÄ¶¯×÷ */
|
||||
spAction const& action, /* Ö´ÐÐÑ»·µÄ¶¯×÷ */
|
||||
int times = -1 /* 循环次数 */
|
||||
);
|
||||
|
||||
virtual ~Loop();
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual Loop * Clone() const override;
|
||||
virtual spAction Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual Loop * Reverse() const override;
|
||||
virtual spAction Reverse() const override;
|
||||
|
||||
// 重置动作
|
||||
virtual void Reset() override;
|
||||
|
||||
protected:
|
||||
// 初始化动作
|
||||
virtual void Initialize() override;
|
||||
virtual void Init(Node* target) override;
|
||||
|
||||
// 更新动作
|
||||
virtual void Update() override;
|
||||
virtual void Update(Node* target) override;
|
||||
|
||||
// 重置动作时间
|
||||
virtual void ResetTime() override;
|
||||
|
||||
protected:
|
||||
Action * action_;
|
||||
spAction action_;
|
||||
int times_;
|
||||
int total_times_;
|
||||
};
|
||||
|
|
@ -70,8 +70,6 @@ namespace easy2d
|
|||
E2D_DISABLE_COPY(Sequence);
|
||||
|
||||
public:
|
||||
typedef std::vector<Action*> Actions;
|
||||
|
||||
Sequence();
|
||||
|
||||
explicit Sequence(
|
||||
|
|
@ -82,7 +80,7 @@ namespace easy2d
|
|||
|
||||
// 在结尾添加动作
|
||||
void Add(
|
||||
Action * action
|
||||
spAction const& action
|
||||
);
|
||||
|
||||
// 在结尾添加多个动作
|
||||
|
|
@ -91,20 +89,20 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual Sequence * Clone() const override;
|
||||
virtual spAction Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual Sequence * Reverse() const;
|
||||
virtual spAction Reverse() const override;
|
||||
|
||||
// 重置动作
|
||||
virtual void Reset() override;
|
||||
|
||||
protected:
|
||||
// 初始化动作
|
||||
virtual void Initialize() override;
|
||||
virtual void Init(Node* target) override;
|
||||
|
||||
// 更新动作
|
||||
virtual void Update() override;
|
||||
virtual void Update(Node* target) override;
|
||||
|
||||
// 重置动作时间
|
||||
virtual void ResetTime() override;
|
||||
|
|
@ -122,8 +120,6 @@ namespace easy2d
|
|||
E2D_DISABLE_COPY(Spawn);
|
||||
|
||||
public:
|
||||
typedef std::vector<Action*> Actions;
|
||||
|
||||
Spawn();
|
||||
|
||||
explicit Spawn(
|
||||
|
|
@ -134,7 +130,7 @@ namespace easy2d
|
|||
|
||||
// 在结尾添加动作
|
||||
void Add(
|
||||
Action * action
|
||||
spAction const& action
|
||||
);
|
||||
|
||||
// 在结尾添加多个动作
|
||||
|
|
@ -143,20 +139,20 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual Spawn * Clone() const override;
|
||||
virtual spAction Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual Spawn * Reverse() const;
|
||||
virtual spAction Reverse() const;
|
||||
|
||||
// 重置动作
|
||||
virtual void Reset() override;
|
||||
|
||||
protected:
|
||||
// 初始化动作
|
||||
virtual void Initialize() override;
|
||||
virtual void Init(Node* target) override;
|
||||
|
||||
// 更新动作
|
||||
virtual void Update() override;
|
||||
virtual void Update(Node* target) override;
|
||||
|
||||
// 重置动作时间
|
||||
virtual void ResetTime() override;
|
||||
|
|
|
|||
|
|
@ -41,14 +41,14 @@ namespace easy2d
|
|||
delta_ = 0;
|
||||
}
|
||||
|
||||
void FiniteTimeAction::Initialize()
|
||||
void FiniteTimeAction::Init(Node* target)
|
||||
{
|
||||
Action::Initialize();
|
||||
Action::Init(target);
|
||||
}
|
||||
|
||||
void FiniteTimeAction::Update()
|
||||
void FiniteTimeAction::Update(Node* target)
|
||||
{
|
||||
Action::Update();
|
||||
Action::Update(target);
|
||||
|
||||
if (duration_ == 0)
|
||||
{
|
||||
|
|
@ -83,41 +83,41 @@ namespace easy2d
|
|||
delta_pos_ = vector;
|
||||
}
|
||||
|
||||
void MoveBy::Initialize()
|
||||
void MoveBy::Init(Node* target)
|
||||
{
|
||||
FiniteTimeAction::Initialize();
|
||||
FiniteTimeAction::Init(target);
|
||||
|
||||
if (target_)
|
||||
if (target)
|
||||
{
|
||||
prev_pos_ = start_pos_ = target_->GetPosition();
|
||||
prev_pos_ = start_pos_ = target->GetPosition();
|
||||
}
|
||||
}
|
||||
|
||||
void MoveBy::Update()
|
||||
void MoveBy::Update(Node* target)
|
||||
{
|
||||
FiniteTimeAction::Update();
|
||||
FiniteTimeAction::Update(target);
|
||||
|
||||
if (target_)
|
||||
if (target)
|
||||
{
|
||||
Point currentPos = target_->GetPosition();
|
||||
Point currentPos = target->GetPosition();
|
||||
Point diff = currentPos - prev_pos_;
|
||||
start_pos_ = start_pos_ + diff;
|
||||
|
||||
Point newPos = start_pos_ + (delta_pos_ * delta_);
|
||||
target_->SetPosition(newPos);
|
||||
target->SetPosition(newPos);
|
||||
|
||||
prev_pos_ = newPos;
|
||||
}
|
||||
}
|
||||
|
||||
MoveBy * MoveBy::Clone() const
|
||||
spAction MoveBy::Clone() const
|
||||
{
|
||||
return new MoveBy(duration_, delta_pos_);
|
||||
return new (std::nothrow) MoveBy(duration_, delta_pos_);
|
||||
}
|
||||
|
||||
MoveBy * MoveBy::Reverse() const
|
||||
spAction MoveBy::Reverse() const
|
||||
{
|
||||
return new MoveBy(duration_, -delta_pos_);
|
||||
return new (std::nothrow) MoveBy(duration_, -delta_pos_);
|
||||
}
|
||||
|
||||
MoveTo::MoveTo(float duration, Point pos)
|
||||
|
|
@ -126,14 +126,14 @@ namespace easy2d
|
|||
end_pos_ = pos;
|
||||
}
|
||||
|
||||
MoveTo * MoveTo::Clone() const
|
||||
spAction MoveTo::Clone() const
|
||||
{
|
||||
return new MoveTo(duration_, end_pos_);
|
||||
return new (std::nothrow) MoveTo(duration_, end_pos_);
|
||||
}
|
||||
|
||||
void MoveTo::Initialize()
|
||||
void MoveTo::Init(Node* target)
|
||||
{
|
||||
MoveBy::Initialize();
|
||||
MoveBy::Init(target);
|
||||
delta_pos_ = end_pos_ - start_pos_;
|
||||
}
|
||||
|
||||
|
|
@ -150,44 +150,44 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
JumpBy * JumpBy::Clone() const
|
||||
spAction JumpBy::Clone() const
|
||||
{
|
||||
return new JumpBy(duration_, delta_pos_, height_, jumps_);
|
||||
return new (std::nothrow) JumpBy(duration_, delta_pos_, height_, jumps_);
|
||||
}
|
||||
|
||||
JumpBy * JumpBy::Reverse() const
|
||||
spAction JumpBy::Reverse() const
|
||||
{
|
||||
return new JumpBy(duration_, -delta_pos_, height_, jumps_);
|
||||
return new (std::nothrow) JumpBy(duration_, -delta_pos_, height_, jumps_);
|
||||
}
|
||||
|
||||
void JumpBy::Initialize()
|
||||
void JumpBy::Init(Node* target)
|
||||
{
|
||||
FiniteTimeAction::Initialize();
|
||||
FiniteTimeAction::Init(target);
|
||||
|
||||
if (target_)
|
||||
if (target)
|
||||
{
|
||||
prev_pos_ = start_pos_ = target_->GetPosition();
|
||||
prev_pos_ = start_pos_ = target->GetPosition();
|
||||
}
|
||||
}
|
||||
|
||||
void JumpBy::Update()
|
||||
void JumpBy::Update(Node* target)
|
||||
{
|
||||
FiniteTimeAction::Update();
|
||||
FiniteTimeAction::Update(target);
|
||||
|
||||
if (target_)
|
||||
if (target)
|
||||
{
|
||||
float frac = fmod(delta_ * jumps_, 1.f);
|
||||
float x = delta_pos_.x * delta_;
|
||||
float y = height_ * 4 * frac * (1 - frac);
|
||||
y += delta_pos_.y * delta_;
|
||||
|
||||
Point currentPos = target_->GetPosition();
|
||||
Point currentPos = target->GetPosition();
|
||||
|
||||
Point diff = currentPos - prev_pos_;
|
||||
start_pos_ = diff + start_pos_;
|
||||
|
||||
Point newPos = start_pos_ + Point(x, y);
|
||||
target_->SetPosition(newPos);
|
||||
target->SetPosition(newPos);
|
||||
|
||||
prev_pos_ = newPos;
|
||||
}
|
||||
|
|
@ -199,14 +199,14 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
JumpTo * JumpTo::Clone() const
|
||||
spAction JumpTo::Clone() const
|
||||
{
|
||||
return new JumpTo(duration_, end_pos_, height_, jumps_);
|
||||
return new (std::nothrow) JumpTo(duration_, end_pos_, height_, jumps_);
|
||||
}
|
||||
|
||||
void JumpTo::Initialize()
|
||||
void JumpTo::Init(Node* target)
|
||||
{
|
||||
JumpBy::Initialize();
|
||||
JumpBy::Init(target);
|
||||
delta_pos_ = end_pos_ - start_pos_;
|
||||
}
|
||||
|
||||
|
|
@ -229,35 +229,35 @@ namespace easy2d
|
|||
delta_y_ = scale_y;
|
||||
}
|
||||
|
||||
void ScaleBy::Initialize()
|
||||
void ScaleBy::Init(Node* target)
|
||||
{
|
||||
FiniteTimeAction::Initialize();
|
||||
FiniteTimeAction::Init(target);
|
||||
|
||||
if (target_)
|
||||
if (target)
|
||||
{
|
||||
start_scale_x_ = target_->GetScaleX();
|
||||
start_scale_y_ = target_->GetScaleY();
|
||||
start_scale_x_ = target->GetScaleX();
|
||||
start_scale_y_ = target->GetScaleY();
|
||||
}
|
||||
}
|
||||
|
||||
void ScaleBy::Update()
|
||||
void ScaleBy::Update(Node* target)
|
||||
{
|
||||
FiniteTimeAction::Update();
|
||||
FiniteTimeAction::Update(target);
|
||||
|
||||
if (target_)
|
||||
if (target)
|
||||
{
|
||||
target_->SetScale(start_scale_x_ + delta_x_ * delta_, start_scale_y_ + delta_y_ * delta_);
|
||||
target->SetScale(start_scale_x_ + delta_x_ * delta_, start_scale_y_ + delta_y_ * delta_);
|
||||
}
|
||||
}
|
||||
|
||||
ScaleBy * ScaleBy::Clone() const
|
||||
spAction ScaleBy::Clone() const
|
||||
{
|
||||
return new ScaleBy(duration_, delta_x_, delta_y_);
|
||||
return new (std::nothrow) ScaleBy(duration_, delta_x_, delta_y_);
|
||||
}
|
||||
|
||||
ScaleBy * ScaleBy::Reverse() const
|
||||
spAction ScaleBy::Reverse() const
|
||||
{
|
||||
return new ScaleBy(duration_, -delta_x_, -delta_y_);
|
||||
return new (std::nothrow) ScaleBy(duration_, -delta_x_, -delta_y_);
|
||||
}
|
||||
|
||||
ScaleTo::ScaleTo(float duration, float scale)
|
||||
|
|
@ -274,14 +274,14 @@ namespace easy2d
|
|||
end_scale_y_ = scale_y;
|
||||
}
|
||||
|
||||
ScaleTo * ScaleTo::Clone() const
|
||||
spAction ScaleTo::Clone() const
|
||||
{
|
||||
return new ScaleTo(duration_, end_scale_x_, end_scale_y_);
|
||||
return new (std::nothrow) ScaleTo(duration_, end_scale_x_, end_scale_y_);
|
||||
}
|
||||
|
||||
void ScaleTo::Initialize()
|
||||
void ScaleTo::Init(Node* target)
|
||||
{
|
||||
ScaleBy::Initialize();
|
||||
ScaleBy::Init(target);
|
||||
delta_x_ = end_scale_x_ - start_scale_x_;
|
||||
delta_y_ = end_scale_y_ - start_scale_y_;
|
||||
}
|
||||
|
|
@ -297,34 +297,34 @@ namespace easy2d
|
|||
delta_val_ = opacity;
|
||||
}
|
||||
|
||||
void OpacityBy::Initialize()
|
||||
void OpacityBy::Init(Node* target)
|
||||
{
|
||||
FiniteTimeAction::Initialize();
|
||||
FiniteTimeAction::Init(target);
|
||||
|
||||
if (target_)
|
||||
if (target)
|
||||
{
|
||||
start_val_ = target_->GetOpacity();
|
||||
start_val_ = target->GetOpacity();
|
||||
}
|
||||
}
|
||||
|
||||
void OpacityBy::Update()
|
||||
void OpacityBy::Update(Node* target)
|
||||
{
|
||||
FiniteTimeAction::Update();
|
||||
FiniteTimeAction::Update(target);
|
||||
|
||||
if (target_)
|
||||
if (target)
|
||||
{
|
||||
target_->SetOpacity(start_val_ + delta_val_ * delta_);
|
||||
target->SetOpacity(start_val_ + delta_val_ * delta_);
|
||||
}
|
||||
}
|
||||
|
||||
OpacityBy * OpacityBy::Clone() const
|
||||
spAction OpacityBy::Clone() const
|
||||
{
|
||||
return new OpacityBy(duration_, delta_val_);
|
||||
return new (std::nothrow) OpacityBy(duration_, delta_val_);
|
||||
}
|
||||
|
||||
OpacityBy * OpacityBy::Reverse() const
|
||||
spAction OpacityBy::Reverse() const
|
||||
{
|
||||
return new OpacityBy(duration_, -delta_val_);
|
||||
return new (std::nothrow) OpacityBy(duration_, -delta_val_);
|
||||
}
|
||||
|
||||
OpacityTo::OpacityTo(float duration, float opacity)
|
||||
|
|
@ -333,14 +333,14 @@ namespace easy2d
|
|||
end_val_ = opacity;
|
||||
}
|
||||
|
||||
OpacityTo * OpacityTo::Clone() const
|
||||
spAction OpacityTo::Clone() const
|
||||
{
|
||||
return new OpacityTo(duration_, end_val_);
|
||||
return new (std::nothrow) OpacityTo(duration_, end_val_);
|
||||
}
|
||||
|
||||
void OpacityTo::Initialize()
|
||||
void OpacityTo::Init(Node* target)
|
||||
{
|
||||
OpacityBy::Initialize();
|
||||
OpacityBy::Init(target);
|
||||
delta_val_ = end_val_ - start_val_;
|
||||
}
|
||||
|
||||
|
|
@ -365,34 +365,34 @@ namespace easy2d
|
|||
delta_val_ = rotation;
|
||||
}
|
||||
|
||||
void RotateBy::Initialize()
|
||||
void RotateBy::Init(Node* target)
|
||||
{
|
||||
FiniteTimeAction::Initialize();
|
||||
FiniteTimeAction::Init(target);
|
||||
|
||||
if (target_)
|
||||
if (target)
|
||||
{
|
||||
start_val_ = target_->GetRotation();
|
||||
start_val_ = target->GetRotation();
|
||||
}
|
||||
}
|
||||
|
||||
void RotateBy::Update()
|
||||
void RotateBy::Update(Node* target)
|
||||
{
|
||||
FiniteTimeAction::Update();
|
||||
FiniteTimeAction::Update(target);
|
||||
|
||||
if (target_)
|
||||
if (target)
|
||||
{
|
||||
target_->SetRotation(start_val_ + delta_val_ * delta_);
|
||||
target->SetRotation(start_val_ + delta_val_ * delta_);
|
||||
}
|
||||
}
|
||||
|
||||
RotateBy * RotateBy::Clone() const
|
||||
spAction RotateBy::Clone() const
|
||||
{
|
||||
return new RotateBy(duration_, delta_val_);
|
||||
return new (std::nothrow) RotateBy(duration_, delta_val_);
|
||||
}
|
||||
|
||||
RotateBy * RotateBy::Reverse() const
|
||||
spAction RotateBy::Reverse() const
|
||||
{
|
||||
return new RotateBy(duration_, -delta_val_);
|
||||
return new (std::nothrow) RotateBy(duration_, -delta_val_);
|
||||
}
|
||||
|
||||
RotateTo::RotateTo(float duration, float rotation)
|
||||
|
|
@ -401,14 +401,14 @@ namespace easy2d
|
|||
end_val_ = rotation;
|
||||
}
|
||||
|
||||
RotateTo * RotateTo::Clone() const
|
||||
spAction RotateTo::Clone() const
|
||||
{
|
||||
return new RotateTo(duration_, end_val_);
|
||||
return new (std::nothrow) RotateTo(duration_, end_val_);
|
||||
}
|
||||
|
||||
void RotateTo::Initialize()
|
||||
void RotateTo::Init(Node* target)
|
||||
{
|
||||
RotateBy::Initialize();
|
||||
RotateBy::Init(target);
|
||||
delta_val_ = end_val_ - start_val_;
|
||||
}
|
||||
|
||||
|
|
@ -429,14 +429,14 @@ namespace easy2d
|
|||
delta_ = 0;
|
||||
}
|
||||
|
||||
void Delay::Initialize()
|
||||
void Delay::Init(Node* target)
|
||||
{
|
||||
Action::Initialize();
|
||||
Action::Init(target);
|
||||
}
|
||||
|
||||
void Delay::Update()
|
||||
void Delay::Update(Node* target)
|
||||
{
|
||||
Action::Update();
|
||||
Action::Update(target);
|
||||
|
||||
delta_ = (time::Now() - started_).Seconds();
|
||||
|
||||
|
|
@ -452,13 +452,13 @@ namespace easy2d
|
|||
started_ = time::Now() - time::Second * delta_;
|
||||
}
|
||||
|
||||
Delay * Delay::Clone() const
|
||||
spAction Delay::Clone() const
|
||||
{
|
||||
return new Delay(delay_);
|
||||
return new (std::nothrow) Delay(delay_);
|
||||
}
|
||||
|
||||
Delay * Delay::Reverse() const
|
||||
spAction Delay::Reverse() const
|
||||
{
|
||||
return new Delay(delay_);
|
||||
return new (std::nothrow) Delay(delay_);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include "Action.h"
|
||||
#include "Action.hpp"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
@ -40,10 +40,10 @@ namespace easy2d
|
|||
|
||||
protected:
|
||||
// 初始化动作
|
||||
virtual void Initialize() override;
|
||||
virtual void Init(Node* target) override;
|
||||
|
||||
// 更新动作
|
||||
virtual void Update() override;
|
||||
virtual void Update(Node* target) override;
|
||||
|
||||
// 重置动作时间
|
||||
virtual void ResetTime() override;
|
||||
|
|
@ -67,17 +67,17 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual MoveBy * Clone() const override;
|
||||
virtual spAction Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual MoveBy * Reverse() const override;
|
||||
virtual spAction Reverse() const override;
|
||||
|
||||
protected:
|
||||
// 初始化动作
|
||||
virtual void Initialize() override;
|
||||
virtual void Init(Node* target) override;
|
||||
|
||||
// 更新动作
|
||||
virtual void Update() override;
|
||||
virtual void Update(Node* target) override;
|
||||
|
||||
protected:
|
||||
Point start_pos_;
|
||||
|
|
@ -99,10 +99,10 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual MoveTo * Clone() const override;
|
||||
virtual spAction Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual MoveTo * Reverse() const override
|
||||
virtual spAction Reverse() const override
|
||||
{
|
||||
E2D_WARNING("Reverse() not supported in MoveTo");
|
||||
return nullptr;
|
||||
|
|
@ -110,7 +110,7 @@ namespace easy2d
|
|||
|
||||
protected:
|
||||
// 初始化动作
|
||||
virtual void Initialize() override;
|
||||
virtual void Init(Node* target) override;
|
||||
|
||||
protected:
|
||||
Point end_pos_;
|
||||
|
|
@ -132,17 +132,17 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual JumpBy * Clone() const override;
|
||||
virtual spAction Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual JumpBy * Reverse() const override;
|
||||
virtual spAction Reverse() const override;
|
||||
|
||||
protected:
|
||||
// 初始化动作
|
||||
virtual void Initialize() override;
|
||||
virtual void Init(Node* target) override;
|
||||
|
||||
// 更新动作
|
||||
virtual void Update() override;
|
||||
virtual void Update(Node* target) override;
|
||||
|
||||
protected:
|
||||
Point start_pos_;
|
||||
|
|
@ -168,10 +168,10 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual JumpTo * Clone() const override;
|
||||
virtual spAction Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual JumpTo * Reverse() const override
|
||||
virtual spAction Reverse() const override
|
||||
{
|
||||
E2D_WARNING("Reverse() not supported in JumpTo");
|
||||
return nullptr;
|
||||
|
|
@ -179,7 +179,7 @@ namespace easy2d
|
|||
|
||||
protected:
|
||||
// 初始化动作
|
||||
virtual void Initialize() override;
|
||||
virtual void Init(Node* target) override;
|
||||
|
||||
protected:
|
||||
Point end_pos_;
|
||||
|
|
@ -205,17 +205,17 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual ScaleBy * Clone() const override;
|
||||
virtual spAction Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual ScaleBy * Reverse() const override;
|
||||
virtual spAction Reverse() const override;
|
||||
|
||||
protected:
|
||||
// 初始化动作
|
||||
virtual void Initialize() override;
|
||||
virtual void Init(Node* target) override;
|
||||
|
||||
// 更新动作
|
||||
virtual void Update() override;
|
||||
virtual void Update(Node* target) override;
|
||||
|
||||
protected:
|
||||
float start_scale_x_;
|
||||
|
|
@ -244,10 +244,10 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual ScaleTo * Clone() const override;
|
||||
virtual spAction Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual ScaleTo * Reverse() const override
|
||||
virtual spAction Reverse() const override
|
||||
{
|
||||
E2D_WARNING("Reverse() not supported in ScaleTo");
|
||||
return nullptr;
|
||||
|
|
@ -255,7 +255,7 @@ namespace easy2d
|
|||
|
||||
protected:
|
||||
// 初始化动作
|
||||
virtual void Initialize() override;
|
||||
virtual void Init(Node* target) override;
|
||||
|
||||
protected:
|
||||
float end_scale_x_;
|
||||
|
|
@ -276,17 +276,17 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual OpacityBy * Clone() const override;
|
||||
virtual spAction Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual OpacityBy * Reverse() const override;
|
||||
virtual spAction Reverse() const override;
|
||||
|
||||
protected:
|
||||
// 初始化动作
|
||||
virtual void Initialize() override;
|
||||
virtual void Init(Node* target) override;
|
||||
|
||||
// 更新动作
|
||||
virtual void Update() override;
|
||||
virtual void Update(Node* target) override;
|
||||
|
||||
protected:
|
||||
float start_val_;
|
||||
|
|
@ -307,10 +307,10 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual OpacityTo * Clone() const override;
|
||||
virtual spAction Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual OpacityTo * Reverse() const override
|
||||
virtual spAction Reverse() const override
|
||||
{
|
||||
E2D_WARNING("Reverse() not supported in OpacityTo");
|
||||
return nullptr;
|
||||
|
|
@ -318,7 +318,7 @@ namespace easy2d
|
|||
|
||||
protected:
|
||||
// 初始化动作
|
||||
virtual void Initialize() override;
|
||||
virtual void Init(Node* target) override;
|
||||
|
||||
protected:
|
||||
float end_val_;
|
||||
|
|
@ -366,17 +366,17 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual RotateBy * Clone() const override;
|
||||
virtual spAction Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual RotateBy * Reverse() const override;
|
||||
virtual spAction Reverse() const override;
|
||||
|
||||
protected:
|
||||
// 初始化动作
|
||||
virtual void Initialize() override;
|
||||
virtual void Init(Node* target) override;
|
||||
|
||||
// 更新动作
|
||||
virtual void Update() override;
|
||||
virtual void Update(Node* target) override;
|
||||
|
||||
protected:
|
||||
float start_val_;
|
||||
|
|
@ -397,10 +397,10 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual RotateTo * Clone() const override;
|
||||
virtual spAction Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual RotateTo * Reverse() const override
|
||||
virtual spAction Reverse() const override
|
||||
{
|
||||
E2D_WARNING("Reverse() not supported in RotateTo");
|
||||
return nullptr;
|
||||
|
|
@ -408,7 +408,7 @@ namespace easy2d
|
|||
|
||||
protected:
|
||||
// 初始化动作
|
||||
virtual void Initialize() override;
|
||||
virtual void Init(Node* target) override;
|
||||
|
||||
protected:
|
||||
float end_val_;
|
||||
|
|
@ -427,20 +427,20 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual Delay * Clone() const override;
|
||||
virtual spAction Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual Delay * Reverse() const override;
|
||||
virtual spAction Reverse() const override;
|
||||
|
||||
// 重置动作
|
||||
virtual void Reset() override;
|
||||
|
||||
protected:
|
||||
// 初始化动作
|
||||
virtual void Initialize() override;
|
||||
virtual void Init(Node* target) override;
|
||||
|
||||
// 更新动作
|
||||
virtual void Update() override;
|
||||
virtual void Update(Node* target) override;
|
||||
|
||||
// 重置动作时间
|
||||
virtual void ResetTime() override;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
Animate::Animate(Animation * animation)
|
||||
Animate::Animate(spAnimation const& animation)
|
||||
: frame_index_(0)
|
||||
, animation_(nullptr)
|
||||
{
|
||||
|
|
@ -42,43 +42,37 @@ namespace easy2d
|
|||
|
||||
Animate::~Animate()
|
||||
{
|
||||
SafeRelease(animation_);
|
||||
}
|
||||
|
||||
Animation * Animate::GetAnimation() const
|
||||
spAnimation Animate::GetAnimation() const
|
||||
{
|
||||
return animation_;
|
||||
}
|
||||
|
||||
void Animate::SetAnimation(Animation * animation)
|
||||
void Animate::SetAnimation(spAnimation const& animation)
|
||||
{
|
||||
if (animation && animation != animation_)
|
||||
{
|
||||
if (animation_)
|
||||
{
|
||||
animation_->Release();
|
||||
}
|
||||
animation_ = animation;
|
||||
animation_->Retain();
|
||||
frame_index_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Animate::Initialize()
|
||||
void Animate::Init(Node* target)
|
||||
{
|
||||
Action::Initialize();
|
||||
Action::Init(target);
|
||||
|
||||
auto target = dynamic_cast<Sprite*>(target_);
|
||||
if (target && animation_)
|
||||
auto sprite_target = dynamic_cast<Sprite*>(target);
|
||||
if (sprite_target && animation_)
|
||||
{
|
||||
target->Load(animation_->GetFrames()[frame_index_]);
|
||||
sprite_target->Load(animation_->GetFrames()[frame_index_]);
|
||||
++frame_index_;
|
||||
}
|
||||
}
|
||||
|
||||
void Animate::Update()
|
||||
void Animate::Update(Node* target)
|
||||
{
|
||||
Action::Update();
|
||||
Action::Update(target);
|
||||
|
||||
if (!animation_)
|
||||
{
|
||||
|
|
@ -89,11 +83,11 @@ namespace easy2d
|
|||
while ((time::Now() - started_).Seconds() >= animation_->GetInterval())
|
||||
{
|
||||
auto& frames = animation_->GetFrames();
|
||||
auto target = dynamic_cast<Sprite*>(target_);
|
||||
auto sprite_target = dynamic_cast<Sprite*>(target);
|
||||
|
||||
if (target)
|
||||
if (sprite_target)
|
||||
{
|
||||
target->Load(frames[frame_index_]);
|
||||
sprite_target->Load(frames[frame_index_]);
|
||||
}
|
||||
|
||||
started_ += time::Second * animation_->GetInterval();
|
||||
|
|
@ -118,23 +112,23 @@ namespace easy2d
|
|||
frame_index_ = 0;
|
||||
}
|
||||
|
||||
Animate * Animate::Clone() const
|
||||
spAction Animate::Clone() const
|
||||
{
|
||||
if (animation_)
|
||||
{
|
||||
return new Animate(animation_);
|
||||
return new (std::nothrow) Animate(animation_);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Animate * Animate::Reverse() const
|
||||
spAction Animate::Reverse() const
|
||||
{
|
||||
if (animation_)
|
||||
{
|
||||
auto animation = animation_->Reverse();
|
||||
if (animation)
|
||||
{
|
||||
return new Animate(animation);
|
||||
return new (std::nothrow) Animate(animation);
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
|
|
@ -169,10 +163,6 @@ namespace easy2d
|
|||
|
||||
Animation::~Animation()
|
||||
{
|
||||
for (auto frame : frames_)
|
||||
{
|
||||
SafeRelease(frame);
|
||||
}
|
||||
}
|
||||
|
||||
void Animation::SetInterval(float interval)
|
||||
|
|
@ -180,13 +170,12 @@ namespace easy2d
|
|||
interval_ = std::max(interval, 0.f);
|
||||
}
|
||||
|
||||
void Animation::Add(Image * frame)
|
||||
void Animation::Add(spImage const& frame)
|
||||
{
|
||||
E2D_WARNING_IF(frame == nullptr, "Animation::Add failed, frame Is nullptr.");
|
||||
E2D_WARNING_IF(!frame, "Animation::Add failed, frame Is nullptr.");
|
||||
if (frame)
|
||||
{
|
||||
frames_.push_back(frame);
|
||||
frame->Retain();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -203,14 +192,14 @@ namespace easy2d
|
|||
return interval_;
|
||||
}
|
||||
|
||||
const Animation::Images& Animation::GetFrames() const
|
||||
const Images& Animation::GetFrames() const
|
||||
{
|
||||
return frames_;
|
||||
}
|
||||
|
||||
Animation * Animation::Clone() const
|
||||
spAnimation Animation::Clone() const
|
||||
{
|
||||
auto animation = new Animation(interval_);
|
||||
auto animation = new (std::nothrow) Animation(interval_);
|
||||
if (animation)
|
||||
{
|
||||
for (const auto& frame : frames_)
|
||||
|
|
@ -221,26 +210,17 @@ namespace easy2d
|
|||
return animation;
|
||||
}
|
||||
|
||||
Animation * Animation::Reverse() const
|
||||
spAnimation Animation::Reverse() const
|
||||
{
|
||||
auto& oldFrames = this->GetFrames();
|
||||
Images frames(oldFrames.size());
|
||||
|
||||
if (!oldFrames.empty())
|
||||
auto animation = new (std::nothrow) Animation(interval_);
|
||||
if (!frames_.empty())
|
||||
{
|
||||
for (auto iter = oldFrames.crbegin(),
|
||||
iterCrend = oldFrames.crend();
|
||||
iter != iterCrend;
|
||||
++iter)
|
||||
for (auto iter = frames_.crbegin(), crend = frames_.crend(); iter != crend; ++iter)
|
||||
{
|
||||
Image* frame = *iter;
|
||||
if (frame)
|
||||
{
|
||||
frames.push_back(frame);
|
||||
if (*iter)
|
||||
animation->Add(*iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new Animation(this->GetInterval(), frames);
|
||||
return animation;
|
||||
}
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include "Action.h"
|
||||
#include "Action.hpp"
|
||||
#include "Image.h"
|
||||
|
||||
namespace easy2d
|
||||
|
|
@ -31,8 +31,6 @@ namespace easy2d
|
|||
E2D_DISABLE_COPY(Animation);
|
||||
|
||||
public:
|
||||
typedef std::vector<Image*> Images;
|
||||
|
||||
Animation();
|
||||
|
||||
explicit Animation(
|
||||
|
|
@ -52,7 +50,7 @@ namespace easy2d
|
|||
|
||||
// 添加关键帧
|
||||
void Add(
|
||||
Image * frame /* ¹Ø¼üÖ¡ */
|
||||
spImage const& frame /* ¹Ø¼üÖ¡ */
|
||||
);
|
||||
|
||||
// 添加多个关键帧
|
||||
|
|
@ -72,10 +70,10 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取帧动画的拷贝对象
|
||||
Animation * Clone() const;
|
||||
spAnimation Clone() const;
|
||||
|
||||
// 获取帧动画的倒转
|
||||
Animation * Reverse() const;
|
||||
spAnimation Reverse() const;
|
||||
|
||||
protected:
|
||||
float interval_;
|
||||
|
|
@ -93,40 +91,40 @@ namespace easy2d
|
|||
Animate();
|
||||
|
||||
explicit Animate(
|
||||
Animation * animation
|
||||
spAnimation const& animation
|
||||
);
|
||||
|
||||
virtual ~Animate();
|
||||
|
||||
// 获取动画
|
||||
virtual Animation * GetAnimation() const;
|
||||
spAnimation GetAnimation() const;
|
||||
|
||||
// 设置动画
|
||||
virtual void SetAnimation(
|
||||
Animation * animation
|
||||
void SetAnimation(
|
||||
spAnimation const& animation
|
||||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual Animate * Clone() const override;
|
||||
virtual spAction Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual Animate * Reverse() const override;
|
||||
virtual spAction Reverse() const override;
|
||||
|
||||
// 重置动作
|
||||
virtual void Reset() override;
|
||||
|
||||
protected:
|
||||
// 初始化动作
|
||||
virtual void Initialize() override;
|
||||
virtual void Init(Node* target) override;
|
||||
|
||||
// 更新动作
|
||||
virtual void Update() override;
|
||||
virtual void Update(Node* target) override;
|
||||
|
||||
// 重置动作时间
|
||||
virtual void ResetTime() override;
|
||||
|
||||
protected:
|
||||
UINT frame_index_;
|
||||
Animation * animation_;
|
||||
spAnimation animation_;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@
|
|||
|
||||
#pragma once
|
||||
#include "macros.h"
|
||||
#include "../math/vector.hpp"
|
||||
#include "Color.h"
|
||||
#include "Size.h"
|
||||
#include "Rect.hpp"
|
||||
#include "../math/vector.hpp"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,21 +27,21 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
CallFunc * CallFunc::Clone() const
|
||||
spAction CallFunc::Clone() const
|
||||
{
|
||||
return new CallFunc(callback_);
|
||||
}
|
||||
|
||||
CallFunc * CallFunc::Reverse() const
|
||||
spAction CallFunc::Reverse() const
|
||||
{
|
||||
return new CallFunc(callback_);
|
||||
}
|
||||
|
||||
void CallFunc::Initialize()
|
||||
void CallFunc::Init(Node*)
|
||||
{
|
||||
}
|
||||
|
||||
void CallFunc::Update()
|
||||
void CallFunc::Update(Node*)
|
||||
{
|
||||
callback_();
|
||||
this->Stop();
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include "Action.h"
|
||||
#include "Action.hpp"
|
||||
#include <functional>
|
||||
|
||||
namespace easy2d
|
||||
|
|
@ -38,17 +38,17 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual CallFunc *Clone() const override;
|
||||
virtual spAction Clone() const override;
|
||||
|
||||
// 获取该动作的倒转
|
||||
virtual CallFunc *Reverse() const override;
|
||||
virtual spAction Reverse() const override;
|
||||
|
||||
protected:
|
||||
// 初始化动作
|
||||
virtual void Initialize() override;
|
||||
virtual void Init(Node*) override;
|
||||
|
||||
// 更新动作
|
||||
virtual void Update() override;
|
||||
virtual void Update(Node*) override;
|
||||
|
||||
protected:
|
||||
Callback callback_;
|
||||
|
|
|
|||
|
|
@ -39,33 +39,37 @@ namespace easy2d
|
|||
, curr_scene_(nullptr)
|
||||
, next_scene_(nullptr)
|
||||
, transition_(nullptr)
|
||||
, debug_mode_(false)
|
||||
, debug_enabled_(false)
|
||||
, initialized_(false)
|
||||
{
|
||||
::CoInitialize(nullptr);
|
||||
}
|
||||
|
||||
Game::Game(Options const & options)
|
||||
: Game()
|
||||
{
|
||||
Init(options);
|
||||
}
|
||||
|
||||
Game::~Game()
|
||||
{
|
||||
SafeRelease(transition_);
|
||||
SafeRelease(curr_scene_);
|
||||
SafeRelease(next_scene_);
|
||||
|
||||
::CoUninitialize();
|
||||
}
|
||||
|
||||
void Game::Initialize(const Options& options)
|
||||
void Game::Init(const Options& options)
|
||||
{
|
||||
debug_mode_ = options.debug;
|
||||
if (initialized_)
|
||||
return;
|
||||
|
||||
Window::Instance().Initialize(options.title, options.width, options.height, options.icon, debug_mode_);
|
||||
devices::Graphics::Instance().Initialize(Window::Instance().GetHandle(), debug_mode_);
|
||||
devices::Input::Instance().Initialize(debug_mode_);
|
||||
devices::Audio::Instance().Initialize(debug_mode_);
|
||||
debug_enabled_ = options.debug;
|
||||
|
||||
Window::Instance().Init(options.title, options.width, options.height, options.icon, debug_enabled_);
|
||||
devices::Graphics::Instance().Init(Window::Instance().GetHandle(), debug_enabled_);
|
||||
devices::Input::Instance().Init(debug_enabled_);
|
||||
devices::Audio::Instance().Init(debug_enabled_);
|
||||
|
||||
// 若开启了调试模式,打开控制台
|
||||
HWND console = ::GetConsoleWindow();
|
||||
// 关闭控制台
|
||||
if (debug_mode_)
|
||||
if (debug_enabled_)
|
||||
{
|
||||
if (console == nullptr)
|
||||
{
|
||||
|
|
@ -97,6 +101,8 @@ namespace easy2d
|
|||
GWLP_USERDATA,
|
||||
PtrToUlong(this)
|
||||
);
|
||||
|
||||
initialized_ = true;
|
||||
}
|
||||
|
||||
void Game::Run()
|
||||
|
|
@ -110,12 +116,13 @@ namespace easy2d
|
|||
next_scene_ = nullptr;
|
||||
}
|
||||
|
||||
::ShowWindow(Window::Instance().GetHandle(), SW_SHOWNORMAL);
|
||||
::UpdateWindow(Window::Instance().GetHandle());
|
||||
const auto& window = Window::Instance();
|
||||
::ShowWindow(window.GetHandle(), SW_SHOWNORMAL);
|
||||
::UpdateWindow(window.GetHandle());
|
||||
|
||||
const int64_t min_interval = 5;
|
||||
auto last = time::Now();
|
||||
MSG msg = { 0 };
|
||||
MSG msg = {};
|
||||
|
||||
while (!quit_)
|
||||
{
|
||||
|
|
@ -128,12 +135,11 @@ namespace easy2d
|
|||
last = now;
|
||||
|
||||
devices::Input::Instance().Update(
|
||||
Window::Instance().GetHandle(),
|
||||
Window::Instance().GetContentScaleX(),
|
||||
Window::Instance().GetContentScaleY()
|
||||
window.GetHandle(),
|
||||
window.GetContentScaleX(),
|
||||
window.GetContentScaleY()
|
||||
);
|
||||
|
||||
OnUpdate(dt);
|
||||
UpdateScene(dt);
|
||||
DrawScene();
|
||||
|
||||
|
|
@ -162,9 +168,9 @@ namespace easy2d
|
|||
quit_ = true;
|
||||
}
|
||||
|
||||
void Game::EnterScene(Scene * scene, Transition * transition)
|
||||
void Game::EnterScene(spScene const& scene, spTransition const& transition)
|
||||
{
|
||||
if (scene == nullptr)
|
||||
if (!scene)
|
||||
{
|
||||
E2D_WARNING("Next scene is null pointer!");
|
||||
return;
|
||||
|
|
@ -172,45 +178,37 @@ namespace easy2d
|
|||
|
||||
if (curr_scene_ == scene) { return; }
|
||||
|
||||
if (next_scene_)
|
||||
{
|
||||
next_scene_->Release();
|
||||
}
|
||||
next_scene_ = scene;
|
||||
next_scene_->Retain();
|
||||
|
||||
if (transition)
|
||||
{
|
||||
if (transition_)
|
||||
{
|
||||
transition_->Stop();
|
||||
transition_->Release();
|
||||
}
|
||||
transition_ = transition;
|
||||
transition_->Retain();
|
||||
|
||||
transition_->Initialize(curr_scene_, next_scene_, this);
|
||||
transition_->Init(curr_scene_, next_scene_);
|
||||
}
|
||||
}
|
||||
|
||||
Scene * Game::GetCurrentScene()
|
||||
spScene const& Game::GetCurrentScene()
|
||||
{
|
||||
return curr_scene_;
|
||||
}
|
||||
|
||||
bool Game::IsTransitioning() const
|
||||
{
|
||||
return transition_ != nullptr;
|
||||
return transition_;
|
||||
}
|
||||
|
||||
void Game::UpdateScene(float dt)
|
||||
{
|
||||
auto update = [&](Scene * scene) -> void
|
||||
auto update = [&](spScene const& scene) -> void
|
||||
{
|
||||
if (scene)
|
||||
{
|
||||
scene->OnUpdate(dt);
|
||||
Node * root = scene->GetRoot();
|
||||
spNode const& root = scene->GetRoot();
|
||||
if (root)
|
||||
{
|
||||
root->UpdateChildren(dt);
|
||||
|
|
@ -227,7 +225,6 @@ namespace easy2d
|
|||
|
||||
if (transition_->IsDone())
|
||||
{
|
||||
transition_->Release();
|
||||
transition_ = nullptr;
|
||||
}
|
||||
else
|
||||
|
|
@ -241,7 +238,6 @@ namespace easy2d
|
|||
if (curr_scene_)
|
||||
{
|
||||
curr_scene_->OnExit();
|
||||
curr_scene_->Release();
|
||||
}
|
||||
|
||||
next_scene_->OnEnter();
|
||||
|
|
@ -265,7 +261,7 @@ namespace easy2d
|
|||
curr_scene_->Draw();
|
||||
}
|
||||
|
||||
if (debug_mode_)
|
||||
if (debug_enabled_)
|
||||
{
|
||||
if (curr_scene_ && curr_scene_->GetRoot())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,12 +21,11 @@
|
|||
#pragma once
|
||||
#include "base.h"
|
||||
#include "window.h"
|
||||
#include "Scene.h"
|
||||
#include "Transition.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
class Scene;
|
||||
class Transition;
|
||||
|
||||
struct Options
|
||||
{
|
||||
String title; /* 标题 */
|
||||
|
|
@ -52,10 +51,11 @@ namespace easy2d
|
|||
public:
|
||||
Game();
|
||||
|
||||
virtual ~Game();
|
||||
Game(
|
||||
Options const& options
|
||||
);
|
||||
|
||||
// 更新时
|
||||
virtual void OnUpdate(float dt) {}
|
||||
virtual ~Game();
|
||||
|
||||
// 退出时
|
||||
virtual void OnExit() {}
|
||||
|
|
@ -65,8 +65,8 @@ namespace easy2d
|
|||
virtual bool OnClose() { return true; }
|
||||
|
||||
// 初始化
|
||||
void Initialize(
|
||||
const Options& options /* 属性 */
|
||||
void Init(
|
||||
Options const& options
|
||||
);
|
||||
|
||||
// 运行
|
||||
|
|
@ -77,29 +77,27 @@ namespace easy2d
|
|||
|
||||
// 切换场景
|
||||
void EnterScene(
|
||||
Scene * scene, /* 场景 */
|
||||
Transition * transition = nullptr /* 场景动画 */
|
||||
spScene const& scene, /* 场景 */
|
||||
spTransition const& transition = nullptr /* 场景动画 */
|
||||
);
|
||||
|
||||
// 获取当前场景
|
||||
Scene * GetCurrentScene();
|
||||
spScene const& GetCurrentScene();
|
||||
|
||||
// 是否正在进行场景过渡
|
||||
bool IsTransitioning() const;
|
||||
|
||||
// 渲染场景画面
|
||||
void DrawScene();
|
||||
|
||||
// 更新场景
|
||||
void UpdateScene(
|
||||
float dt
|
||||
);
|
||||
|
||||
private:
|
||||
bool debug_mode_;
|
||||
bool initialized_;
|
||||
bool debug_enabled_;
|
||||
bool quit_;
|
||||
Scene* curr_scene_;
|
||||
Scene* next_scene_;
|
||||
Transition* transition_;
|
||||
spScene curr_scene_;
|
||||
spScene next_scene_;
|
||||
spTransition transition_;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,10 +192,7 @@ namespace easy2d
|
|||
if (bitmap_ == bitmap)
|
||||
return;
|
||||
|
||||
if (bitmap_)
|
||||
{
|
||||
bitmap_->Release();
|
||||
}
|
||||
SafeRelease(bitmap_);
|
||||
|
||||
if (bitmap)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
#pragma once
|
||||
#include "base.h"
|
||||
#include "Resource.h"
|
||||
#include "RefCounter.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
void InputDevice::Initialize(bool debug)
|
||||
void InputDevice::Init(bool debug)
|
||||
{
|
||||
if (initialized)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace easy2d
|
|||
E2D_DISABLE_COPY(InputDevice);
|
||||
|
||||
public:
|
||||
void Initialize(bool debug);
|
||||
void Init(bool debug);
|
||||
|
||||
// 检测键盘某按键是否正被按下
|
||||
bool IsDown(
|
||||
|
|
|
|||
|
|
@ -0,0 +1,176 @@
|
|||
// Copyright (c) 2016-2018 Easy2D - Nomango
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining lhs 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 <cassert>
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
template <typename T>
|
||||
class IntrusivePtr
|
||||
{
|
||||
using ElemType = T;
|
||||
|
||||
ElemType* ptr_{ nullptr };
|
||||
|
||||
public:
|
||||
IntrusivePtr() {}
|
||||
|
||||
IntrusivePtr(nullptr_t) {}
|
||||
|
||||
IntrusivePtr(ElemType* p) : ptr_(p)
|
||||
{
|
||||
IntrusivePtrAddRef(ptr_);
|
||||
}
|
||||
|
||||
IntrusivePtr(const IntrusivePtr& other) : ptr_(other.ptr_)
|
||||
{
|
||||
IntrusivePtrAddRef(ptr_);
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
IntrusivePtr(const IntrusivePtr<U>& other) : ptr_(other.Get())
|
||||
{
|
||||
IntrusivePtrAddRef(ptr_);
|
||||
}
|
||||
|
||||
IntrusivePtr(IntrusivePtr&& other) : ptr_(::std::move(other.ptr_)) {}
|
||||
|
||||
~IntrusivePtr()
|
||||
{
|
||||
IntrusivePtrRelease(ptr_);
|
||||
}
|
||||
|
||||
inline ElemType* Get() const { return ptr_; }
|
||||
|
||||
inline void Swap(IntrusivePtr& other)
|
||||
{
|
||||
::std::swap(ptr_, other.ptr_);
|
||||
}
|
||||
|
||||
inline ElemType* operator ->() const
|
||||
{
|
||||
assert(ptr_ && ptr_->GetRefCount() > 0 &&
|
||||
"Invalid pointer!");
|
||||
return ptr_;
|
||||
}
|
||||
|
||||
inline ElemType& operator *() const
|
||||
{
|
||||
assert(ptr_ && ptr_->GetRefCount() > 0 &&
|
||||
"Invalid pointer!");
|
||||
return *ptr_;
|
||||
}
|
||||
|
||||
inline operator bool() const { return ptr_ != nullptr; }
|
||||
|
||||
inline bool operator !() const { return ptr_ == 0; }
|
||||
|
||||
inline IntrusivePtr& operator =(const IntrusivePtr& other)
|
||||
{
|
||||
IntrusivePtr(other).Swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline IntrusivePtr& operator =(ElemType* p)
|
||||
{
|
||||
IntrusivePtr(p).Swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline IntrusivePtr& operator =(nullptr_t)
|
||||
{
|
||||
IntrusivePtr{}.Swap(*this);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, class U>
|
||||
inline bool operator==(IntrusivePtr<T> const& lhs, IntrusivePtr<U> const& rhs)
|
||||
{
|
||||
return lhs.Get() == rhs.Get();
|
||||
}
|
||||
|
||||
template<class T, class U>
|
||||
inline bool operator!=(IntrusivePtr<T> const& lhs, IntrusivePtr<U> const& rhs)
|
||||
{
|
||||
return lhs.Get() != rhs.Get();
|
||||
}
|
||||
|
||||
template<class T, class U>
|
||||
inline bool operator<(IntrusivePtr<T> const& lhs, IntrusivePtr<U> const& rhs)
|
||||
{
|
||||
return lhs.Get() < rhs.Get();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool operator==(IntrusivePtr<T> const& lhs, T* rhs)
|
||||
{
|
||||
return lhs.Get() == rhs;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool operator!=(IntrusivePtr<T> const& lhs, T* rhs)
|
||||
{
|
||||
return lhs.Get() != rhs;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool operator==(T* lhs, IntrusivePtr<T> const& rhs)
|
||||
{
|
||||
return lhs == rhs.Get();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool operator!=(T* lhs, IntrusivePtr<T> const& rhs)
|
||||
{
|
||||
return lhs != rhs.Get();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool operator==(IntrusivePtr<T> const& lhs, nullptr_t)
|
||||
{
|
||||
return !static_cast<bool>(lhs);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool operator!=(IntrusivePtr<T> const& lhs, nullptr_t)
|
||||
{
|
||||
return static_cast<bool>(lhs);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool operator==(nullptr_t, IntrusivePtr<T> const& rhs)
|
||||
{
|
||||
return !static_cast<bool>(rhs);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool operator!=(nullptr_t, IntrusivePtr<T> const& rhs)
|
||||
{
|
||||
return static_cast<bool>(rhs);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline IntrusivePtr<T> make_intrusive(T* ptr)
|
||||
{
|
||||
return IntrusivePtr<T>(ptr);
|
||||
}
|
||||
}
|
||||
|
|
@ -21,7 +21,6 @@
|
|||
#pragma once
|
||||
#include "base.h"
|
||||
#include "audio.h"
|
||||
#include "RefCounter.h"
|
||||
#include "Resource.h"
|
||||
#include <xaudio2.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
#include "Node.h"
|
||||
#include "Scene.h"
|
||||
#include "Task.h"
|
||||
#include "Action.h"
|
||||
#include "Action.hpp"
|
||||
#include "time.h"
|
||||
#include "render.h"
|
||||
#include <iterator>
|
||||
|
|
@ -31,7 +31,6 @@ namespace easy2d
|
|||
Node::Node()
|
||||
: visible_(true)
|
||||
, parent_(nullptr)
|
||||
, parent_scene_(nullptr)
|
||||
, hash_name_(0)
|
||||
, clip_enabled_(false)
|
||||
, dirty_sort_(false)
|
||||
|
|
@ -53,21 +52,6 @@ namespace easy2d
|
|||
Node::~Node()
|
||||
{
|
||||
SafeRelease(border_);
|
||||
|
||||
for (auto action : actions_)
|
||||
{
|
||||
SafeRelease(action);
|
||||
}
|
||||
|
||||
for (auto task : tasks_)
|
||||
{
|
||||
SafeRelease(task);
|
||||
}
|
||||
|
||||
for (auto child : children_)
|
||||
{
|
||||
SafeRelease(child);
|
||||
}
|
||||
}
|
||||
|
||||
void Node::Visit()
|
||||
|
|
@ -93,7 +77,7 @@ namespace easy2d
|
|||
std::sort(
|
||||
std::begin(children_),
|
||||
std::end(children_),
|
||||
[](Node * n1, Node * n2) { return n1->GetOrder() < n2->GetOrder(); }
|
||||
[](spNode const& n1, spNode const& n2) { return n1->GetOrder() < n2->GetOrder(); }
|
||||
);
|
||||
|
||||
dirty_sort_ = false;
|
||||
|
|
@ -202,11 +186,6 @@ namespace easy2d
|
|||
initial_matrix_ = initial_matrix_ * parent_->initial_matrix_;
|
||||
final_matrix_ = final_matrix_ * parent_->initial_matrix_;
|
||||
}
|
||||
else if (parent_scene_)
|
||||
{
|
||||
initial_matrix_ = initial_matrix_ * parent_scene_->GetTransform();
|
||||
final_matrix_ = final_matrix_ * parent_scene_->GetTransform();
|
||||
}
|
||||
|
||||
// 重新构造轮廓
|
||||
SafeRelease(border_);
|
||||
|
|
@ -269,25 +248,24 @@ namespace easy2d
|
|||
if (actions_.empty())
|
||||
return;
|
||||
|
||||
std::vector<Action*> currActions;
|
||||
std::vector<spAction> currActions;
|
||||
currActions.reserve(actions_.size());
|
||||
std::copy_if(
|
||||
actions_.begin(),
|
||||
actions_.end(),
|
||||
std::back_inserter(currActions),
|
||||
[](Action* action) { return action->IsRunning() && !action->IsDone(); }
|
||||
[](spAction action) { return action->IsRunning() && !action->IsDone(); }
|
||||
);
|
||||
|
||||
// 遍历所有正在运行的动作
|
||||
for (const auto& action : currActions)
|
||||
action->Update();
|
||||
action->Update(this);
|
||||
|
||||
// 清除完成的动作
|
||||
for (auto iter = actions_.begin(); iter != actions_.end();)
|
||||
{
|
||||
if ((*iter)->IsDone())
|
||||
{
|
||||
(*iter)->Release();
|
||||
iter = actions_.erase(iter);
|
||||
}
|
||||
else
|
||||
|
|
@ -574,18 +552,18 @@ namespace easy2d
|
|||
border_color_ = color;
|
||||
}
|
||||
|
||||
void Node::AddChild(Node * child, int order)
|
||||
void Node::AddChild(spNode const& child, int order)
|
||||
{
|
||||
E2D_WARNING_IF(child == nullptr, "Node::AddChild NULL pointer exception.");
|
||||
E2D_WARNING_IF(!child, "Node::AddChild NULL pointer exception.");
|
||||
|
||||
if (child)
|
||||
{
|
||||
if (child->parent_ != nullptr)
|
||||
if (child->parent_)
|
||||
{
|
||||
throw std::runtime_error("节点已有父节点, 不能再添加到其他节点");
|
||||
}
|
||||
|
||||
for (Node * parent = this; parent != nullptr; parent = parent->GetParent())
|
||||
for (Node * parent = this; parent; parent = parent->GetParent().Get())
|
||||
{
|
||||
if (child == parent)
|
||||
{
|
||||
|
|
@ -593,14 +571,9 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
child->Retain();
|
||||
children_.push_back(child);
|
||||
child->SetOrder(order);
|
||||
child->parent_ = this;
|
||||
if (this->parent_scene_)
|
||||
{
|
||||
child->SetParentScene(this->parent_scene_);
|
||||
}
|
||||
|
||||
// 更新子节点透明度
|
||||
child->UpdateOpacity();
|
||||
|
|
@ -619,17 +592,12 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
Node * Node::GetParent() const
|
||||
spNode Node::GetParent() const
|
||||
{
|
||||
return parent_;
|
||||
}
|
||||
|
||||
Scene * Node::GetParentScene() const
|
||||
{
|
||||
return parent_scene_;
|
||||
}
|
||||
|
||||
Node::Nodes Node::GetChildren(const String& name) const
|
||||
Nodes Node::GetChildren(const String& name) const
|
||||
{
|
||||
Nodes children;
|
||||
size_t hash_code = std::hash<String>{}(name);
|
||||
|
|
@ -645,7 +613,7 @@ namespace easy2d
|
|||
return children;
|
||||
}
|
||||
|
||||
Node * Node::GetChild(const String& name) const
|
||||
spNode Node::GetChild(const String& name) const
|
||||
{
|
||||
size_t hash_code = std::hash<String>{}(name);
|
||||
|
||||
|
|
@ -660,7 +628,7 @@ namespace easy2d
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
const std::vector<Node*>& Node::GetAllChildren() const
|
||||
const std::vector<spNode>& Node::GetAllChildren() const
|
||||
{
|
||||
return children_;
|
||||
}
|
||||
|
|
@ -678,9 +646,9 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
bool Node::RemoveChild(Node * child)
|
||||
bool Node::RemoveChild(spNode const& child)
|
||||
{
|
||||
E2D_WARNING_IF(child == nullptr, "Node::RemoveChildren NULL pointer exception.");
|
||||
E2D_WARNING_IF(!child, "Node::RemoveChildren NULL pointer exception.");
|
||||
|
||||
if (children_.empty())
|
||||
{
|
||||
|
|
@ -694,13 +662,6 @@ namespace easy2d
|
|||
{
|
||||
children_.erase(iter);
|
||||
child->parent_ = nullptr;
|
||||
|
||||
if (child->parent_scene_)
|
||||
{
|
||||
child->SetParentScene(nullptr);
|
||||
}
|
||||
|
||||
child->Release();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -720,11 +681,6 @@ namespace easy2d
|
|||
if ((*iter)->hash_name_ == hash_code && (*iter)->name_ == child_name)
|
||||
{
|
||||
(*iter)->parent_ = nullptr;
|
||||
if ((*iter)->parent_scene_)
|
||||
{
|
||||
(*iter)->SetParentScene(nullptr);
|
||||
}
|
||||
(*iter)->Release();
|
||||
iter = children_.erase(iter);
|
||||
}
|
||||
else
|
||||
|
|
@ -736,36 +692,22 @@ namespace easy2d
|
|||
|
||||
void Node::RemoveAllChildren()
|
||||
{
|
||||
// 所有节点的引用计数减一
|
||||
for (const auto& child : children_)
|
||||
{
|
||||
child->Release();
|
||||
}
|
||||
// 清空储存节点的容器
|
||||
children_.clear();
|
||||
}
|
||||
|
||||
void Node::RunAction(Action * action)
|
||||
void Node::RunAction(spAction const& action)
|
||||
{
|
||||
E2D_WARNING_IF(action == nullptr, "Action NULL pointer exception!");
|
||||
E2D_WARNING_IF(!action, "Action NULL pointer exception!");
|
||||
|
||||
if (action)
|
||||
{
|
||||
if (action->GetTarget() == nullptr)
|
||||
{
|
||||
auto iter = std::find(actions_.begin(), actions_.end(), action);
|
||||
if (iter == actions_.end())
|
||||
{
|
||||
action->Retain();
|
||||
action->StartWithTarget(this);
|
||||
action->Start();
|
||||
actions_.push_back(action);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("该 Action 已有执行目标");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Node::ResumeAction(const String& name)
|
||||
|
|
@ -828,7 +770,7 @@ namespace easy2d
|
|||
return ret != 0;
|
||||
}
|
||||
|
||||
bool Node::Intersects(Node * node)
|
||||
bool Node::Intersects(spNode const& node)
|
||||
{
|
||||
if (transform_.size.width == 0.f || transform_.size.height == 0.f || node->transform_.size.width == 0.f || node->transform_.size.height == 0.f)
|
||||
return false;
|
||||
|
|
@ -883,19 +825,18 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
const Node::Actions & Node::GetAllActions() const
|
||||
const Actions& Node::GetAllActions() const
|
||||
{
|
||||
return actions_;
|
||||
}
|
||||
|
||||
void Node::AddTask(Task * task)
|
||||
void Node::AddTask(spTask const& task)
|
||||
{
|
||||
if (task)
|
||||
{
|
||||
auto iter = std::find(tasks_.begin(), tasks_.end(), task);
|
||||
if (iter == tasks_.end())
|
||||
{
|
||||
task->Retain();
|
||||
task->last_time_ = time::Now();
|
||||
tasks_.push_back(task);
|
||||
}
|
||||
|
|
@ -959,7 +900,7 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
const Node::Tasks & Node::GetAllTasks() const
|
||||
const Tasks & Node::GetAllTasks() const
|
||||
{
|
||||
return tasks_;
|
||||
}
|
||||
|
|
@ -969,13 +910,13 @@ namespace easy2d
|
|||
if (tasks_.empty())
|
||||
return;
|
||||
|
||||
std::vector<Task*> currTasks;
|
||||
std::vector<spTask> currTasks;
|
||||
currTasks.reserve(tasks_.size());
|
||||
std::copy_if(
|
||||
tasks_.begin(),
|
||||
tasks_.end(),
|
||||
std::back_inserter(currTasks),
|
||||
[](Task* task) { return task->IsReady() && !task->stopped_; }
|
||||
[](spTask const& task) { return task->IsReady() && !task->stopped_; }
|
||||
);
|
||||
|
||||
// 遍历就绪的任务
|
||||
|
|
@ -987,7 +928,6 @@ namespace easy2d
|
|||
{
|
||||
if ((*iter)->stopped_)
|
||||
{
|
||||
(*iter)->Release();
|
||||
iter = tasks_.erase(iter);
|
||||
}
|
||||
else
|
||||
|
|
@ -1030,13 +970,4 @@ namespace easy2d
|
|||
hash_name_ = std::hash<String>{}(name);
|
||||
}
|
||||
}
|
||||
|
||||
void Node::SetParentScene(Scene * scene)
|
||||
{
|
||||
parent_scene_ = scene;
|
||||
for (const auto& child : children_)
|
||||
{
|
||||
child->SetParentScene(scene);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
#pragma once
|
||||
#include "base.h"
|
||||
#include "RefCounter.h"
|
||||
#include "KeyEvent.h"
|
||||
#include "MouseEvent.h"
|
||||
#include "../math/Transform.h"
|
||||
|
|
@ -43,10 +42,6 @@ namespace easy2d
|
|||
E2D_DISABLE_COPY(Node);
|
||||
|
||||
public:
|
||||
typedef std::vector<Node*> Nodes;
|
||||
typedef std::vector<Action*> Actions;
|
||||
typedef std::vector<Task*> Tasks;
|
||||
|
||||
Node();
|
||||
|
||||
virtual ~Node();
|
||||
|
|
@ -121,10 +116,7 @@ namespace easy2d
|
|||
float GetDisplayOpacity() const;
|
||||
|
||||
// 获取父节点
|
||||
Node * GetParent() const;
|
||||
|
||||
// 获取节点所在场景
|
||||
Scene * GetParentScene() const;
|
||||
spNode GetParent() const;
|
||||
|
||||
// 设置节点是否显示
|
||||
void SetVisible(
|
||||
|
|
@ -292,12 +284,12 @@ namespace easy2d
|
|||
|
||||
// 判断两物体是否相交
|
||||
bool Intersects(
|
||||
Node * node
|
||||
spNode const& node
|
||||
);
|
||||
|
||||
// 添加子节点
|
||||
void AddChild(
|
||||
Node * child,
|
||||
spNode const& child,
|
||||
int order = 0 /* 渲染顺序 */
|
||||
);
|
||||
|
||||
|
|
@ -313,7 +305,7 @@ namespace easy2d
|
|||
) const;
|
||||
|
||||
// 获取名称相同的子节点
|
||||
Node* GetChild(
|
||||
spNode GetChild(
|
||||
const String& name
|
||||
) const;
|
||||
|
||||
|
|
@ -325,7 +317,7 @@ namespace easy2d
|
|||
|
||||
// 移除子节点
|
||||
bool RemoveChild(
|
||||
Node * child
|
||||
spNode const& child
|
||||
);
|
||||
|
||||
// 移除所有名称相同的子节点
|
||||
|
|
@ -341,7 +333,7 @@ namespace easy2d
|
|||
|
||||
// 执行动作
|
||||
void RunAction(
|
||||
Action * action
|
||||
spAction const& action
|
||||
);
|
||||
|
||||
// 继续动作
|
||||
|
|
@ -373,7 +365,7 @@ namespace easy2d
|
|||
|
||||
// 添加任务
|
||||
void AddTask(
|
||||
Task * task
|
||||
spTask const& task
|
||||
);
|
||||
|
||||
// 启动任务
|
||||
|
|
@ -423,11 +415,6 @@ namespace easy2d
|
|||
// 渲染节点边缘
|
||||
void DrawBorder();
|
||||
|
||||
// 设置节点所在场景
|
||||
void SetParentScene(
|
||||
Scene * scene
|
||||
);
|
||||
|
||||
// 更新子节点
|
||||
void UpdateChildren(float dt);
|
||||
|
||||
|
|
@ -456,7 +443,6 @@ namespace easy2d
|
|||
bool clip_enabled_;
|
||||
bool dirty_sort_;
|
||||
bool dirty_transform_;
|
||||
Scene* parent_scene_;
|
||||
Node* parent_;
|
||||
Color border_color_;
|
||||
Actions actions_;
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@
|
|||
namespace easy2d
|
||||
{
|
||||
RefCounter::RefCounter()
|
||||
: ref_count_(0)
|
||||
{
|
||||
ref_count_ = 0;
|
||||
}
|
||||
|
||||
RefCounter::~RefCounter()
|
||||
|
|
@ -33,20 +33,12 @@ namespace easy2d
|
|||
|
||||
long RefCounter::Retain()
|
||||
{
|
||||
return ::InterlockedIncrement(&ref_count_);
|
||||
|
||||
}
|
||||
|
||||
long RefCounter::Release()
|
||||
{
|
||||
long new_count = ::InterlockedDecrement(&ref_count_);
|
||||
|
||||
if (new_count <= 0)
|
||||
{
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return new_count;
|
||||
}
|
||||
|
||||
long RefCounter::GetRefCount() const
|
||||
|
|
|
|||
|
|
@ -23,24 +23,39 @@
|
|||
|
||||
namespace easy2d
|
||||
{
|
||||
// 引用计数
|
||||
class RefCounter
|
||||
{
|
||||
public:
|
||||
RefCounter();
|
||||
E2D_DISABLE_COPY(RefCounter);
|
||||
|
||||
virtual ~RefCounter();
|
||||
public:
|
||||
RefCounter() : ref_count_(0) {}
|
||||
|
||||
virtual ~RefCounter() {}
|
||||
|
||||
// 增加引用计数
|
||||
long Retain();
|
||||
inline void Retain() { ::InterlockedIncrement(&ref_count_); }
|
||||
|
||||
// 减少引用计数
|
||||
long Release();
|
||||
inline void Release()
|
||||
{
|
||||
if (::InterlockedDecrement(&ref_count_) <= 0)
|
||||
delete this;
|
||||
}
|
||||
|
||||
// 获取引用计数
|
||||
long GetRefCount() const;
|
||||
inline long GetRefCount() const { return ref_count_; }
|
||||
|
||||
private:
|
||||
long ref_count_;
|
||||
};
|
||||
|
||||
inline void IntrusivePtrAddRef(RefCounter* ptr)
|
||||
{
|
||||
if (ptr) ptr->Retain();
|
||||
}
|
||||
|
||||
inline void IntrusivePtrRelease(RefCounter* ptr)
|
||||
{
|
||||
if (ptr) ptr->Release();
|
||||
}
|
||||
}
|
||||
|
|
@ -29,7 +29,7 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
Scene::Scene(Node * root)
|
||||
Scene::Scene(spNode const& root)
|
||||
: root_(nullptr)
|
||||
, transform_()
|
||||
{
|
||||
|
|
@ -38,34 +38,17 @@ namespace easy2d
|
|||
|
||||
Scene::~Scene()
|
||||
{
|
||||
if (root_)
|
||||
{
|
||||
root_->SetParentScene(nullptr);
|
||||
root_->Release();
|
||||
}
|
||||
}
|
||||
|
||||
void Scene::SetRoot(Node * root)
|
||||
void Scene::SetRoot(spNode const& root)
|
||||
{
|
||||
if (root_ == root)
|
||||
return;
|
||||
|
||||
if (root_)
|
||||
{
|
||||
root_->SetParentScene(nullptr);
|
||||
root_->Release();
|
||||
}
|
||||
|
||||
if (root)
|
||||
{
|
||||
root->Retain();
|
||||
root->SetParentScene(this);
|
||||
}
|
||||
|
||||
root_ = root;
|
||||
}
|
||||
|
||||
Node * Scene::GetRoot() const
|
||||
spNode const& Scene::GetRoot() const
|
||||
{
|
||||
return root_;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include "RefCounter.h"
|
||||
#include "base.h"
|
||||
#include "KeyEvent.h"
|
||||
#include "MouseEvent.h"
|
||||
#include "../math/Matrix.hpp"
|
||||
|
|
@ -38,7 +38,7 @@ namespace easy2d
|
|||
Scene();
|
||||
|
||||
explicit Scene(
|
||||
Node * root
|
||||
spNode const& root
|
||||
);
|
||||
|
||||
virtual ~Scene();
|
||||
|
|
@ -54,11 +54,11 @@ namespace easy2d
|
|||
|
||||
// 设置根节点
|
||||
void SetRoot(
|
||||
Node * root
|
||||
spNode const& root
|
||||
);
|
||||
|
||||
// 获取根节点
|
||||
Node* GetRoot() const;
|
||||
spNode const& GetRoot() const;
|
||||
|
||||
// 渲染场景
|
||||
void Draw();
|
||||
|
|
@ -82,7 +82,7 @@ namespace easy2d
|
|||
const math::Matrix& GetTransform() const;
|
||||
|
||||
private:
|
||||
Node* root_;
|
||||
spNode root_;
|
||||
math::Matrix transform_;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
Sprite::Sprite(Image * image)
|
||||
Sprite::Sprite(spImage const& image)
|
||||
: image_(nullptr)
|
||||
{
|
||||
Load(image);
|
||||
|
|
@ -63,20 +63,13 @@ namespace easy2d
|
|||
|
||||
Sprite::~Sprite()
|
||||
{
|
||||
SafeRelease(image_);
|
||||
}
|
||||
|
||||
bool Sprite::Load(Image * image)
|
||||
bool Sprite::Load(spImage const& image)
|
||||
{
|
||||
if (image)
|
||||
{
|
||||
if (image_)
|
||||
{
|
||||
image_->Release();
|
||||
}
|
||||
|
||||
image_ = image;
|
||||
image_->Retain();
|
||||
|
||||
Node::SetSize(image_->GetWidth(), image_->GetHeight());
|
||||
return true;
|
||||
|
|
@ -88,15 +81,17 @@ namespace easy2d
|
|||
{
|
||||
if (!image_)
|
||||
{
|
||||
image_ = new Image();
|
||||
image_->Retain();
|
||||
image_ = new (std::nothrow) Image();
|
||||
}
|
||||
|
||||
if (image_)
|
||||
{
|
||||
if (image_->Load(res))
|
||||
{
|
||||
Node::SetSize(image_->GetWidth(), image_->GetHeight());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -104,15 +99,17 @@ namespace easy2d
|
|||
{
|
||||
if (!image_)
|
||||
{
|
||||
image_ = new Image();
|
||||
image_->Retain();
|
||||
image_ = new (std::nothrow) Image();
|
||||
}
|
||||
|
||||
if (image_)
|
||||
{
|
||||
if (image_->Load(file_name))
|
||||
{
|
||||
Node::SetSize(image_->GetWidth(), image_->GetHeight());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -125,7 +122,7 @@ namespace easy2d
|
|||
);
|
||||
}
|
||||
|
||||
Image * Sprite::GetImage() const
|
||||
spImage const& Sprite::GetImage() const
|
||||
{
|
||||
return image_;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace easy2d
|
|||
Sprite();
|
||||
|
||||
explicit Sprite(
|
||||
Image * image
|
||||
spImage const& image
|
||||
);
|
||||
|
||||
explicit Sprite(
|
||||
|
|
@ -69,7 +69,7 @@ namespace easy2d
|
|||
|
||||
// 加载图片
|
||||
bool Load(
|
||||
Image * image
|
||||
spImage const& image
|
||||
);
|
||||
|
||||
// 将图片裁剪为矩形
|
||||
|
|
@ -78,12 +78,12 @@ namespace easy2d
|
|||
);
|
||||
|
||||
// 获取 Image 对象
|
||||
Image * GetImage() const;
|
||||
spImage const& GetImage() const;
|
||||
|
||||
// 渲染精灵
|
||||
virtual void OnDraw() const override;
|
||||
|
||||
private:
|
||||
Image* image_;
|
||||
spImage image_;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,22 +23,16 @@
|
|||
namespace easy2d
|
||||
{
|
||||
Task::Task(const Callback & func, const String & name)
|
||||
: running_(true)
|
||||
, stopped_(false)
|
||||
, run_times_(0)
|
||||
, total_times_(-1)
|
||||
, delay_()
|
||||
, callback_(func)
|
||||
, name_(name)
|
||||
: Task(func, Duration{}, -1, name)
|
||||
{
|
||||
}
|
||||
|
||||
Task::Task(const Callback & func, float delay, int times, const String & name)
|
||||
Task::Task(Callback const& func, Duration const& delay, int times, const String & name)
|
||||
: running_(true)
|
||||
, stopped_(false)
|
||||
, run_times_(0)
|
||||
, delay_(time::Second * std::max(delay, 0.f))
|
||||
, total_times_(times)
|
||||
, delay_(delay)
|
||||
, callback_(func)
|
||||
, name_(name)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,13 +21,10 @@
|
|||
#pragma once
|
||||
#include "base.h"
|
||||
#include "time.h"
|
||||
#include "RefCounter.h"
|
||||
#include <functional>
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
class Node;
|
||||
|
||||
// 定时任务
|
||||
class Task
|
||||
: public RefCounter
|
||||
|
|
@ -43,8 +40,8 @@ namespace easy2d
|
|||
);
|
||||
|
||||
explicit Task(
|
||||
const Callback& func, /* 执行函数 */
|
||||
float delay, /* 时间间隔(秒) */
|
||||
Callback const& func, /* 执行函数 */
|
||||
Duration const& delay, /* 时间间隔(秒) */
|
||||
int times = -1, /* 执行次数(设 -1 为永久执行) */
|
||||
const String& name = L"" /* 任务名称 */
|
||||
);
|
||||
|
|
@ -61,13 +58,11 @@ namespace easy2d
|
|||
// 获取任务名称
|
||||
const String& GetName() const;
|
||||
|
||||
// 任务是否就绪
|
||||
protected:
|
||||
bool IsReady() const;
|
||||
|
||||
// 执行任务
|
||||
void Update();
|
||||
|
||||
// 重置计时
|
||||
void ResetTime();
|
||||
|
||||
private:
|
||||
|
|
@ -76,9 +71,8 @@ namespace easy2d
|
|||
int run_times_;
|
||||
int total_times_;
|
||||
String name_;
|
||||
time::Duration delay_;
|
||||
time::TimePoint last_time_;
|
||||
Duration delay_;
|
||||
TimePoint last_time_;
|
||||
Callback callback_;
|
||||
Node * target_;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,8 +50,6 @@ namespace easy2d
|
|||
{
|
||||
SafeRelease(out_layer_);
|
||||
SafeRelease(in_layer_);
|
||||
SafeRelease(out_scene_);
|
||||
SafeRelease(in_scene_);
|
||||
}
|
||||
|
||||
bool Transition::IsDone()
|
||||
|
|
@ -59,18 +57,12 @@ namespace easy2d
|
|||
return done_;
|
||||
}
|
||||
|
||||
void Transition::Initialize(Scene * prev, Scene * next, Game * game)
|
||||
void Transition::Init(spScene const& prev, spScene const& next)
|
||||
{
|
||||
started_ = time::Now();
|
||||
out_scene_ = prev;
|
||||
in_scene_ = next;
|
||||
|
||||
if (out_scene_)
|
||||
out_scene_->Retain();
|
||||
|
||||
if (in_scene_)
|
||||
in_scene_->Retain();
|
||||
|
||||
if (in_scene_)
|
||||
{
|
||||
ThrowIfFailed(
|
||||
|
|
@ -153,9 +145,9 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
void BoxTransition::Initialize(Scene * prev, Scene * next, Game * game)
|
||||
void BoxTransition::Init(spScene const& prev, spScene const& next)
|
||||
{
|
||||
Transition::Initialize(prev, next, game);
|
||||
Transition::Init(prev, next);
|
||||
|
||||
in_layer_prop_.opacity = 0;
|
||||
}
|
||||
|
|
@ -195,9 +187,9 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
void EmergeTransition::Initialize(Scene * prev, Scene * next, Game * game)
|
||||
void EmergeTransition::Init(spScene const& prev, spScene const& next)
|
||||
{
|
||||
Transition::Initialize(prev, next, game);
|
||||
Transition::Init(prev, next);
|
||||
|
||||
out_layer_prop_.opacity = 1;
|
||||
in_layer_prop_.opacity = 0;
|
||||
|
|
@ -220,9 +212,9 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
void FadeTransition::Initialize(Scene * prev, Scene * next, Game * game)
|
||||
void FadeTransition::Init(spScene const& prev, spScene const& next)
|
||||
{
|
||||
Transition::Initialize(prev, next, game);
|
||||
Transition::Init(prev, next);
|
||||
|
||||
out_layer_prop_.opacity = 1;
|
||||
in_layer_prop_.opacity = 0;
|
||||
|
|
@ -254,9 +246,9 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
void MoveTransition::Initialize(Scene * prev, Scene * next, Game * game)
|
||||
void MoveTransition::Init(spScene const& prev, spScene const& next)
|
||||
{
|
||||
Transition::Initialize(prev, next, game);
|
||||
Transition::Init(prev, next);
|
||||
|
||||
switch (direction_)
|
||||
{
|
||||
|
|
@ -344,9 +336,9 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
void RotationTransition::Initialize(Scene * prev, Scene * next, Game * game)
|
||||
void RotationTransition::Init(spScene const& prev, spScene const& next)
|
||||
{
|
||||
Transition::Initialize(prev, next, game);
|
||||
Transition::Init(prev, next);
|
||||
|
||||
if (out_scene_)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,11 +21,9 @@
|
|||
#pragma once
|
||||
#include "base.h"
|
||||
#include "time.h"
|
||||
#include "RefCounter.h"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
class Game;
|
||||
class Scene;
|
||||
|
||||
// 场景过渡
|
||||
|
|
@ -46,10 +44,9 @@ namespace easy2d
|
|||
|
||||
protected:
|
||||
// 初始化场景过渡动画
|
||||
virtual void Initialize(
|
||||
Scene * prev,
|
||||
Scene * next,
|
||||
Game * game
|
||||
virtual void Init(
|
||||
spScene const& prev,
|
||||
spScene const& next
|
||||
);
|
||||
|
||||
// 更新场景过渡动画
|
||||
|
|
@ -68,10 +65,10 @@ namespace easy2d
|
|||
bool done_;
|
||||
float duration_;
|
||||
float process_;
|
||||
time::TimePoint started_;
|
||||
TimePoint started_;
|
||||
Size window_size_;
|
||||
Scene* out_scene_;
|
||||
Scene* in_scene_;
|
||||
spScene out_scene_;
|
||||
spScene in_scene_;
|
||||
ID2D1Layer* out_layer_;
|
||||
ID2D1Layer* in_layer_;
|
||||
LayerProperties out_layer_prop_;
|
||||
|
|
@ -92,10 +89,9 @@ namespace easy2d
|
|||
// 更新动画
|
||||
virtual void Update() override;
|
||||
|
||||
virtual void Initialize(
|
||||
Scene * prev,
|
||||
Scene * next,
|
||||
Game * game
|
||||
virtual void Init(
|
||||
spScene const& prev,
|
||||
spScene const& next
|
||||
) override;
|
||||
};
|
||||
|
||||
|
|
@ -112,10 +108,9 @@ namespace easy2d
|
|||
protected:
|
||||
virtual void Update() override;
|
||||
|
||||
virtual void Initialize(
|
||||
Scene * prev,
|
||||
Scene * next,
|
||||
Game * game
|
||||
virtual void Init(
|
||||
spScene const& prev,
|
||||
spScene const& next
|
||||
) override;
|
||||
};
|
||||
|
||||
|
|
@ -132,10 +127,9 @@ namespace easy2d
|
|||
protected:
|
||||
virtual void Update() override;
|
||||
|
||||
virtual void Initialize(
|
||||
Scene * prev,
|
||||
Scene * next,
|
||||
Game * game
|
||||
virtual void Init(
|
||||
spScene const& prev,
|
||||
spScene const& next
|
||||
) override;
|
||||
};
|
||||
|
||||
|
|
@ -153,10 +147,9 @@ namespace easy2d
|
|||
protected:
|
||||
virtual void Update() override;
|
||||
|
||||
virtual void Initialize(
|
||||
Scene * prev,
|
||||
Scene * next,
|
||||
Game * game
|
||||
virtual void Init(
|
||||
spScene const& prev,
|
||||
spScene const& next
|
||||
) override;
|
||||
|
||||
virtual void Reset() override;
|
||||
|
|
@ -181,10 +174,9 @@ namespace easy2d
|
|||
protected:
|
||||
virtual void Update() override;
|
||||
|
||||
virtual void Initialize(
|
||||
Scene * prev,
|
||||
Scene * next,
|
||||
Game * game
|
||||
virtual void Init(
|
||||
spScene const& prev,
|
||||
spScene const& next
|
||||
) override;
|
||||
|
||||
virtual void Reset() override;
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ namespace easy2d
|
|||
, mastering_voice_(nullptr)
|
||||
, initialized(false)
|
||||
{
|
||||
modules::Initialize();
|
||||
modules::Init();
|
||||
}
|
||||
|
||||
AudioDevice::~AudioDevice()
|
||||
|
|
@ -185,7 +185,7 @@ namespace easy2d
|
|||
modules::Destroy();
|
||||
}
|
||||
|
||||
void AudioDevice::Initialize(bool debug)
|
||||
void AudioDevice::Init(bool debug)
|
||||
{
|
||||
if (initialized)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ namespace easy2d
|
|||
E2D_DISABLE_COPY(AudioDevice);
|
||||
|
||||
public:
|
||||
void Initialize(bool debug);
|
||||
void Init(bool debug);
|
||||
|
||||
// 开启设备
|
||||
void Open();
|
||||
|
|
|
|||
|
|
@ -20,10 +20,74 @@
|
|||
|
||||
#pragma once
|
||||
#include "BaseTypes.h"
|
||||
#include "IntrusivePtr.hpp"
|
||||
#include "RefCounter.hpp"
|
||||
#include <stdexcept>
|
||||
|
||||
|
||||
#ifndef E2D_DECLARE_SMART_PTR
|
||||
#define E2D_DECLARE_SMART_PTR(class_name)\
|
||||
class class_name;\
|
||||
using sp##class_name = ::easy2d::IntrusivePtr< class_name >
|
||||
|
||||
#define E2D_DECLARE_NS_SMART_PTR(ns_name, class_name)\
|
||||
namespace ns_name\
|
||||
{\
|
||||
class class_name; \
|
||||
using sp##class_name = ::easy2d::IntrusivePtr< class_name >;\
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
E2D_DECLARE_SMART_PTR(Image);
|
||||
E2D_DECLARE_SMART_PTR(Music);
|
||||
E2D_DECLARE_SMART_PTR(Task);
|
||||
|
||||
E2D_DECLARE_SMART_PTR(Node);
|
||||
E2D_DECLARE_SMART_PTR(Scene);
|
||||
E2D_DECLARE_SMART_PTR(Sprite);
|
||||
E2D_DECLARE_SMART_PTR(Text);
|
||||
E2D_DECLARE_SMART_PTR(Canvas);
|
||||
|
||||
E2D_DECLARE_SMART_PTR(Action);
|
||||
E2D_DECLARE_SMART_PTR(MoveBy);
|
||||
E2D_DECLARE_SMART_PTR(MoveTo);
|
||||
E2D_DECLARE_SMART_PTR(JumpBy);
|
||||
E2D_DECLARE_SMART_PTR(JumpTo);
|
||||
E2D_DECLARE_SMART_PTR(ScaleBy);
|
||||
E2D_DECLARE_SMART_PTR(ScaleTo);
|
||||
E2D_DECLARE_SMART_PTR(OpacityBy);
|
||||
E2D_DECLARE_SMART_PTR(OpacityTo);
|
||||
E2D_DECLARE_SMART_PTR(FadeIn);
|
||||
E2D_DECLARE_SMART_PTR(FadeOut);
|
||||
E2D_DECLARE_SMART_PTR(RotateBy);
|
||||
E2D_DECLARE_SMART_PTR(RotateTo);
|
||||
E2D_DECLARE_SMART_PTR(Delay);
|
||||
E2D_DECLARE_SMART_PTR(Animation);
|
||||
E2D_DECLARE_SMART_PTR(Animate);
|
||||
E2D_DECLARE_SMART_PTR(CallFunc);
|
||||
E2D_DECLARE_SMART_PTR(Loop);
|
||||
E2D_DECLARE_SMART_PTR(Sequence);
|
||||
E2D_DECLARE_SMART_PTR(Spawn);
|
||||
|
||||
E2D_DECLARE_SMART_PTR(Transition);
|
||||
E2D_DECLARE_SMART_PTR(FadeTransition);
|
||||
E2D_DECLARE_SMART_PTR(EmergeTransition);
|
||||
E2D_DECLARE_SMART_PTR(BoxTransition);
|
||||
E2D_DECLARE_SMART_PTR(MoveTransition);
|
||||
E2D_DECLARE_SMART_PTR(RotationTransition);
|
||||
|
||||
E2D_DECLARE_NS_SMART_PTR(ui, Button);
|
||||
E2D_DECLARE_NS_SMART_PTR(ui, Menu);
|
||||
|
||||
using Images = ::std::vector< spImage >;
|
||||
using Nodes = ::std::vector< spNode >;
|
||||
using Actions = ::std::vector< spAction >;
|
||||
using Tasks = ::std::vector< spTask >;
|
||||
|
||||
|
||||
template<class Interface>
|
||||
inline void SafeRelease(Interface*& p)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ namespace easy2d
|
|||
Module_XAudio2 XAudio2;
|
||||
Module_MediaFoundation MediaFoundation;
|
||||
|
||||
void Initialize()
|
||||
void Init()
|
||||
{
|
||||
initialize_count++;
|
||||
if (initialize_count > 1)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace easy2d
|
|||
{
|
||||
// modules can be initialized multiple times,
|
||||
// but it needs to be destroyed every time
|
||||
void Initialize();
|
||||
void Init();
|
||||
|
||||
void Destroy();
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include "time.h"
|
||||
#include "base.h"
|
||||
#include "modules.h"
|
||||
#include "Image.h"
|
||||
|
||||
#pragma comment(lib, "d2d1.lib")
|
||||
#pragma comment(lib, "dwrite.lib")
|
||||
|
|
@ -38,7 +39,7 @@ namespace easy2d
|
|||
{
|
||||
ZeroMemory(&d2d, sizeof(D2DResources));
|
||||
|
||||
modules::Initialize();
|
||||
modules::Init();
|
||||
}
|
||||
|
||||
GraphicsDevice::~GraphicsDevice()
|
||||
|
|
@ -63,7 +64,7 @@ namespace easy2d
|
|||
modules::Destroy();
|
||||
}
|
||||
|
||||
void GraphicsDevice::Initialize(HWND hwnd, bool debug)
|
||||
void GraphicsDevice::Init(HWND hwnd, bool debug)
|
||||
{
|
||||
if (initialized)
|
||||
return;
|
||||
|
|
@ -302,7 +303,7 @@ namespace easy2d
|
|||
}
|
||||
|
||||
HRESULT GraphicsDevice::DrawImage(
|
||||
Image * image,
|
||||
spImage const& image,
|
||||
float opacity,
|
||||
const Rect & dest_rect,
|
||||
const Rect & source_rect
|
||||
|
|
|
|||
|
|
@ -23,12 +23,13 @@
|
|||
#include "Singleton.hpp"
|
||||
#include "Font.h"
|
||||
#include "Resource.h"
|
||||
#include "Image.h"
|
||||
#include "TextRenderer.h"
|
||||
#include "../math/Matrix.hpp"
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
class Image;
|
||||
|
||||
namespace devices
|
||||
{
|
||||
struct D2DResources
|
||||
|
|
@ -52,7 +53,7 @@ namespace easy2d
|
|||
E2D_DISABLE_COPY(GraphicsDevice);
|
||||
|
||||
public:
|
||||
void Initialize(HWND hwnd, bool debug);
|
||||
void Init(HWND hwnd, bool debug);
|
||||
|
||||
// ¿ªÊ¼äÖȾ
|
||||
void BeginDraw(HWND hwnd);
|
||||
|
|
@ -121,7 +122,7 @@ namespace easy2d
|
|||
);
|
||||
|
||||
HRESULT DrawImage(
|
||||
Image* image,
|
||||
spImage const& image,
|
||||
float opacity,
|
||||
const Rect& dest_rect,
|
||||
const Rect& source_rect
|
||||
|
|
|
|||
|
|
@ -187,6 +187,11 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
namespace easy2d
|
||||
{
|
||||
using namespace time;
|
||||
}
|
||||
|
||||
#if VS_VER >= VS_2015
|
||||
|
||||
namespace easy2d
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ namespace easy2d
|
|||
::DestroyWindow(handle);
|
||||
}
|
||||
|
||||
void WindowImpl::Initialize(String title, int width, int height, LPCWSTR icon, bool debug)
|
||||
void WindowImpl::Init(String title, int width, int height, LPCWSTR icon, bool debug)
|
||||
{
|
||||
if (initialized)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace easy2d
|
|||
E2D_DISABLE_COPY(WindowImpl);
|
||||
|
||||
public:
|
||||
void Initialize(
|
||||
void Init(
|
||||
String title,
|
||||
int width,
|
||||
int height,
|
||||
|
|
|
|||
|
|
@ -46,21 +46,22 @@
|
|||
#include "base/Color.h"
|
||||
#include "base/Resource.h"
|
||||
|
||||
#include "base/RefCounter.h"
|
||||
#include "base/RefCounter.hpp"
|
||||
#include "base/IntrusivePtr.hpp"
|
||||
#include "base/Image.h"
|
||||
#include "base/Scene.h"
|
||||
#include "base/Node.h"
|
||||
#include "base/Scene.h"
|
||||
#include "base/Sprite.h"
|
||||
#include "base/Task.h"
|
||||
#include "base/Text.h"
|
||||
#include "base/Action.h"
|
||||
#include "base/Canvas.h"
|
||||
#include "base/Music.h"
|
||||
#include "base/Task.h"
|
||||
#include "base/Action.hpp"
|
||||
#include "base/ActionCombined.h"
|
||||
#include "base/ActionFiniteTime.h"
|
||||
#include "base/Animation.h"
|
||||
#include "base/CallFunc.h"
|
||||
#include "base/Canvas.h"
|
||||
#include "base/Transition.h"
|
||||
#include "base/Music.h"
|
||||
|
||||
#include "base/KeyEvent.h"
|
||||
#include "base/MouseEvent.h"
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
Button::Button(Node * normal, const Callback& func)
|
||||
Button::Button(spNode const& normal, const Callback& func)
|
||||
: callback_(nullptr)
|
||||
, status_(Status::Normal)
|
||||
, enabled_(true)
|
||||
|
|
@ -67,7 +67,7 @@ namespace easy2d
|
|||
this->SetCallbackOnClick(func);
|
||||
}
|
||||
|
||||
Button::Button(Node * normal, Node * selected, const Callback& func)
|
||||
Button::Button(spNode const& normal, spNode const& selected, const Callback& func)
|
||||
: callback_(nullptr)
|
||||
, status_(Status::Normal)
|
||||
, enabled_(true)
|
||||
|
|
@ -82,7 +82,7 @@ namespace easy2d
|
|||
this->SetCallbackOnClick(func);
|
||||
}
|
||||
|
||||
Button::Button(Node * normal, Node * mouseover, Node * selected, const Callback& func)
|
||||
Button::Button(spNode const& normal, spNode const& mouseover, spNode const& selected, const Callback& func)
|
||||
: callback_(nullptr)
|
||||
, status_(Status::Normal)
|
||||
, enabled_(true)
|
||||
|
|
@ -98,7 +98,7 @@ namespace easy2d
|
|||
this->SetCallbackOnClick(func);
|
||||
}
|
||||
|
||||
Button::Button(Node * normal, Node * mouseover, Node * selected, Node * disabled, const Callback& func)
|
||||
Button::Button(spNode const& normal, spNode const& mouseover, spNode const& selected, spNode const& disabled, const Callback& func)
|
||||
: callback_(nullptr)
|
||||
, status_(Status::Normal)
|
||||
, enabled_(true)
|
||||
|
|
@ -115,12 +115,16 @@ namespace easy2d
|
|||
this->SetCallbackOnClick(func);
|
||||
}
|
||||
|
||||
Button::~Button()
|
||||
{
|
||||
}
|
||||
|
||||
bool Button::IsEnable() const
|
||||
{
|
||||
return enabled_;
|
||||
}
|
||||
|
||||
void Button::SetNormal(Node * normal)
|
||||
void Button::SetNormal(spNode const& normal)
|
||||
{
|
||||
SET_BUTTON_NODE(normal_, normal);
|
||||
if (normal)
|
||||
|
|
@ -129,17 +133,17 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
void Button::SetMouseOver(Node * mouseover)
|
||||
void Button::SetMouseOver(spNode const& mouseover)
|
||||
{
|
||||
SET_BUTTON_NODE(mouseover_, mouseover);
|
||||
}
|
||||
|
||||
void Button::SetSelected(Node * selected)
|
||||
void Button::SetSelected(spNode const& selected)
|
||||
{
|
||||
SET_BUTTON_NODE(selected_, selected);
|
||||
}
|
||||
|
||||
void Button::SetDisabled(Node * disabled)
|
||||
void Button::SetDisabled(spNode const& disabled)
|
||||
{
|
||||
SET_BUTTON_NODE(disabled_, disabled);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,37 +31,39 @@ namespace easy2d
|
|||
{
|
||||
E2D_DISABLE_COPY(Button);
|
||||
|
||||
typedef std::function<void()> Callback;
|
||||
using Callback = std::function<void()>;
|
||||
|
||||
public:
|
||||
Button();
|
||||
|
||||
explicit Button(
|
||||
Node * normal, /* 噸宥彜蓑 */
|
||||
spNode const& normal, /* 噸宥彜蓑 */
|
||||
const Callback& func = nullptr /* 按钮点击后的回调函数 */
|
||||
);
|
||||
|
||||
explicit Button(
|
||||
Node * normal, /* 噸宥彜蓑 */
|
||||
Node * selected, /* 報炎梓和彜蓑 */
|
||||
spNode const& normal, /* 噸宥彜蓑 */
|
||||
spNode const& selected, /* 報炎梓和彜蓑 */
|
||||
const Callback& func = nullptr /* 按钮点击后的回调函数 */
|
||||
);
|
||||
|
||||
explicit Button(
|
||||
Node * normal, /* 噸宥彜蓑 */
|
||||
Node * mouseover, /* 報炎卞秘彜蓑 */
|
||||
Node * selected, /* 報炎梓和彜蓑 */
|
||||
spNode const& normal, /* 噸宥彜蓑 */
|
||||
spNode const& mouseover, /* 報炎卞秘彜蓑 */
|
||||
spNode const& selected, /* 報炎梓和彜蓑 */
|
||||
const Callback& func = nullptr /* 按钮点击后的回调函数 */
|
||||
);
|
||||
|
||||
explicit Button(
|
||||
Node * normal, /* 噸宥彜蓑 */
|
||||
Node * mouseover, /* 報炎卞秘彜蓑 */
|
||||
Node * selected, /* 報炎卞秘彜蓑 */
|
||||
Node * disabled, /* 梓泥鋤喘彜蓑 */
|
||||
spNode const& normal, /* 噸宥彜蓑 */
|
||||
spNode const& mouseover, /* 報炎卞秘彜蓑 */
|
||||
spNode const& selected, /* 報炎卞秘彜蓑 */
|
||||
spNode const& disabled, /* 梓泥鋤喘彜蓑 */
|
||||
const Callback& func = nullptr /* 按钮点击后的回调函数 */
|
||||
);
|
||||
|
||||
virtual ~Button();
|
||||
|
||||
// 获取按钮状态是启用还是禁用
|
||||
bool IsEnable() const;
|
||||
|
||||
|
|
@ -72,22 +74,22 @@ namespace easy2d
|
|||
|
||||
// 设置一般情况下显示的按钮
|
||||
virtual void SetNormal(
|
||||
Node * normal
|
||||
spNode const& normal
|
||||
);
|
||||
|
||||
// 设置鼠标移入按钮时显示的按钮
|
||||
virtual void SetMouseOver(
|
||||
Node * mouseover
|
||||
spNode const& mouseover
|
||||
);
|
||||
|
||||
// 设置鼠标按下按钮时显示的按钮
|
||||
virtual void SetSelected(
|
||||
Node * selected
|
||||
spNode const& selected
|
||||
);
|
||||
|
||||
// 设置按钮被禁用时显示的按钮
|
||||
virtual void SetDisabled(
|
||||
Node * disabled
|
||||
spNode const& disabled
|
||||
);
|
||||
|
||||
// 设置按钮点击后的回调函数
|
||||
|
|
@ -124,10 +126,10 @@ namespace easy2d
|
|||
virtual void Visit() override;
|
||||
|
||||
private:
|
||||
Node * normal_;
|
||||
Node * mouseover_;
|
||||
Node * selected_;
|
||||
Node * disabled_;
|
||||
spNode normal_;
|
||||
spNode mouseover_;
|
||||
spNode selected_;
|
||||
spNode disabled_;
|
||||
bool enabled_;
|
||||
bool is_selected_;
|
||||
Status status_;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace easy2d
|
|||
{
|
||||
}
|
||||
|
||||
Menu::Menu(const std::vector<Button*>& buttons)
|
||||
Menu::Menu(const std::vector<spButton>& buttons)
|
||||
: enabled_(true)
|
||||
{
|
||||
for (const auto& button : buttons)
|
||||
|
|
@ -61,7 +61,7 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
void Menu::AddButton(Button * button)
|
||||
void Menu::AddButton(spButton const& button)
|
||||
{
|
||||
if (button)
|
||||
{
|
||||
|
|
@ -71,7 +71,7 @@ namespace easy2d
|
|||
}
|
||||
}
|
||||
|
||||
bool Menu::RemoveButton(Button * button)
|
||||
bool Menu::RemoveButton(spButton const& button)
|
||||
{
|
||||
if (buttons_.empty())
|
||||
{
|
||||
|
|
@ -94,7 +94,7 @@ namespace easy2d
|
|||
return false;
|
||||
}
|
||||
|
||||
const std::vector<Button*>& Menu::GetAllButtons() const
|
||||
const std::vector<spButton>& Menu::GetAllButtons() const
|
||||
{
|
||||
return buttons_;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include "../base/Node.h"
|
||||
#include "Button.h"
|
||||
|
||||
namespace easy2d
|
||||
|
|
@ -36,7 +35,7 @@ namespace easy2d
|
|||
Menu();
|
||||
|
||||
explicit Menu(
|
||||
const std::vector<Button*>& buttons /* 按钮数组 */
|
||||
const std::vector<spButton>& buttons /* 按钮数组 */
|
||||
);
|
||||
|
||||
// 获取菜单是否禁用
|
||||
|
|
@ -52,20 +51,20 @@ namespace easy2d
|
|||
|
||||
// 添加按钮
|
||||
void AddButton(
|
||||
Button * button
|
||||
spButton const& button
|
||||
);
|
||||
|
||||
// 移除按钮
|
||||
bool RemoveButton(
|
||||
Button * button
|
||||
spButton const& button
|
||||
);
|
||||
|
||||
// 获取所有按钮
|
||||
const std::vector<Button*>& GetAllButtons() const;
|
||||
const std::vector<spButton>& GetAllButtons() const;
|
||||
|
||||
private:
|
||||
bool enabled_;
|
||||
std::vector<Button*> buttons_;
|
||||
std::vector<spButton> buttons_;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ namespace easy2d
|
|||
if (file_path.empty())
|
||||
return false;
|
||||
|
||||
Music * music = new (std::nothrow) Music();
|
||||
spMusic music = new (std::nothrow) Music();
|
||||
|
||||
if (music)
|
||||
{
|
||||
|
|
@ -50,10 +50,6 @@ namespace easy2d
|
|||
musics_cache_.insert(std::make_pair(hash_code, music));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
music->Release();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -121,7 +117,7 @@ namespace easy2d
|
|||
if (musics_cache_.end() != musics_cache_.find(hash_code))
|
||||
return true;
|
||||
|
||||
Music * music = new (std::nothrow) Music();
|
||||
spMusic music = new (std::nothrow) Music();
|
||||
|
||||
if (music)
|
||||
{
|
||||
|
|
@ -131,10 +127,6 @@ namespace easy2d
|
|||
musics_cache_.insert(std::make_pair(hash_code, music));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
music->Release();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -222,13 +214,6 @@ namespace easy2d
|
|||
|
||||
void Player::ClearCache()
|
||||
{
|
||||
if (musics_cache_.empty())
|
||||
return;
|
||||
|
||||
for (const auto& pair : musics_cache_)
|
||||
{
|
||||
pair.second->Release();
|
||||
}
|
||||
musics_cache_.clear();
|
||||
}
|
||||
}
|
||||
|
|
@ -24,8 +24,6 @@
|
|||
|
||||
namespace easy2d
|
||||
{
|
||||
class Music;
|
||||
|
||||
// 音乐播放器
|
||||
class Player
|
||||
{
|
||||
|
|
@ -120,6 +118,6 @@ namespace easy2d
|
|||
|
||||
protected:
|
||||
float volume_;
|
||||
std::map<size_t, Music*> musics_cache_;
|
||||
std::map<size_t, spMusic> musics_cache_;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\core\base\Action.h" />
|
||||
<ClInclude Include="..\..\core\base\Action.hpp" />
|
||||
<ClInclude Include="..\..\core\base\ActionCombined.h" />
|
||||
<ClInclude Include="..\..\core\base\ActionFiniteTime.h" />
|
||||
<ClInclude Include="..\..\core\base\Animation.h" />
|
||||
|
|
@ -33,6 +33,7 @@
|
|||
<ClInclude Include="..\..\core\base\Game.h" />
|
||||
<ClInclude Include="..\..\core\base\Image.h" />
|
||||
<ClInclude Include="..\..\core\base\Input.h" />
|
||||
<ClInclude Include="..\..\core\base\IntrusivePtr.hpp" />
|
||||
<ClInclude Include="..\..\core\base\KeyEvent.h" />
|
||||
<ClInclude Include="..\..\core\base\logs.h" />
|
||||
<ClInclude Include="..\..\core\base\macros.h" />
|
||||
|
|
@ -41,7 +42,7 @@
|
|||
<ClInclude Include="..\..\core\base\Music.h" />
|
||||
<ClInclude Include="..\..\core\base\Node.h" />
|
||||
<ClInclude Include="..\..\core\base\Rect.hpp" />
|
||||
<ClInclude Include="..\..\core\base\RefCounter.h" />
|
||||
<ClInclude Include="..\..\core\base\RefCounter.hpp" />
|
||||
<ClInclude Include="..\..\core\base\render.h" />
|
||||
<ClInclude Include="..\..\core\base\Resource.h" />
|
||||
<ClInclude Include="..\..\core\base\Scene.h" />
|
||||
|
|
@ -69,7 +70,6 @@
|
|||
<ClInclude Include="..\..\core\utils\Transcoder.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\core\base\Action.cpp" />
|
||||
<ClCompile Include="..\..\core\base\ActionCombined.cpp" />
|
||||
<ClCompile Include="..\..\core\base\ActionFiniteTime.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Animation.cpp" />
|
||||
|
|
@ -86,7 +86,6 @@
|
|||
<ClCompile Include="..\..\core\base\MouseEvent.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Music.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Node.cpp" />
|
||||
<ClCompile Include="..\..\core\base\RefCounter.cpp" />
|
||||
<ClCompile Include="..\..\core\base\render.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Resource.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Scene.cpp" />
|
||||
|
|
|
|||
|
|
@ -2,9 +2,6 @@
|
|||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\core\easy2d.h" />
|
||||
<ClInclude Include="..\..\core\base\Action.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\ActionCombined.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
|
|
@ -59,9 +56,6 @@
|
|||
<ClInclude Include="..\..\core\base\Rect.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\RefCounter.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\render.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
|
|
@ -143,6 +137,15 @@
|
|||
<ClInclude Include="..\..\core\base\Singleton.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\RefCounter.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\IntrusivePtr.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\Action.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="base">
|
||||
|
|
@ -159,9 +162,6 @@
|
|||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\core\base\Action.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\base\ActionCombined.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
|
|
@ -201,9 +201,6 @@
|
|||
<ClCompile Include="..\..\core\base\Node.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\base\RefCounter.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\base\render.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\core\base\Action.h" />
|
||||
<ClInclude Include="..\..\core\base\Action.hpp" />
|
||||
<ClInclude Include="..\..\core\base\ActionCombined.h" />
|
||||
<ClInclude Include="..\..\core\base\ActionFiniteTime.h" />
|
||||
<ClInclude Include="..\..\core\base\Animation.h" />
|
||||
|
|
@ -33,6 +33,7 @@
|
|||
<ClInclude Include="..\..\core\base\Game.h" />
|
||||
<ClInclude Include="..\..\core\base\Image.h" />
|
||||
<ClInclude Include="..\..\core\base\Input.h" />
|
||||
<ClInclude Include="..\..\core\base\IntrusivePtr.hpp" />
|
||||
<ClInclude Include="..\..\core\base\KeyEvent.h" />
|
||||
<ClInclude Include="..\..\core\base\logs.h" />
|
||||
<ClInclude Include="..\..\core\base\macros.h" />
|
||||
|
|
@ -41,7 +42,7 @@
|
|||
<ClInclude Include="..\..\core\base\Music.h" />
|
||||
<ClInclude Include="..\..\core\base\Node.h" />
|
||||
<ClInclude Include="..\..\core\base\Rect.hpp" />
|
||||
<ClInclude Include="..\..\core\base\RefCounter.h" />
|
||||
<ClInclude Include="..\..\core\base\RefCounter.hpp" />
|
||||
<ClInclude Include="..\..\core\base\render.h" />
|
||||
<ClInclude Include="..\..\core\base\Resource.h" />
|
||||
<ClInclude Include="..\..\core\base\Scene.h" />
|
||||
|
|
@ -69,7 +70,6 @@
|
|||
<ClInclude Include="..\..\core\utils\Transcoder.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\core\base\Action.cpp" />
|
||||
<ClCompile Include="..\..\core\base\ActionCombined.cpp" />
|
||||
<ClCompile Include="..\..\core\base\ActionFiniteTime.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Animation.cpp" />
|
||||
|
|
@ -86,7 +86,6 @@
|
|||
<ClCompile Include="..\..\core\base\MouseEvent.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Music.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Node.cpp" />
|
||||
<ClCompile Include="..\..\core\base\RefCounter.cpp" />
|
||||
<ClCompile Include="..\..\core\base\render.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Resource.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Scene.cpp" />
|
||||
|
|
|
|||
|
|
@ -2,9 +2,6 @@
|
|||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\core\easy2d.h" />
|
||||
<ClInclude Include="..\..\core\base\Action.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\ActionCombined.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
|
|
@ -59,9 +56,6 @@
|
|||
<ClInclude Include="..\..\core\base\Rect.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\RefCounter.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\render.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
|
|
@ -143,6 +137,15 @@
|
|||
<ClInclude Include="..\..\core\base\Singleton.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\RefCounter.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\IntrusivePtr.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\Action.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="base">
|
||||
|
|
@ -159,9 +162,6 @@
|
|||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\core\base\Action.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\base\ActionCombined.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
|
|
@ -201,9 +201,6 @@
|
|||
<ClCompile Include="..\..\core\base\Node.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\base\RefCounter.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\base\render.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\core\base\Action.h" />
|
||||
<ClInclude Include="..\..\core\base\Action.hpp" />
|
||||
<ClInclude Include="..\..\core\base\ActionCombined.h" />
|
||||
<ClInclude Include="..\..\core\base\ActionFiniteTime.h" />
|
||||
<ClInclude Include="..\..\core\base\Animation.h" />
|
||||
|
|
@ -33,6 +33,7 @@
|
|||
<ClInclude Include="..\..\core\base\Game.h" />
|
||||
<ClInclude Include="..\..\core\base\Image.h" />
|
||||
<ClInclude Include="..\..\core\base\Input.h" />
|
||||
<ClInclude Include="..\..\core\base\IntrusivePtr.hpp" />
|
||||
<ClInclude Include="..\..\core\base\KeyEvent.h" />
|
||||
<ClInclude Include="..\..\core\base\logs.h" />
|
||||
<ClInclude Include="..\..\core\base\macros.h" />
|
||||
|
|
@ -41,7 +42,7 @@
|
|||
<ClInclude Include="..\..\core\base\Music.h" />
|
||||
<ClInclude Include="..\..\core\base\Node.h" />
|
||||
<ClInclude Include="..\..\core\base\Rect.hpp" />
|
||||
<ClInclude Include="..\..\core\base\RefCounter.h" />
|
||||
<ClInclude Include="..\..\core\base\RefCounter.hpp" />
|
||||
<ClInclude Include="..\..\core\base\render.h" />
|
||||
<ClInclude Include="..\..\core\base\Resource.h" />
|
||||
<ClInclude Include="..\..\core\base\Scene.h" />
|
||||
|
|
@ -69,7 +70,6 @@
|
|||
<ClInclude Include="..\..\core\utils\Transcoder.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\core\base\Action.cpp" />
|
||||
<ClCompile Include="..\..\core\base\ActionCombined.cpp" />
|
||||
<ClCompile Include="..\..\core\base\ActionFiniteTime.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Animation.cpp" />
|
||||
|
|
@ -86,7 +86,6 @@
|
|||
<ClCompile Include="..\..\core\base\MouseEvent.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Music.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Node.cpp" />
|
||||
<ClCompile Include="..\..\core\base\RefCounter.cpp" />
|
||||
<ClCompile Include="..\..\core\base\render.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Resource.cpp" />
|
||||
<ClCompile Include="..\..\core\base\Scene.cpp" />
|
||||
|
|
@ -198,7 +197,7 @@
|
|||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
</ClCompile>
|
||||
|
|
|
|||
|
|
@ -2,9 +2,6 @@
|
|||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\core\easy2d.h" />
|
||||
<ClInclude Include="..\..\core\base\Action.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\ActionCombined.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
|
|
@ -59,9 +56,6 @@
|
|||
<ClInclude Include="..\..\core\base\Rect.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\RefCounter.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\render.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
|
|
@ -143,6 +137,15 @@
|
|||
<ClInclude Include="..\..\core\base\Singleton.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\RefCounter.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\IntrusivePtr.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\core\base\Action.hpp">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="base">
|
||||
|
|
@ -159,9 +162,6 @@
|
|||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\core\base\Action.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\base\ActionCombined.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
|
|
@ -201,9 +201,6 @@
|
|||
<ClCompile Include="..\..\core\base\Node.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\base\RefCounter.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\core\base\render.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
|
|
|
|||
Loading…
Reference in New Issue