rename Node to Actor, rename Scene to Stage, rename Stage to Director

This commit is contained in:
Nomango 2019-08-12 18:30:42 +08:00
parent 0dbdf4ffc8
commit 62d8c4507d
36 changed files with 307 additions and 307 deletions

View File

@ -2,7 +2,7 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup> <ItemGroup>
<ClInclude Include="..\src\kiwano\2d\GifSprite.h" /> <ClInclude Include="..\src\kiwano\2d\GifSprite.h" />
<ClInclude Include="..\src\kiwano\base\Stage.h" /> <ClInclude Include="..\src\kiwano\base\Director.h" />
<ClInclude Include="..\src\kiwano\base\types.h" /> <ClInclude Include="..\src\kiwano\base\types.h" />
<ClInclude Include="..\src\kiwano\kiwano.h" /> <ClInclude Include="..\src\kiwano\kiwano.h" />
<ClInclude Include="..\src\kiwano\config.h" /> <ClInclude Include="..\src\kiwano\config.h" />
@ -23,8 +23,8 @@
<ClInclude Include="..\src\kiwano\2d\GifImage.h" /> <ClInclude Include="..\src\kiwano\2d\GifImage.h" />
<ClInclude Include="..\src\kiwano\2d\Image.h" /> <ClInclude Include="..\src\kiwano\2d\Image.h" />
<ClInclude Include="..\src\kiwano\2d\Layer.h" /> <ClInclude Include="..\src\kiwano\2d\Layer.h" />
<ClInclude Include="..\src\kiwano\2d\Node.h" /> <ClInclude Include="..\src\kiwano\2d\Actor.h" />
<ClInclude Include="..\src\kiwano\2d\Scene.h" /> <ClInclude Include="..\src\kiwano\2d\Stage.h" />
<ClInclude Include="..\src\kiwano\2d\Sprite.h" /> <ClInclude Include="..\src\kiwano\2d\Sprite.h" />
<ClInclude Include="..\src\kiwano\2d\Text.h" /> <ClInclude Include="..\src\kiwano\2d\Text.h" />
<ClInclude Include="..\src\kiwano\2d\TextStyle.hpp" /> <ClInclude Include="..\src\kiwano\2d\TextStyle.hpp" />
@ -97,8 +97,8 @@
<ClCompile Include="..\src\kiwano\2d\GifSprite.cpp" /> <ClCompile Include="..\src\kiwano\2d\GifSprite.cpp" />
<ClCompile Include="..\src\kiwano\2d\Image.cpp" /> <ClCompile Include="..\src\kiwano\2d\Image.cpp" />
<ClCompile Include="..\src\kiwano\2d\Layer.cpp" /> <ClCompile Include="..\src\kiwano\2d\Layer.cpp" />
<ClCompile Include="..\src\kiwano\2d\Node.cpp" /> <ClCompile Include="..\src\kiwano\2d\Actor.cpp" />
<ClCompile Include="..\src\kiwano\2d\Scene.cpp" /> <ClCompile Include="..\src\kiwano\2d\Stage.cpp" />
<ClCompile Include="..\src\kiwano\2d\Sprite.cpp" /> <ClCompile Include="..\src\kiwano\2d\Sprite.cpp" />
<ClCompile Include="..\src\kiwano\2d\Text.cpp" /> <ClCompile Include="..\src\kiwano\2d\Text.cpp" />
<ClCompile Include="..\src\kiwano\2d\Transition.cpp" /> <ClCompile Include="..\src\kiwano\2d\Transition.cpp" />
@ -109,7 +109,7 @@
<ClCompile Include="..\src\kiwano\base\logs.cpp" /> <ClCompile Include="..\src\kiwano\base\logs.cpp" />
<ClCompile Include="..\src\kiwano\base\Object.cpp" /> <ClCompile Include="..\src\kiwano\base\Object.cpp" />
<ClCompile Include="..\src\kiwano\base\Resource.cpp" /> <ClCompile Include="..\src\kiwano\base\Resource.cpp" />
<ClCompile Include="..\src\kiwano\base\Stage.cpp" /> <ClCompile Include="..\src\kiwano\base\Director.cpp" />
<ClCompile Include="..\src\kiwano\base\Timer.cpp" /> <ClCompile Include="..\src\kiwano\base\Timer.cpp" />
<ClCompile Include="..\src\kiwano\base\TimerManager.cpp" /> <ClCompile Include="..\src\kiwano\base\TimerManager.cpp" />
<ClCompile Include="..\src\kiwano\base\time.cpp" /> <ClCompile Include="..\src\kiwano\base\time.cpp" />

View File

@ -84,12 +84,6 @@
<ClInclude Include="..\src\kiwano\2d\Layer.h"> <ClInclude Include="..\src\kiwano\2d\Layer.h">
<Filter>2d</Filter> <Filter>2d</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\src\kiwano\2d\Node.h">
<Filter>2d</Filter>
</ClInclude>
<ClInclude Include="..\src\kiwano\2d\Scene.h">
<Filter>2d</Filter>
</ClInclude>
<ClInclude Include="..\src\kiwano\2d\Sprite.h"> <ClInclude Include="..\src\kiwano\2d\Sprite.h">
<Filter>2d</Filter> <Filter>2d</Filter>
</ClInclude> </ClInclude>
@ -267,9 +261,15 @@
<ClInclude Include="..\src\kiwano\2d\ShapeNode.h"> <ClInclude Include="..\src\kiwano\2d\ShapeNode.h">
<Filter>2d</Filter> <Filter>2d</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\src\kiwano\base\Stage.h"> <ClInclude Include="..\src\kiwano\base\Director.h">
<Filter>base</Filter> <Filter>base</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\src\kiwano\2d\Actor.h">
<Filter>2d</Filter>
</ClInclude>
<ClInclude Include="..\src\kiwano\2d\Stage.h">
<Filter>2d</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\src\kiwano\ui\Button.cpp"> <ClCompile Include="..\src\kiwano\ui\Button.cpp">
@ -311,12 +311,6 @@
<ClCompile Include="..\src\kiwano\2d\Layer.cpp"> <ClCompile Include="..\src\kiwano\2d\Layer.cpp">
<Filter>2d</Filter> <Filter>2d</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\src\kiwano\2d\Node.cpp">
<Filter>2d</Filter>
</ClCompile>
<ClCompile Include="..\src\kiwano\2d\Scene.cpp">
<Filter>2d</Filter>
</ClCompile>
<ClCompile Include="..\src\kiwano\2d\Sprite.cpp"> <ClCompile Include="..\src\kiwano\2d\Sprite.cpp">
<Filter>2d</Filter> <Filter>2d</Filter>
</ClCompile> </ClCompile>
@ -407,8 +401,14 @@
<ClCompile Include="..\src\kiwano\2d\ShapeNode.cpp"> <ClCompile Include="..\src\kiwano\2d\ShapeNode.cpp">
<Filter>2d</Filter> <Filter>2d</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\src\kiwano\base\Stage.cpp"> <ClCompile Include="..\src\kiwano\base\Director.cpp">
<Filter>base</Filter> <Filter>base</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\src\kiwano\2d\Actor.cpp">
<Filter>2d</Filter>
</ClCompile>
<ClCompile Include="..\src\kiwano\2d\Stage.cpp">
<Filter>2d</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -19,7 +19,7 @@
// THE SOFTWARE. // THE SOFTWARE.
#include "Action.h" #include "Action.h"
#include "Node.h" #include "Actor.h"
namespace kiwano namespace kiwano
{ {
@ -36,16 +36,16 @@ namespace kiwano
{ {
} }
void Action::Init(NodePtr target) void Action::Init(ActorPtr target)
{ {
} }
void Action::Update(NodePtr target, Duration dt) void Action::Update(ActorPtr target, Duration dt)
{ {
Complete(target); Complete(target);
} }
void Action::UpdateStep(NodePtr target, Duration dt) void Action::UpdateStep(ActorPtr target, Duration dt)
{ {
elapsed_ += dt; elapsed_ += dt;
@ -81,7 +81,7 @@ namespace kiwano
} }
} }
void Action::Complete(NodePtr target) void Action::Complete(ActorPtr target)
{ {
if (cb_loop_done_) if (cb_loop_done_)
cb_loop_done_(); cb_loop_done_();
@ -99,7 +99,7 @@ namespace kiwano
++loops_done_; ++loops_done_;
} }
void Action::Restart(NodePtr target) void Action::Restart(ActorPtr target)
{ {
status_ = Status::NotStarted; status_ = Status::NotStarted;
elapsed_ = 0; elapsed_ = 0;

View File

@ -64,7 +64,7 @@ namespace kiwano
// 设置循环次数 (-1 为永久循环) // 设置循环次数 (-1 为永久循环)
inline void SetLoops(int loops) { loops_ = loops; } inline void SetLoops(int loops) { loops_ = loops; }
// 动作结束时移除目标节点 // 动作结束时移除目标角色
inline void RemoveTargetWhenDone() { detach_target_ = true; } inline void RemoveTargetWhenDone() { detach_target_ = true; }
// 设置动作结束时的回调函数 // 设置动作结束时的回调函数
@ -100,15 +100,15 @@ namespace kiwano
inline ActionCallback GetLoopDoneCallback() const { return cb_loop_done_; } inline ActionCallback GetLoopDoneCallback() const { return cb_loop_done_; }
protected: protected:
virtual void Init(NodePtr target); virtual void Init(ActorPtr target);
virtual void Update(NodePtr target, Duration dt); virtual void Update(ActorPtr target, Duration dt);
void UpdateStep(NodePtr target, Duration dt); void UpdateStep(ActorPtr target, Duration dt);
void Complete(NodePtr target); void Complete(ActorPtr target);
void Restart(NodePtr target); void Restart(ActorPtr target);
protected: protected:
Status status_; Status status_;

View File

@ -19,7 +19,7 @@
// THE SOFTWARE. // THE SOFTWARE.
#include "ActionGroup.h" #include "ActionGroup.h"
#include "Node.h" #include "Actor.h"
#include "../base/logs.h" #include "../base/logs.h"
namespace kiwano namespace kiwano
@ -43,7 +43,7 @@ namespace kiwano
{ {
} }
void ActionGroup::Init(NodePtr target) void ActionGroup::Init(ActorPtr target)
{ {
if (actions_.IsEmpty()) if (actions_.IsEmpty())
{ {
@ -64,7 +64,7 @@ namespace kiwano
} }
} }
void ActionGroup::Update(NodePtr target, Duration dt) void ActionGroup::Update(ActorPtr target, Duration dt)
{ {
if (sequence_) if (sequence_)
{ {

View File

@ -60,10 +60,10 @@ namespace kiwano
protected: protected:
// 初始化动作 // 初始化动作
void Init(NodePtr target) override; void Init(ActorPtr target) override;
// 更新动作 // 更新动作
void Update(NodePtr target, Duration dt) override; void Update(ActorPtr target, Duration dt) override;
protected: protected:
bool sequence_; bool sequence_;

View File

@ -39,7 +39,7 @@ namespace kiwano
// 设置动作循环结束时的回调函数 // 设置动作循环结束时的回调函数
inline ActionHelper& SetLoopDoneCallback(ActionCallback const& cb) { base->SetLoopDoneCallback(cb); return (*this); } inline ActionHelper& SetLoopDoneCallback(ActionCallback const& cb) { base->SetLoopDoneCallback(cb); return (*this); }
// 动作结束时移除目标节点 // 动作结束时移除目标角色
inline ActionHelper& RemoveTargetWhenDone() { base->RemoveTargetWhenDone(); return (*this); } inline ActionHelper& RemoveTargetWhenDone() { base->RemoveTargetWhenDone(); return (*this); }
// 设置名称 // 设置名称
@ -76,7 +76,7 @@ namespace kiwano
// 设置动作循环结束时的回调函数 // 设置动作循环结束时的回调函数
inline TweenHelper& SetLoopDoneCallback(ActionCallback const& cb) { base->SetLoopDoneCallback(cb); return (*this); } inline TweenHelper& SetLoopDoneCallback(ActionCallback const& cb) { base->SetLoopDoneCallback(cb); return (*this); }
// 动作结束时移除目标节点 // 动作结束时移除目标角色
inline TweenHelper& RemoveTargetWhenDone() { base->RemoveTargetWhenDone(); return (*this); } inline TweenHelper& RemoveTargetWhenDone() { base->RemoveTargetWhenDone(); return (*this); }
// 设置名称 // 设置名称

View File

@ -19,12 +19,12 @@
// THE SOFTWARE. // THE SOFTWARE.
#include "ActionManager.h" #include "ActionManager.h"
#include "Node.h" #include "Actor.h"
#include "../base/logs.h" #include "../base/logs.h"
namespace kiwano namespace kiwano
{ {
void ActionManager::UpdateActions(NodePtr target, Duration dt) void ActionManager::UpdateActions(ActorPtr target, Duration dt)
{ {
if (actions_.IsEmpty() || !target) if (actions_.IsEmpty() || !target)
return; return;

View File

@ -51,7 +51,7 @@ namespace kiwano
Actions const& GetAllActions() const; Actions const& GetAllActions() const;
protected: protected:
void UpdateActions(NodePtr target, Duration dt); void UpdateActions(ActorPtr target, Duration dt);
protected: protected:
Actions actions_; Actions actions_;

View File

@ -20,7 +20,7 @@
#include "ActionTween.h" #include "ActionTween.h"
#include "include-forwards.h" #include "include-forwards.h"
#include "Node.h" #include "Actor.h"
namespace kiwano namespace kiwano
{ {
@ -98,7 +98,7 @@ namespace kiwano
return dur_; return dur_;
} }
void ActionTween::Update(NodePtr target, Duration dt) void ActionTween::Update(ActorPtr target, Duration dt)
{ {
float percent; float percent;
@ -142,7 +142,7 @@ namespace kiwano
delta_pos_ = vector; delta_pos_ = vector;
} }
void ActionMoveBy::Init(NodePtr target) void ActionMoveBy::Init(ActorPtr target)
{ {
if (target) if (target)
{ {
@ -150,7 +150,7 @@ namespace kiwano
} }
} }
void ActionMoveBy::UpdateTween(NodePtr target, float percent) void ActionMoveBy::UpdateTween(ActorPtr target, float percent)
{ {
Point diff = target->GetPosition() - prev_pos_; Point diff = target->GetPosition() - prev_pos_;
start_pos_ = start_pos_ + diff; start_pos_ = start_pos_ + diff;
@ -182,7 +182,7 @@ namespace kiwano
return new (std::nothrow) ActionMoveTo(dur_, end_pos_, ease_func_); return new (std::nothrow) ActionMoveTo(dur_, end_pos_, ease_func_);
} }
void ActionMoveTo::Init(NodePtr target) void ActionMoveTo::Init(ActorPtr target)
{ {
ActionMoveBy::Init(target); ActionMoveBy::Init(target);
delta_pos_ = end_pos_ - start_pos_; delta_pos_ = end_pos_ - start_pos_;
@ -211,7 +211,7 @@ namespace kiwano
return new (std::nothrow) ActionJumpBy(dur_, -delta_pos_, height_, jumps_, ease_func_); return new (std::nothrow) ActionJumpBy(dur_, -delta_pos_, height_, jumps_, ease_func_);
} }
void ActionJumpBy::Init(NodePtr target) void ActionJumpBy::Init(ActorPtr target)
{ {
if (target) if (target)
{ {
@ -219,7 +219,7 @@ namespace kiwano
} }
} }
void ActionJumpBy::UpdateTween(NodePtr target, float percent) void ActionJumpBy::UpdateTween(ActorPtr target, float percent)
{ {
float frac = fmod(percent * jumps_, 1.f); float frac = fmod(percent * jumps_, 1.f);
float x = delta_pos_.x * percent; float x = delta_pos_.x * percent;
@ -246,7 +246,7 @@ namespace kiwano
return new (std::nothrow) ActionJumpTo(dur_, end_pos_, height_, jumps_, ease_func_); return new (std::nothrow) ActionJumpTo(dur_, end_pos_, height_, jumps_, ease_func_);
} }
void ActionJumpTo::Init(NodePtr target) void ActionJumpTo::Init(ActorPtr target)
{ {
ActionJumpBy::Init(target); ActionJumpBy::Init(target);
delta_pos_ = end_pos_ - start_pos_; delta_pos_ = end_pos_ - start_pos_;
@ -271,7 +271,7 @@ namespace kiwano
{ {
} }
void ActionScaleBy::Init(NodePtr target) void ActionScaleBy::Init(ActorPtr target)
{ {
if (target) if (target)
{ {
@ -280,7 +280,7 @@ namespace kiwano
} }
} }
void ActionScaleBy::UpdateTween(NodePtr target, float percent) void ActionScaleBy::UpdateTween(ActorPtr target, float percent)
{ {
target->SetScale(start_scale_x_ + delta_x_ * percent, start_scale_y_ + delta_y_ * percent); target->SetScale(start_scale_x_ + delta_x_ * percent, start_scale_y_ + delta_y_ * percent);
} }
@ -314,7 +314,7 @@ namespace kiwano
return new (std::nothrow) ActionScaleTo(dur_, end_scale_x_, end_scale_y_, ease_func_); return new (std::nothrow) ActionScaleTo(dur_, end_scale_x_, end_scale_y_, ease_func_);
} }
void ActionScaleTo::Init(NodePtr target) void ActionScaleTo::Init(ActorPtr target)
{ {
ActionScaleBy::Init(target); ActionScaleBy::Init(target);
delta_x_ = end_scale_x_ - start_scale_x_; delta_x_ = end_scale_x_ - start_scale_x_;
@ -334,7 +334,7 @@ namespace kiwano
{ {
} }
void ActionFadeTo::Init(NodePtr target) void ActionFadeTo::Init(ActorPtr target)
{ {
if (target) if (target)
{ {
@ -343,7 +343,7 @@ namespace kiwano
} }
} }
void ActionFadeTo::UpdateTween(NodePtr target, float percent) void ActionFadeTo::UpdateTween(ActorPtr target, float percent)
{ {
target->SetOpacity(start_val_ + delta_val_ * percent); target->SetOpacity(start_val_ + delta_val_ * percent);
} }
@ -375,7 +375,7 @@ namespace kiwano
{ {
} }
void ActionRotateBy::Init(NodePtr target) void ActionRotateBy::Init(ActorPtr target)
{ {
if (target) if (target)
{ {
@ -383,7 +383,7 @@ namespace kiwano
} }
} }
void ActionRotateBy::UpdateTween(NodePtr target, float percent) void ActionRotateBy::UpdateTween(ActorPtr target, float percent)
{ {
float rotation = start_val_ + delta_val_ * percent; float rotation = start_val_ + delta_val_ * percent;
if (rotation > 360.f) if (rotation > 360.f)
@ -413,7 +413,7 @@ namespace kiwano
return new (std::nothrow) ActionRotateTo(dur_, end_val_, ease_func_); return new (std::nothrow) ActionRotateTo(dur_, end_val_, ease_func_);
} }
void ActionRotateTo::Init(NodePtr target) void ActionRotateTo::Init(ActorPtr target)
{ {
ActionRotateBy::Init(target); ActionRotateBy::Init(target);
delta_val_ = end_val_ - start_val_; delta_val_ = end_val_ - start_val_;
@ -481,7 +481,7 @@ namespace kiwano
return false; return false;
} }
void ActionPath::Init(NodePtr target) void ActionPath::Init(ActorPtr target)
{ {
start_pos_ = target->GetPosition(); start_pos_ = target->GetPosition();
@ -496,7 +496,7 @@ namespace kiwano
} }
} }
void ActionPath::UpdateTween(NodePtr target, float percent) void ActionPath::UpdateTween(ActorPtr target, float percent)
{ {
float length = GetPathLength() * std::min(std::max((end_ - start_) * percent + start_, 0.f), 1.f); float length = GetPathLength() * std::min(std::max((end_ - start_) * percent + start_, 0.f), 1.f);
@ -647,13 +647,13 @@ namespace kiwano
return new ActionCustom(dur_, tween_func_); return new ActionCustom(dur_, tween_func_);
} }
void ActionCustom::Init(NodePtr target) void ActionCustom::Init(ActorPtr target)
{ {
if (!tween_func_) if (!tween_func_)
this->Done(); this->Done();
} }
void ActionCustom::UpdateTween(NodePtr target, float percent) void ActionCustom::UpdateTween(ActorPtr target, float percent)
{ {
if (tween_func_) if (tween_func_)
tween_func_(target, percent); tween_func_(target, percent);

View File

@ -90,9 +90,9 @@ namespace kiwano
void SetDuration(Duration duration); void SetDuration(Duration duration);
protected: protected:
void Update(NodePtr target, Duration dt) override; void Update(ActorPtr target, Duration dt) override;
virtual void UpdateTween(NodePtr target, float percent) = 0; virtual void UpdateTween(ActorPtr target, float percent) = 0;
protected: protected:
Duration dur_; Duration dur_;
@ -118,9 +118,9 @@ namespace kiwano
ActionPtr Reverse() const override; ActionPtr Reverse() const override;
protected: protected:
void Init(NodePtr target) override; void Init(ActorPtr target) override;
void UpdateTween(NodePtr target, float percent) override; void UpdateTween(ActorPtr target, float percent) override;
protected: protected:
Point start_pos_; Point start_pos_;
@ -151,7 +151,7 @@ namespace kiwano
} }
protected: protected:
void Init(NodePtr target) override; void Init(ActorPtr target) override;
protected: protected:
Point end_pos_; Point end_pos_;
@ -178,9 +178,9 @@ namespace kiwano
ActionPtr Reverse() const override; ActionPtr Reverse() const override;
protected: protected:
void Init(NodePtr target) override; void Init(ActorPtr target) override;
void UpdateTween(NodePtr target, float percent) override; void UpdateTween(ActorPtr target, float percent) override;
protected: protected:
Point start_pos_; Point start_pos_;
@ -215,7 +215,7 @@ namespace kiwano
} }
protected: protected:
void Init(NodePtr target) override; void Init(ActorPtr target) override;
protected: protected:
Point end_pos_; Point end_pos_;
@ -247,9 +247,9 @@ namespace kiwano
ActionPtr Reverse() const override; ActionPtr Reverse() const override;
protected: protected:
void Init(NodePtr target) override; void Init(ActorPtr target) override;
void UpdateTween(NodePtr target, float percent) override; void UpdateTween(ActorPtr target, float percent) override;
protected: protected:
float start_scale_x_; float start_scale_x_;
@ -288,7 +288,7 @@ namespace kiwano
} }
protected: protected:
void Init(NodePtr target) override; void Init(ActorPtr target) override;
protected: protected:
float end_scale_x_; float end_scale_x_;
@ -318,9 +318,9 @@ namespace kiwano
} }
protected: protected:
void Init(NodePtr target) override; void Init(ActorPtr target) override;
void UpdateTween(NodePtr target, float percent) override; void UpdateTween(ActorPtr target, float percent) override;
protected: protected:
float start_val_; float start_val_;
@ -373,9 +373,9 @@ namespace kiwano
ActionPtr Reverse() const override; ActionPtr Reverse() const override;
protected: protected:
void Init(NodePtr target) override; void Init(ActorPtr target) override;
void UpdateTween(NodePtr target, float percent) override; void UpdateTween(ActorPtr target, float percent) override;
protected: protected:
float start_val_; float start_val_;
@ -405,7 +405,7 @@ namespace kiwano
} }
protected: protected:
void Init(NodePtr target) override; void Init(ActorPtr target) override;
protected: protected:
float end_val_; float end_val_;
@ -481,9 +481,9 @@ namespace kiwano
inline void SetGeometry(ComPtr<ID2D1PathGeometry> geo) { geo_ = geo; } inline void SetGeometry(ComPtr<ID2D1PathGeometry> geo) { geo_ = geo; }
protected: protected:
void Init(NodePtr target) override; void Init(ActorPtr target) override;
void UpdateTween(NodePtr target, float percent) override; void UpdateTween(ActorPtr target, float percent) override;
protected: protected:
bool path_beginning_; bool path_beginning_;
@ -502,7 +502,7 @@ namespace kiwano
: public ActionTween : public ActionTween
{ {
public: public:
using TweenFunc = Closure<void(NodePtr, float)>; using TweenFunc = Closure<void(ActorPtr, float)>;
ActionCustom( ActionCustom(
Duration duration, /* ³ÖÐøÊ±³¤ */ Duration duration, /* ³ÖÐøÊ±³¤ */
@ -521,9 +521,9 @@ namespace kiwano
} }
protected: protected:
void Init(NodePtr target) override; void Init(ActorPtr target) override;
void UpdateTween(NodePtr target, float percent) override; void UpdateTween(ActorPtr target, float percent) override;
protected: protected:
TweenFunc tween_func_; TweenFunc tween_func_;

View File

@ -18,9 +18,9 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE. // THE SOFTWARE.
#include "Node.h" #include "Actor.h"
#include "Action.h" #include "Action.h"
#include "Scene.h" #include "Stage.h"
#include "../base/logs.h" #include "../base/logs.h"
#include "../renderer/render.h" #include "../renderer/render.h"
@ -32,13 +32,13 @@ namespace kiwano
float default_anchor_y = 0.f; float default_anchor_y = 0.f;
} }
void Node::SetDefaultAnchor(float anchor_x, float anchor_y) void Actor::SetDefaultAnchor(float anchor_x, float anchor_y)
{ {
default_anchor_x = anchor_x; default_anchor_x = anchor_x;
default_anchor_y = anchor_y; default_anchor_y = anchor_y;
} }
Node::Node() Actor::Actor()
: visible_(true) : visible_(true)
, update_pausing_(false) , update_pausing_(false)
, hover_(false) , hover_(false)
@ -50,7 +50,7 @@ namespace kiwano
, show_border_(false) , show_border_(false)
, is_fast_transform_(true) , is_fast_transform_(true)
, parent_(nullptr) , parent_(nullptr)
, scene_(nullptr) , stage_(nullptr)
, hash_name_(0) , hash_name_(0)
, z_order_(0) , z_order_(0)
, opacity_(1.f) , opacity_(1.f)
@ -59,7 +59,7 @@ namespace kiwano
{ {
} }
void Node::Update(Duration dt) void Actor::Update(Duration dt)
{ {
if (!update_pausing_) if (!update_pausing_)
{ {
@ -74,7 +74,7 @@ namespace kiwano
if (!children_.IsEmpty()) if (!children_.IsEmpty())
{ {
NodePtr next; ActorPtr next;
for (auto child = children_.First(); child; child = next) for (auto child = children_.First(); child; child = next)
{ {
next = child->NextItem(); next = child->NextItem();
@ -83,7 +83,7 @@ namespace kiwano
} }
} }
void Node::Render() void Actor::Render()
{ {
if (!visible_) if (!visible_)
return; return;
@ -98,7 +98,7 @@ namespace kiwano
else else
{ {
// render children those are less than 0 in Z-Order // render children those are less than 0 in Z-Order
Node* child = children_.First().Get(); Actor* child = children_.First().Get();
while (child) while (child)
{ {
if (child->GetZOrder() >= 0) if (child->GetZOrder() >= 0)
@ -119,7 +119,7 @@ namespace kiwano
} }
} }
void Node::RenderBorder() void Actor::RenderBorder()
{ {
if (show_border_) if (show_border_)
{ {
@ -137,12 +137,12 @@ namespace kiwano
} }
} }
void Node::Dispatch(Event& evt) void Actor::Dispatch(Event& evt)
{ {
if (!visible_) if (!visible_)
return; return;
NodePtr prev; ActorPtr prev;
for (auto child = children_.Last(); child; child = prev) for (auto child = children_.Last(); child; child = prev)
{ {
prev = child->PrevItem(); prev = child->PrevItem();
@ -198,13 +198,13 @@ namespace kiwano
EventDispatcher::Dispatch(evt); EventDispatcher::Dispatch(evt);
} }
Matrix const & Node::GetTransformMatrix() const Matrix const & Actor::GetTransformMatrix() const
{ {
UpdateTransform(); UpdateTransform();
return transform_matrix_; return transform_matrix_;
} }
Matrix const & Node::GetTransformInverseMatrix() const Matrix const & Actor::GetTransformInverseMatrix() const
{ {
UpdateTransform(); UpdateTransform();
if (dirty_transform_inverse_) if (dirty_transform_inverse_)
@ -215,7 +215,7 @@ namespace kiwano
return transform_matrix_inverse_; return transform_matrix_inverse_;
} }
void Node::UpdateTransform() const void Actor::UpdateTransform() const
{ {
if (!dirty_transform_) if (!dirty_transform_)
return; return;
@ -246,11 +246,11 @@ namespace kiwano
} }
// update children's transform // update children's transform
for (Node* child = children_.First().Get(); child; child = child->NextItem().Get()) for (Actor* child = children_.First().Get(); child; child = child->NextItem().Get())
child->dirty_transform_ = true; child->dirty_transform_ = true;
} }
void Node::UpdateOpacity() void Actor::UpdateOpacity()
{ {
if (parent_ && parent_->IsCascadeOpacityEnabled()) if (parent_ && parent_->IsCascadeOpacityEnabled())
{ {
@ -261,33 +261,33 @@ namespace kiwano
displayed_opacity_ = opacity_; displayed_opacity_ = opacity_;
} }
for (Node* child = children_.First().Get(); child; child = child->NextItem().Get()) for (Actor* child = children_.First().Get(); child; child = child->NextItem().Get())
{ {
child->UpdateOpacity(); child->UpdateOpacity();
} }
} }
void Node::SetScene(Scene* scene) void Actor::SetStage(Stage* scene)
{ {
if (scene && scene_ != scene) if (scene && stage_ != scene)
{ {
scene_ = scene; stage_ = scene;
for (Node* child = children_.First().Get(); child; child = child->NextItem().Get()) for (Actor* child = children_.First().Get(); child; child = child->NextItem().Get())
{ {
child->scene_ = scene; child->stage_ = scene;
} }
} }
} }
void Node::Reorder() void Actor::Reorder()
{ {
if (parent_) if (parent_)
{ {
NodePtr me = this; ActorPtr me = this;
parent_->children_.Remove(me); parent_->children_.Remove(me);
Node* sibling = parent_->children_.Last().Get(); Actor* sibling = parent_->children_.Last().Get();
if (sibling && sibling->GetZOrder() > z_order_) if (sibling && sibling->GetZOrder() > z_order_)
{ {
@ -311,7 +311,7 @@ namespace kiwano
} }
} }
void Node::SetZOrder(int zorder) void Actor::SetZOrder(int zorder)
{ {
if (z_order_ != zorder) if (z_order_ != zorder)
{ {
@ -320,7 +320,7 @@ namespace kiwano
} }
} }
void Node::SetOpacity(float opacity) void Actor::SetOpacity(float opacity)
{ {
if (opacity_ == opacity) if (opacity_ == opacity)
return; return;
@ -329,7 +329,7 @@ namespace kiwano
UpdateOpacity(); UpdateOpacity();
} }
void Node::SetCascadeOpacityEnabled(bool enabled) void Actor::SetCascadeOpacityEnabled(bool enabled)
{ {
if (cascade_opacity_ == enabled) if (cascade_opacity_ == enabled)
return; return;
@ -338,17 +338,17 @@ namespace kiwano
UpdateOpacity(); UpdateOpacity();
} }
void Node::SetAnchorX(float anchor_x) void Actor::SetAnchorX(float anchor_x)
{ {
this->SetAnchor(anchor_x, anchor_.y); this->SetAnchor(anchor_x, anchor_.y);
} }
void Node::SetAnchorY(float anchor_y) void Actor::SetAnchorY(float anchor_y)
{ {
this->SetAnchor(anchor_.x, anchor_y); this->SetAnchor(anchor_.x, anchor_y);
} }
void Node::SetAnchor(float anchor_x, float anchor_y) void Actor::SetAnchor(float anchor_x, float anchor_y)
{ {
if (anchor_.x == anchor_x && anchor_.y == anchor_y) if (anchor_.x == anchor_x && anchor_.y == anchor_y)
return; return;
@ -358,27 +358,27 @@ namespace kiwano
dirty_transform_ = true; dirty_transform_ = true;
} }
void Node::SetAnchor(Point const& anchor) void Actor::SetAnchor(Point const& anchor)
{ {
this->SetAnchor(anchor.x, anchor.y); this->SetAnchor(anchor.x, anchor.y);
} }
void Node::SetWidth(float width) void Actor::SetWidth(float width)
{ {
this->SetSize(width, size_.y); this->SetSize(width, size_.y);
} }
void Node::SetHeight(float height) void Actor::SetHeight(float height)
{ {
this->SetSize(size_.x, height); this->SetSize(size_.x, height);
} }
void Node::SetSize(const Size& size) void Actor::SetSize(const Size& size)
{ {
this->SetSize(size.x, size.y); this->SetSize(size.x, size.y);
} }
void Node::SetSize(float width, float height) void Actor::SetSize(float width, float height)
{ {
if (size_.x == width && size_.y == height) if (size_.x == width && size_.y == height)
return; return;
@ -388,19 +388,19 @@ namespace kiwano
dirty_transform_ = true; dirty_transform_ = true;
} }
void Node::SetTransform(Transform const& transform) void Actor::SetTransform(Transform const& transform)
{ {
transform_ = transform; transform_ = transform;
dirty_transform_ = true; dirty_transform_ = true;
is_fast_transform_ = false; is_fast_transform_ = false;
} }
void Node::SetVisible(bool val) void Actor::SetVisible(bool val)
{ {
visible_ = val; visible_ = val;
} }
void Node::SetName(String const& name) void Actor::SetName(String const& name)
{ {
if (!IsName(name)) if (!IsName(name))
{ {
@ -409,22 +409,22 @@ namespace kiwano
} }
} }
void Node::SetPositionX(float x) void Actor::SetPositionX(float x)
{ {
this->SetPosition(x, transform_.position.y); this->SetPosition(x, transform_.position.y);
} }
void Node::SetPositionY(float y) void Actor::SetPositionY(float y)
{ {
this->SetPosition(transform_.position.x, y); this->SetPosition(transform_.position.x, y);
} }
void Node::SetPosition(const Point & p) void Actor::SetPosition(const Point & p)
{ {
this->SetPosition(p.x, p.y); this->SetPosition(p.x, p.y);
} }
void Node::SetPosition(float x, float y) void Actor::SetPosition(float x, float y)
{ {
if (transform_.position.x == x && transform_.position.y == y) if (transform_.position.x == x && transform_.position.y == y)
return; return;
@ -434,32 +434,32 @@ namespace kiwano
dirty_transform_ = true; dirty_transform_ = true;
} }
void Node::Move(float x, float y) void Actor::Move(float x, float y)
{ {
this->SetPosition(transform_.position.x + x, transform_.position.y + y); this->SetPosition(transform_.position.x + x, transform_.position.y + y);
} }
void Node::Move(const Point & v) void Actor::Move(const Point & v)
{ {
this->Move(v.x, v.y); this->Move(v.x, v.y);
} }
void Node::SetScaleX(float scale_x) void Actor::SetScaleX(float scale_x)
{ {
this->SetScale(scale_x, transform_.scale.y); this->SetScale(scale_x, transform_.scale.y);
} }
void Node::SetScaleY(float scale_y) void Actor::SetScaleY(float scale_y)
{ {
this->SetScale(transform_.scale.x, scale_y); this->SetScale(transform_.scale.x, scale_y);
} }
void Node::SetScale(float scale) void Actor::SetScale(float scale)
{ {
this->SetScale(scale, scale); this->SetScale(scale, scale);
} }
void Node::SetScale(float scale_x, float scale_y) void Actor::SetScale(float scale_x, float scale_y)
{ {
if (transform_.scale.x == scale_x && transform_.scale.y == scale_y) if (transform_.scale.x == scale_x && transform_.scale.y == scale_y)
return; return;
@ -470,22 +470,22 @@ namespace kiwano
is_fast_transform_ = false; is_fast_transform_ = false;
} }
void Node::SetScale(Point const& scale) void Actor::SetScale(Point const& scale)
{ {
this->SetScale(scale.x, scale.y); this->SetScale(scale.x, scale.y);
} }
void Node::SetSkewX(float skew_x) void Actor::SetSkewX(float skew_x)
{ {
this->SetSkew(skew_x, transform_.skew.y); this->SetSkew(skew_x, transform_.skew.y);
} }
void Node::SetSkewY(float skew_y) void Actor::SetSkewY(float skew_y)
{ {
this->SetSkew(transform_.skew.x, skew_y); this->SetSkew(transform_.skew.x, skew_y);
} }
void Node::SetSkew(float skew_x, float skew_y) void Actor::SetSkew(float skew_x, float skew_y)
{ {
if (transform_.skew.x == skew_x && transform_.skew.y == skew_y) if (transform_.skew.x == skew_x && transform_.skew.y == skew_y)
return; return;
@ -496,12 +496,12 @@ namespace kiwano
is_fast_transform_ = false; is_fast_transform_ = false;
} }
void Node::SetSkew(Point const& skew) void Actor::SetSkew(Point const& skew)
{ {
this->SetSkew(skew.x, skew.y); this->SetSkew(skew.x, skew.y);
} }
void Node::SetRotation(float angle) void Actor::SetRotation(float angle)
{ {
if (transform_.rotation == angle) if (transform_.rotation == angle)
return; return;
@ -511,9 +511,9 @@ namespace kiwano
is_fast_transform_ = false; is_fast_transform_ = false;
} }
void Node::AddChild(NodePtr child) void Actor::AddChild(ActorPtr child)
{ {
KGE_ASSERT(child && "Node::AddChild failed, NULL pointer exception"); KGE_ASSERT(child && "Actor::AddChild failed, NULL pointer exception");
if (child) if (child)
{ {
@ -522,7 +522,7 @@ namespace kiwano
if (child->parent_) if (child->parent_)
KGE_ERROR_LOG(L"The node to be added already has a parent"); KGE_ERROR_LOG(L"The node to be added already has a parent");
for (Node* parent = parent_; parent; parent = parent->parent_) for (Actor* parent = parent_; parent; parent = parent->parent_)
if (parent == child) if (parent == child)
KGE_ERROR_LOG(L"A node cannot be its own parent"); KGE_ERROR_LOG(L"A node cannot be its own parent");
@ -530,14 +530,14 @@ namespace kiwano
children_.PushBack(child); children_.PushBack(child);
child->parent_ = this; child->parent_ = this;
child->SetScene(this->scene_); child->SetStage(this->stage_);
child->dirty_transform_ = true; child->dirty_transform_ = true;
child->UpdateOpacity(); child->UpdateOpacity();
child->Reorder(); child->Reorder();
} }
} }
void Node::AddChildren(Array<NodePtr> const& children) void Actor::AddChildren(Array<ActorPtr> const& children)
{ {
for (const auto& node : children) for (const auto& node : children)
{ {
@ -545,22 +545,22 @@ namespace kiwano
} }
} }
Rect Node::GetBounds() const Rect Actor::GetBounds() const
{ {
return Rect(Point{}, size_); return Rect(Point{}, size_);
} }
Rect Node::GetBoundingBox() const Rect Actor::GetBoundingBox() const
{ {
return GetTransformMatrix().Transform(GetBounds()); return GetTransformMatrix().Transform(GetBounds());
} }
Array<NodePtr> Node::GetChildren(String const& name) const Array<ActorPtr> Actor::GetChildren(String const& name) const
{ {
Array<NodePtr> children; Array<ActorPtr> children;
size_t hash_code = std::hash<String>{}(name); size_t hash_code = std::hash<String>{}(name);
for (Node* child = children_.First().Get(); child; child = child->NextItem().Get()) for (Actor* child = children_.First().Get(); child; child = child->NextItem().Get())
{ {
if (child->hash_name_ == hash_code && child->IsName(name)) if (child->hash_name_ == hash_code && child->IsName(name))
{ {
@ -570,11 +570,11 @@ namespace kiwano
return children; return children;
} }
NodePtr Node::GetChild(String const& name) const ActorPtr Actor::GetChild(String const& name) const
{ {
size_t hash_code = std::hash<String>{}(name); size_t hash_code = std::hash<String>{}(name);
for (Node* child = children_.First().Get(); child; child = child->NextItem().Get()) for (Actor* child = children_.First().Get(); child; child = child->NextItem().Get())
{ {
if (child->hash_name_ == hash_code && child->IsName(name)) if (child->hash_name_ == hash_code && child->IsName(name))
{ {
@ -584,12 +584,12 @@ namespace kiwano
return nullptr; return nullptr;
} }
Node::Children const & Node::GetChildren() const Actor::Children const & Actor::GetChildren() const
{ {
return children_; return children_;
} }
void Node::RemoveFromParent() void Actor::RemoveFromParent()
{ {
if (parent_) if (parent_)
{ {
@ -597,14 +597,14 @@ namespace kiwano
} }
} }
void Node::RemoveChild(NodePtr child) void Actor::RemoveChild(ActorPtr child)
{ {
RemoveChild(child.Get()); RemoveChild(child.Get());
} }
void Node::RemoveChild(Node * child) void Actor::RemoveChild(Actor * child)
{ {
KGE_ASSERT(child && "Node::RemoveChild failed, NULL pointer exception"); KGE_ASSERT(child && "Actor::RemoveChild failed, NULL pointer exception");
if (children_.IsEmpty()) if (children_.IsEmpty())
return; return;
@ -612,12 +612,12 @@ namespace kiwano
if (child) if (child)
{ {
child->parent_ = nullptr; child->parent_ = nullptr;
if (child->scene_) child->SetScene(nullptr); if (child->stage_) child->SetStage(nullptr);
children_.Remove(NodePtr(child)); children_.Remove(ActorPtr(child));
} }
} }
void Node::RemoveChildren(String const& child_name) void Actor::RemoveChildren(String const& child_name)
{ {
if (children_.IsEmpty()) if (children_.IsEmpty())
{ {
@ -626,8 +626,8 @@ namespace kiwano
size_t hash_code = std::hash<String>{}(child_name); size_t hash_code = std::hash<String>{}(child_name);
Node* next; Actor* next;
for (Node* child = children_.First().Get(); child; child = next) for (Actor* child = children_.First().Get(); child; child = next)
{ {
next = child->NextItem().Get(); next = child->NextItem().Get();
@ -638,17 +638,17 @@ namespace kiwano
} }
} }
void Node::RemoveAllChildren() void Actor::RemoveAllChildren()
{ {
children_.Clear(); children_.Clear();
} }
void Node::SetResponsible(bool enable) void Actor::SetResponsible(bool enable)
{ {
responsible_ = enable; responsible_ = enable;
} }
bool Node::ContainsPoint(const Point& point) const bool Actor::ContainsPoint(const Point& point) const
{ {
if (size_.x == 0.f || size_.y == 0.f) if (size_.x == 0.f || size_.y == 0.f)
return false; return false;

View File

@ -27,30 +27,30 @@
namespace kiwano namespace kiwano
{ {
class Stage; class Director;
// 节点 // 角色
class KGE_API Node class KGE_API Actor
: public Object : public Object
, public TimerManager , public TimerManager
, public ActionManager , public ActionManager
, public EventDispatcher , public EventDispatcher
, public IntrusiveListItem<NodePtr> , public IntrusiveListItem<ActorPtr>
{ {
friend class Stage; friend class Director;
friend class Transition; friend class Transition;
friend class IntrusiveList<NodePtr>; friend class IntrusiveList<ActorPtr>;
using Children = IntrusiveList<NodePtr>; using Children = IntrusiveList<ActorPtr>;
using UpdateCallback = Closure<void(Duration)>; using UpdateCallback = Closure<void(Duration)>;
public: public:
Node(); Actor();
// 更新节点 // 更新角色
virtual void OnUpdate(Duration dt) { KGE_UNUSED(dt); } virtual void OnUpdate(Duration dt) { KGE_UNUSED(dt); }
// 渲染节点 // 渲染角色
virtual void OnRender() {} virtual void OnRender() {}
// 获取显示状态 // 获取显示状态
@ -87,7 +87,7 @@ namespace kiwano
float GetScaleY() const { return transform_.scale.y; } float GetScaleY() const { return transform_.scale.y; }
// 获取错切角度 // 获取错切角度
Point GetSkew() const { return transform_.skew; } Point GetSkew() const { return transform_.skew; }
// 获取横向错切角度 // 获取横向错切角度
float GetSkewX() const { return transform_.skew.x; } float GetSkewX() const { return transform_.skew.x; }
@ -146,11 +146,11 @@ namespace kiwano
// 获取二维变换的逆矩阵 // 获取二维变换的逆矩阵
Matrix const& GetTransformInverseMatrix() const; Matrix const& GetTransformInverseMatrix() const;
// 获取父节点 // 获取父角色
inline Node* GetParent() const { return parent_; } inline Actor* GetParent() const { return parent_; }
// 获取所在场景 // 获取所在场景
inline Scene* GetScene() const { return scene_; } inline Stage* GetStage() const { return stage_; }
// 设置是否显示 // 设置是否显示
void SetVisible( void SetVisible(
@ -330,62 +330,62 @@ namespace kiwano
bool enable bool enable
); );
// 判断点是否在节点 // 判断点是否在角色
bool ContainsPoint( bool ContainsPoint(
const Point& point const Point& point
) const; ) const;
// 添加子节点 // 添加子角色
void AddChild( void AddChild(
NodePtr child ActorPtr child
); );
// 添加多个子节点 // 添加多个子角色
void AddChildren( void AddChildren(
Array<NodePtr> const& children Array<ActorPtr> const& children
); );
// 获取所有名称相同的子节点 // 获取所有名称相同的子角色
Array<NodePtr> GetChildren( Array<ActorPtr> GetChildren(
String const& name String const& name
) const; ) const;
// 获取名称相同的子节点 // 获取名称相同的子角色
NodePtr GetChild( ActorPtr GetChild(
String const& name String const& name
) const; ) const;
// 获取全部子节点 // 获取全部子角色
Children const& GetChildren() const; Children const& GetChildren() const;
// 移除子节点 // 移除子角色
void RemoveChild( void RemoveChild(
NodePtr child ActorPtr child
); );
// 移除子节点 // 移除子角色
void RemoveChild( void RemoveChild(
Node* child Actor* child
); );
// 移除所有名称相同的子节点 // 移除所有名称相同的子角色
void RemoveChildren( void RemoveChildren(
String const& child_name String const& child_name
); );
// 移除所有节点 // 移除所有角色
void RemoveAllChildren(); void RemoveAllChildren();
// 从父节点移除 // 从父角色移除
void RemoveFromParent(); void RemoveFromParent();
// 暂停节点更新 // 暂停角色更新
inline void PauseUpdating() { update_pausing_ = true; } inline void PauseUpdating() { update_pausing_ = true; }
// 继续节点更新 // 继续角色更新
inline void ResumeUpdating() { update_pausing_ = false; } inline void ResumeUpdating() { update_pausing_ = false; }
// 节点更新是否暂停 // 角色更新是否暂停
inline bool IsUpdatePausing() const { return update_pausing_; } inline bool IsUpdatePausing() const { return update_pausing_; }
// 设置更新时的回调函数 // 设置更新时的回调函数
@ -394,7 +394,7 @@ namespace kiwano
// 获取更新时的回调函数 // 获取更新时的回调函数
inline UpdateCallback GetCallbackOnUpdate() const { return cb_update_; } inline UpdateCallback GetCallbackOnUpdate() const { return cb_update_; }
// 渲染节点边界 // 渲染角色边界
inline void ShowBorder(bool show) { show_border_ = show; } inline void ShowBorder(bool show) { show_border_ = show; }
// 设置默认锚点 // 设置默认锚点
@ -422,7 +422,7 @@ namespace kiwano
void Reorder(); void Reorder();
void SetScene(Scene* scene); void SetStage(Stage* scene);
protected: protected:
bool visible_; bool visible_;
@ -435,8 +435,8 @@ namespace kiwano
int z_order_; int z_order_;
float opacity_; float opacity_;
float displayed_opacity_; float displayed_opacity_;
Node* parent_; Actor* parent_;
Scene* scene_; Stage* stage_;
size_t hash_name_; size_t hash_name_;
Point anchor_; Point anchor_;
Size size_; Size size_;
@ -452,9 +452,9 @@ namespace kiwano
}; };
// 可视化节点 // 可视化角色
class KGE_API VisualNode class KGE_API VisualNode
: public Node : public Actor
{ {
public: public:
virtual void PrepareRender() override; virtual void PrepareRender() override;

View File

@ -51,7 +51,7 @@ namespace kiwano
frames_ = frames; frames_ = frames;
} }
void Animation::Init(NodePtr target) void Animation::Init(ActorPtr target)
{ {
if (!frames_ || frames_->GetFrames().empty()) if (!frames_ || frames_->GetFrames().empty())
{ {
@ -66,7 +66,7 @@ namespace kiwano
} }
} }
void Animation::UpdateTween(NodePtr target, float percent) void Animation::UpdateTween(ActorPtr target, float percent)
{ {
auto sprite_target = dynamic_cast<Sprite*>(target.Get()); auto sprite_target = dynamic_cast<Sprite*>(target.Get());

View File

@ -53,9 +53,9 @@ namespace kiwano
ActionPtr Reverse() const override; ActionPtr Reverse() const override;
protected: protected:
void Init(NodePtr target) override; void Init(ActorPtr target) override;
void UpdateTween(NodePtr target, float percent) override; void UpdateTween(ActorPtr target, float percent) override;
protected: protected:
FramesPtr frames_; FramesPtr frames_;

View File

@ -19,7 +19,7 @@
// THE SOFTWARE. // THE SOFTWARE.
#pragma once #pragma once
#include "Node.h" #include "Actor.h"
#include "Font.hpp" #include "Font.hpp"
#include "TextStyle.hpp" #include "TextStyle.hpp"
#include "../renderer/TextRenderer.h" #include "../renderer/TextRenderer.h"

View File

@ -19,7 +19,7 @@
// THE SOFTWARE. // THE SOFTWARE.
#pragma once #pragma once
#include "Node.h" #include "Actor.h"
namespace kiwano namespace kiwano
{ {

View File

@ -19,7 +19,7 @@
// THE SOFTWARE. // THE SOFTWARE.
#pragma once #pragma once
#include "Node.h" #include "Actor.h"
#include "../base/Resource.h" #include "../base/Resource.h"
#include "../renderer/render.h" #include "../renderer/render.h"

View File

@ -52,7 +52,7 @@ namespace kiwano
if (!swallow_) if (!swallow_)
{ {
NodePtr prev; ActorPtr prev;
for (auto child = children_.Last(); child; child = prev) for (auto child = children_.Last(); child; child = prev)
{ {
prev = child->PrevItem(); prev = child->PrevItem();

View File

@ -19,12 +19,12 @@
// THE SOFTWARE. // THE SOFTWARE.
#pragma once #pragma once
#include "Node.h" #include "Actor.h"
namespace kiwano namespace kiwano
{ {
class KGE_API Layer class KGE_API Layer
: public Node : public Actor
{ {
public: public:
Layer(); Layer();

View File

@ -19,12 +19,12 @@
// THE SOFTWARE. // THE SOFTWARE.
#pragma once #pragma once
#include "Node.h" #include "Actor.h"
#include "../renderer/render.h" // ID2D1Geometry #include "../renderer/render.h" // ID2D1Geometry
namespace kiwano namespace kiwano
{ {
// 二维图形节点 // śţÎŹÍźĐνÇÉŤ
class KGE_API ShapeNode class KGE_API ShapeNode
: public VisualNode : public VisualNode
{ {
@ -144,7 +144,7 @@ namespace kiwano
}; };
// 矩形节点 // žŘĐνÇÉŤ
class KGE_API RectNode class KGE_API RectNode
: public ShapeNode : public ShapeNode
{ {
@ -171,7 +171,7 @@ namespace kiwano
}; };
// 圆角矩形节点 // Ô˛˝ÇžŘĐνÇÉŤ
class KGE_API RoundedRectNode class KGE_API RoundedRectNode
: public ShapeNode : public ShapeNode
{ {
@ -214,7 +214,7 @@ namespace kiwano
}; };
// 圆形节点 // Ô˛ĐνÇÉŤ
class KGE_API CircleNode class KGE_API CircleNode
: public ShapeNode : public ShapeNode
{ {
@ -251,7 +251,7 @@ namespace kiwano
}; };
// 椭圆节点 // ÍÖÔ˛˝ÇÉŤ
class KGE_API EllipseNode class KGE_API EllipseNode
: public ShapeNode : public ShapeNode
{ {
@ -294,7 +294,7 @@ namespace kiwano
}; };
// 路径节点 // ¡žś˝ÇÉŤ
class KGE_API PathNode class KGE_API PathNode
: public ShapeNode : public ShapeNode
{ {

View File

@ -57,7 +57,7 @@ namespace kiwano
{ {
image_ = image; image_ = image;
Node::SetSize(image_->GetWidth(), image_->GetHeight()); Actor::SetSize(image_->GetWidth(), image_->GetHeight());
return true; return true;
} }
return false; return false;
@ -76,7 +76,7 @@ namespace kiwano
void Sprite::Crop(const Rect& crop_rect) void Sprite::Crop(const Rect& crop_rect)
{ {
image_->Crop(crop_rect); image_->Crop(crop_rect);
Node::SetSize( Actor::SetSize(
std::min(std::max(crop_rect.size.x, 0.f), image_->GetSourceWidth() - image_->GetCropX()), std::min(std::max(crop_rect.size.x, 0.f), image_->GetSourceWidth() - image_->GetCropX()),
std::min(std::max(crop_rect.size.y, 0.f), image_->GetSourceHeight() - image_->GetCropY()) std::min(std::max(crop_rect.size.y, 0.f), image_->GetSourceHeight() - image_->GetCropY())
); );

View File

@ -19,7 +19,7 @@
// THE SOFTWARE. // THE SOFTWARE.
#pragma once #pragma once
#include "Node.h" #include "Actor.h"
#include "Image.h" #include "Image.h"
namespace kiwano namespace kiwano

View File

@ -18,32 +18,32 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE. // THE SOFTWARE.
#include "Scene.h" #include "Stage.h"
#include "../base/logs.h" #include "../base/logs.h"
#include "../renderer/render.h" #include "../renderer/render.h"
namespace kiwano namespace kiwano
{ {
Scene::Scene() Stage::Stage()
{ {
scene_ = this; stage_ = this;
SetAnchor(0, 0); SetAnchor(0, 0);
SetSize(Renderer::Instance()->GetOutputSize()); SetSize(Renderer::Instance()->GetOutputSize());
} }
Scene::~Scene() Stage::~Stage()
{ {
} }
void Scene::OnEnter() void Stage::OnEnter()
{ {
KGE_LOG(L"Scene entered"); KGE_LOG(L"Stage entered");
} }
void Scene::OnExit() void Stage::OnExit()
{ {
KGE_LOG(L"Scene exited"); KGE_LOG(L"Stage exited");
} }
} }

View File

@ -19,21 +19,21 @@
// THE SOFTWARE. // THE SOFTWARE.
#pragma once #pragma once
#include "Node.h" #include "Actor.h"
namespace kiwano namespace kiwano
{ {
// ³¡¾° // ³¡¾°
class KGE_API Scene class KGE_API Stage
: public Node : public Actor
{ {
friend class Transition; friend class Transition;
friend class Stage; friend class Director;
public: public:
Scene(); Stage();
virtual ~Scene(); virtual ~Stage();
// ½øÈ볡¾° // ½øÈ볡¾°
virtual void OnEnter(); virtual void OnEnter();

View File

@ -19,7 +19,7 @@
// THE SOFTWARE. // THE SOFTWARE.
#pragma once #pragma once
#include "Node.h" #include "Actor.h"
#include "Font.hpp" #include "Font.hpp"
#include "TextStyle.hpp" #include "TextStyle.hpp"
#include <dwrite.h> #include <dwrite.h>

View File

@ -19,8 +19,8 @@
// THE SOFTWARE. // THE SOFTWARE.
#include "Transition.h" #include "Transition.h"
#include "Node.h" #include "Actor.h"
#include "Scene.h" #include "Stage.h"
#include "../base/window.h" #include "../base/window.h"
#include "../base/logs.h" #include "../base/logs.h"
#include "../renderer/render.h" #include "../renderer/render.h"
@ -55,7 +55,7 @@ namespace kiwano
return done_; return done_;
} }
void Transition::Init(ScenePtr prev, ScenePtr next) void Transition::Init(StagePtr prev, StagePtr next)
{ {
process_ = 0; process_ = 0;
delta_ = Duration{}; delta_ = Duration{};
@ -147,7 +147,7 @@ namespace kiwano
{ {
} }
void BoxTransition::Init(ScenePtr prev, ScenePtr next) void BoxTransition::Init(StagePtr prev, StagePtr next)
{ {
Transition::Init(prev, next); Transition::Init(prev, next);
@ -189,7 +189,7 @@ namespace kiwano
{ {
} }
void EmergeTransition::Init(ScenePtr prev, ScenePtr next) void EmergeTransition::Init(StagePtr prev, StagePtr next)
{ {
Transition::Init(prev, next); Transition::Init(prev, next);
@ -214,7 +214,7 @@ namespace kiwano
{ {
} }
void FadeTransition::Init(ScenePtr prev, ScenePtr next) void FadeTransition::Init(StagePtr prev, StagePtr next)
{ {
Transition::Init(prev, next); Transition::Init(prev, next);
@ -248,7 +248,7 @@ namespace kiwano
{ {
} }
void MoveTransition::Init(ScenePtr prev, ScenePtr next) void MoveTransition::Init(StagePtr prev, StagePtr next)
{ {
Transition::Init(prev, next); Transition::Init(prev, next);
@ -327,7 +327,7 @@ namespace kiwano
{ {
} }
void RotationTransition::Init(ScenePtr prev, ScenePtr next) void RotationTransition::Init(StagePtr prev, StagePtr next)
{ {
Transition::Init(prev, next); Transition::Init(prev, next);

View File

@ -24,13 +24,13 @@
namespace kiwano namespace kiwano
{ {
class Stage; class Director;
// ³¡¾°¹ý¶É // ³¡¾°¹ý¶É
class KGE_API Transition class KGE_API Transition
: public Object : public Object
{ {
friend class Stage; friend class Director;
public: public:
explicit Transition( explicit Transition(
@ -43,8 +43,8 @@ namespace kiwano
protected: protected:
virtual void Init( virtual void Init(
ScenePtr prev, StagePtr prev,
ScenePtr next StagePtr next
); );
virtual void Update(Duration dt); virtual void Update(Duration dt);
@ -61,8 +61,8 @@ namespace kiwano
Duration duration_; Duration duration_;
Duration delta_; Duration delta_;
Size window_size_; Size window_size_;
ScenePtr out_scene_; StagePtr out_scene_;
ScenePtr in_scene_; StagePtr in_scene_;
ComPtr<ID2D1Layer> out_layer_; ComPtr<ID2D1Layer> out_layer_;
ComPtr<ID2D1Layer> in_layer_; ComPtr<ID2D1Layer> in_layer_;
LayerProperties out_layer_prop_; LayerProperties out_layer_prop_;
@ -84,8 +84,8 @@ namespace kiwano
void Update(Duration dt) override; void Update(Duration dt) override;
virtual void Init( virtual void Init(
ScenePtr prev, StagePtr prev,
ScenePtr next StagePtr next
) override; ) override;
}; };
@ -103,8 +103,8 @@ namespace kiwano
void Update(Duration dt) override; void Update(Duration dt) override;
virtual void Init( virtual void Init(
ScenePtr prev, StagePtr prev,
ScenePtr next StagePtr next
) override; ) override;
}; };
@ -122,8 +122,8 @@ namespace kiwano
void Update(Duration dt) override; void Update(Duration dt) override;
virtual void Init( virtual void Init(
ScenePtr prev, StagePtr prev,
ScenePtr next StagePtr next
) override; ) override;
}; };
@ -142,8 +142,8 @@ namespace kiwano
void Update(Duration dt) override; void Update(Duration dt) override;
virtual void Init( virtual void Init(
ScenePtr prev, StagePtr prev,
ScenePtr next StagePtr next
) override; ) override;
void Reset() override; void Reset() override;
@ -169,8 +169,8 @@ namespace kiwano
void Update(Duration dt) override; void Update(Duration dt) override;
virtual void Init( virtual void Init(
ScenePtr prev, StagePtr prev,
ScenePtr next StagePtr next
) override; ) override;
void Reset() override; void Reset() override;

View File

@ -38,8 +38,8 @@ namespace kiwano
KGE_DECLARE_SMART_PTR(GifImage); KGE_DECLARE_SMART_PTR(GifImage);
KGE_DECLARE_SMART_PTR(Frames); KGE_DECLARE_SMART_PTR(Frames);
KGE_DECLARE_SMART_PTR(Node); KGE_DECLARE_SMART_PTR(Actor);
KGE_DECLARE_SMART_PTR(Scene); KGE_DECLARE_SMART_PTR(Stage);
KGE_DECLARE_SMART_PTR(Layer); KGE_DECLARE_SMART_PTR(Layer);
KGE_DECLARE_SMART_PTR(Sprite); KGE_DECLARE_SMART_PTR(Sprite);
KGE_DECLARE_SMART_PTR(GifSprite); KGE_DECLARE_SMART_PTR(GifSprite);

View File

@ -18,26 +18,26 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE. // THE SOFTWARE.
#include "Stage.h" #include "Director.h"
#include "../2d/Node.h" #include "../2d/Actor.h"
#include "../2d/Scene.h" #include "../2d/Stage.h"
#include "../2d/Transition.h" #include "../2d/Transition.h"
#include "../2d/DebugNode.h" #include "../2d/DebugNode.h"
namespace kiwano namespace kiwano
{ {
Stage::Stage() Director::Director()
: render_border_enabled_(false) : render_border_enabled_(false)
{ {
} }
Stage::~Stage() Director::~Director()
{ {
} }
void Stage::EnterScene(ScenePtr scene) void Director::EnterStage(StagePtr scene)
{ {
KGE_ASSERT(scene && "Stage::EnterScene failed, NULL pointer exception"); KGE_ASSERT(scene && "Director::EnterStage failed, NULL pointer exception");
if (curr_scene_ == scene || next_scene_ == scene) if (curr_scene_ == scene || next_scene_ == scene)
return; return;
@ -45,9 +45,9 @@ namespace kiwano
next_scene_ = scene; next_scene_ = scene;
} }
void Stage::EnterScene(ScenePtr scene, TransitionPtr transition) void Director::EnterStage(StagePtr scene, TransitionPtr transition)
{ {
EnterScene(scene); EnterStage(scene);
if (transition && next_scene_) if (transition && next_scene_)
{ {
@ -60,17 +60,17 @@ namespace kiwano
} }
} }
ScenePtr Stage::GetCurrentScene() StagePtr Director::GetCurrentStage()
{ {
return curr_scene_; return curr_scene_;
} }
void Stage::SetRenderBorderEnabled(bool enabled) void Director::SetRenderBorderEnabled(bool enabled)
{ {
render_border_enabled_ = enabled; render_border_enabled_ = enabled;
} }
void Stage::ShowDebugInfo(bool show) void Director::ShowDebugInfo(bool show)
{ {
if (show) if (show)
{ {
@ -83,7 +83,7 @@ namespace kiwano
} }
} }
void Stage::OnUpdate(Duration dt) void Director::OnUpdate(Duration dt)
{ {
if (transition_) if (transition_)
{ {
@ -116,7 +116,7 @@ namespace kiwano
debug_node_->Update(dt); debug_node_->Update(dt);
} }
void Stage::OnRender() void Director::OnRender()
{ {
if (transition_) if (transition_)
{ {
@ -131,7 +131,7 @@ namespace kiwano
debug_node_->Render(); debug_node_->Render();
} }
void Stage::AfterRender() void Director::AfterRender()
{ {
if (render_border_enabled_) if (render_border_enabled_)
{ {
@ -140,7 +140,7 @@ namespace kiwano
} }
} }
void Stage::HandleEvent(Event& evt) void Director::HandleEvent(Event& evt)
{ {
if (debug_node_) if (debug_node_)
debug_node_->Dispatch(evt); debug_node_->Dispatch(evt);

View File

@ -26,28 +26,28 @@
namespace kiwano namespace kiwano
{ {
class KGE_API Stage class KGE_API Director
: public Singleton<Stage> : public Singleton<Director>
, public Component , public Component
{ {
KGE_DECLARE_SINGLETON(Stage); KGE_DECLARE_SINGLETON(Director);
public: public:
// 切换场景 // 切换场景
void EnterScene( void EnterStage(
ScenePtr scene /* 场景 */ StagePtr scene /* 场景 */
); );
// 切换场景 // 切换场景
void EnterScene( void EnterStage(
ScenePtr scene, /* 场景 */ StagePtr scene, /* 场景 */
TransitionPtr transition /* 场景动画 */ TransitionPtr transition /* 场景动画 */
); );
// 获取当前场景 // 获取当前场景
ScenePtr GetCurrentScene(); StagePtr GetCurrentStage();
// 启用或禁用场景内的节点边界渲染功能 // 启用或禁用角色边界渲染功能
void SetRenderBorderEnabled(bool enabled); void SetRenderBorderEnabled(bool enabled);
// 显示调试信息 // 显示调试信息
@ -67,15 +67,15 @@ namespace kiwano
void HandleEvent(Event& evt) override; void HandleEvent(Event& evt) override;
protected: protected:
Stage(); Director();
virtual ~Stage(); virtual ~Director();
protected: protected:
bool render_border_enabled_; bool render_border_enabled_;
ScenePtr curr_scene_; StagePtr curr_scene_;
ScenePtr next_scene_; StagePtr next_scene_;
NodePtr debug_node_; ActorPtr debug_node_;
TransitionPtr transition_; TransitionPtr transition_;
}; };
} }

View File

@ -105,7 +105,7 @@ namespace kiwano
void* data; void* data;
}; };
class Node; class Actor;
// 事件 // 事件
struct KGE_API Event struct KGE_API Event
@ -145,7 +145,7 @@ namespace kiwano
}; };
UINT type; UINT type;
Node* target; Actor* target;
union union
{ {

View File

@ -63,7 +63,7 @@
#include "base/time.h" #include "base/time.h"
#include "base/window.h" #include "base/window.h"
#include "base/input.h" #include "base/input.h"
#include "base/Stage.h" #include "base/Director.h"
#include "base/logs.h" #include "base/logs.h"
#include "renderer/render.h" #include "renderer/render.h"
#include "platform/modules.h" #include "platform/modules.h"
@ -94,8 +94,8 @@
#include "2d/ActionManager.h" #include "2d/ActionManager.h"
#include "2d/Transition.h" #include "2d/Transition.h"
#include "2d/Node.h" #include "2d/Actor.h"
#include "2d/Scene.h" #include "2d/Stage.h"
#include "2d/Layer.h" #include "2d/Layer.h"
#include "2d/Sprite.h" #include "2d/Sprite.h"
#include "2d/GifSprite.h" #include "2d/GifSprite.h"

View File

@ -23,7 +23,7 @@
#include "../base/window.h" #include "../base/window.h"
#include "../base/logs.h" #include "../base/logs.h"
#include "../base/input.h" #include "../base/input.h"
#include "../base/Stage.h" #include "../base/Director.h"
#include "../renderer/render.h" #include "../renderer/render.h"
#include <windowsx.h> // GET_X_LPARAM, GET_Y_LPARAM #include <windowsx.h> // GET_X_LPARAM, GET_Y_LPARAM
#include <imm.h> // ImmAssociateContext #include <imm.h> // ImmAssociateContext
@ -66,7 +66,7 @@ namespace kiwano
Use(Renderer::Instance()); Use(Renderer::Instance());
Use(Input::Instance()); Use(Input::Instance());
Use(Stage::Instance()); Use(Director::Instance());
} }
Application::~Application() Application::~Application()
@ -100,7 +100,7 @@ namespace kiwano
if (options.debug) if (options.debug)
{ {
Stage::Instance()->ShowDebugInfo(true); Director::Instance()->ShowDebugInfo(true);
Renderer::Instance()->SetCollectingStatus(true); Renderer::Instance()->SetCollectingStatus(true);
} }
@ -158,7 +158,7 @@ namespace kiwano
} }
// Destroy all instances // Destroy all instances
Stage::Destroy(); Director::Destroy();
Input::Destroy(); Input::Destroy();
Renderer::Destroy(); Renderer::Destroy();
Window::Destroy(); Window::Destroy();

View File

@ -19,7 +19,7 @@
// THE SOFTWARE. // THE SOFTWARE.
#include "Button.h" #include "Button.h"
#include "../2d/Scene.h" #include "../2d/Stage.h"
#include "../base/window.h" #include "../base/window.h"
namespace kiwano namespace kiwano
@ -145,4 +145,4 @@ namespace kiwano
} }
} }
} }

View File

@ -25,7 +25,7 @@ namespace kiwano
{ {
// 꽉데 // 꽉데
class KGE_API Menu class KGE_API Menu
: public Node : public Actor
{ {
public: public:
Menu(); Menu();