diff --git a/projects/kiwano.vcxproj b/projects/kiwano.vcxproj index ca18ef82..9d80d8fb 100644 --- a/projects/kiwano.vcxproj +++ b/projects/kiwano.vcxproj @@ -2,7 +2,7 @@ - + @@ -23,8 +23,8 @@ - - + + @@ -97,8 +97,8 @@ - - + + @@ -109,7 +109,7 @@ - + diff --git a/projects/kiwano.vcxproj.filters b/projects/kiwano.vcxproj.filters index f8fc490f..f98d06cf 100644 --- a/projects/kiwano.vcxproj.filters +++ b/projects/kiwano.vcxproj.filters @@ -84,12 +84,6 @@ 2d - - 2d - - - 2d - 2d @@ -267,9 +261,15 @@ 2d - + base + + 2d + + + 2d + @@ -311,12 +311,6 @@ 2d - - 2d - - - 2d - 2d @@ -407,8 +401,14 @@ 2d - + base + + 2d + + + 2d + \ No newline at end of file diff --git a/src/kiwano/2d/Action.cpp b/src/kiwano/2d/Action.cpp index 759b2989..f156283a 100644 --- a/src/kiwano/2d/Action.cpp +++ b/src/kiwano/2d/Action.cpp @@ -19,7 +19,7 @@ // THE SOFTWARE. #include "Action.h" -#include "Node.h" +#include "Actor.h" 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); } - void Action::UpdateStep(NodePtr target, Duration dt) + void Action::UpdateStep(ActorPtr target, Duration dt) { elapsed_ += dt; @@ -81,7 +81,7 @@ namespace kiwano } } - void Action::Complete(NodePtr target) + void Action::Complete(ActorPtr target) { if (cb_loop_done_) cb_loop_done_(); @@ -99,7 +99,7 @@ namespace kiwano ++loops_done_; } - void Action::Restart(NodePtr target) + void Action::Restart(ActorPtr target) { status_ = Status::NotStarted; elapsed_ = 0; diff --git a/src/kiwano/2d/Action.h b/src/kiwano/2d/Action.h index fe3e6c28..923306ad 100644 --- a/src/kiwano/2d/Action.h +++ b/src/kiwano/2d/Action.h @@ -64,7 +64,7 @@ namespace kiwano // 设置循环次数 (-1 为永久循环) inline void SetLoops(int loops) { loops_ = loops; } - // 动作结束时移除目标节点 + // 动作结束时移除目标角色 inline void RemoveTargetWhenDone() { detach_target_ = true; } // 设置动作结束时的回调函数 @@ -100,15 +100,15 @@ namespace kiwano inline ActionCallback GetLoopDoneCallback() const { return cb_loop_done_; } 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: Status status_; diff --git a/src/kiwano/2d/ActionGroup.cpp b/src/kiwano/2d/ActionGroup.cpp index 4976cb32..a4ae0588 100644 --- a/src/kiwano/2d/ActionGroup.cpp +++ b/src/kiwano/2d/ActionGroup.cpp @@ -19,7 +19,7 @@ // THE SOFTWARE. #include "ActionGroup.h" -#include "Node.h" +#include "Actor.h" #include "../base/logs.h" namespace kiwano @@ -43,7 +43,7 @@ namespace kiwano { } - void ActionGroup::Init(NodePtr target) + void ActionGroup::Init(ActorPtr target) { 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_) { diff --git a/src/kiwano/2d/ActionGroup.h b/src/kiwano/2d/ActionGroup.h index 7615f177..96b45f3e 100644 --- a/src/kiwano/2d/ActionGroup.h +++ b/src/kiwano/2d/ActionGroup.h @@ -60,10 +60,10 @@ namespace kiwano 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: bool sequence_; diff --git a/src/kiwano/2d/ActionHelper.h b/src/kiwano/2d/ActionHelper.h index ea404de1..4ceff047 100644 --- a/src/kiwano/2d/ActionHelper.h +++ b/src/kiwano/2d/ActionHelper.h @@ -39,7 +39,7 @@ namespace kiwano // 设置动作循环结束时的回调函数 inline ActionHelper& SetLoopDoneCallback(ActionCallback const& cb) { base->SetLoopDoneCallback(cb); 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& RemoveTargetWhenDone() { base->RemoveTargetWhenDone(); return (*this); } // 设置名称 diff --git a/src/kiwano/2d/ActionManager.cpp b/src/kiwano/2d/ActionManager.cpp index 13c3ed76..5bf7fa2c 100644 --- a/src/kiwano/2d/ActionManager.cpp +++ b/src/kiwano/2d/ActionManager.cpp @@ -19,12 +19,12 @@ // THE SOFTWARE. #include "ActionManager.h" -#include "Node.h" +#include "Actor.h" #include "../base/logs.h" namespace kiwano { - void ActionManager::UpdateActions(NodePtr target, Duration dt) + void ActionManager::UpdateActions(ActorPtr target, Duration dt) { if (actions_.IsEmpty() || !target) return; diff --git a/src/kiwano/2d/ActionManager.h b/src/kiwano/2d/ActionManager.h index 1e6b0978..4fc7cdd2 100644 --- a/src/kiwano/2d/ActionManager.h +++ b/src/kiwano/2d/ActionManager.h @@ -51,7 +51,7 @@ namespace kiwano Actions const& GetAllActions() const; protected: - void UpdateActions(NodePtr target, Duration dt); + void UpdateActions(ActorPtr target, Duration dt); protected: Actions actions_; diff --git a/src/kiwano/2d/ActionTween.cpp b/src/kiwano/2d/ActionTween.cpp index 437ea893..279be38d 100644 --- a/src/kiwano/2d/ActionTween.cpp +++ b/src/kiwano/2d/ActionTween.cpp @@ -20,7 +20,7 @@ #include "ActionTween.h" #include "include-forwards.h" -#include "Node.h" +#include "Actor.h" namespace kiwano { @@ -98,7 +98,7 @@ namespace kiwano return dur_; } - void ActionTween::Update(NodePtr target, Duration dt) + void ActionTween::Update(ActorPtr target, Duration dt) { float percent; @@ -142,7 +142,7 @@ namespace kiwano delta_pos_ = vector; } - void ActionMoveBy::Init(NodePtr target) + void ActionMoveBy::Init(ActorPtr 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_; start_pos_ = start_pos_ + diff; @@ -182,7 +182,7 @@ namespace kiwano return new (std::nothrow) ActionMoveTo(dur_, end_pos_, ease_func_); } - void ActionMoveTo::Init(NodePtr target) + void ActionMoveTo::Init(ActorPtr target) { ActionMoveBy::Init(target); delta_pos_ = end_pos_ - start_pos_; @@ -211,7 +211,7 @@ namespace kiwano return new (std::nothrow) ActionJumpBy(dur_, -delta_pos_, height_, jumps_, ease_func_); } - void ActionJumpBy::Init(NodePtr target) + void ActionJumpBy::Init(ActorPtr 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 x = delta_pos_.x * percent; @@ -246,7 +246,7 @@ namespace kiwano 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); delta_pos_ = end_pos_ - start_pos_; @@ -271,7 +271,7 @@ namespace kiwano { } - void ActionScaleBy::Init(NodePtr target) + void ActionScaleBy::Init(ActorPtr 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); } @@ -314,7 +314,7 @@ namespace kiwano 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); 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) { @@ -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); } @@ -375,7 +375,7 @@ namespace kiwano { } - void ActionRotateBy::Init(NodePtr target) + void ActionRotateBy::Init(ActorPtr 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; if (rotation > 360.f) @@ -413,7 +413,7 @@ namespace kiwano return new (std::nothrow) ActionRotateTo(dur_, end_val_, ease_func_); } - void ActionRotateTo::Init(NodePtr target) + void ActionRotateTo::Init(ActorPtr target) { ActionRotateBy::Init(target); delta_val_ = end_val_ - start_val_; @@ -481,7 +481,7 @@ namespace kiwano return false; } - void ActionPath::Init(NodePtr target) + void ActionPath::Init(ActorPtr target) { 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); @@ -647,13 +647,13 @@ namespace kiwano return new ActionCustom(dur_, tween_func_); } - void ActionCustom::Init(NodePtr target) + void ActionCustom::Init(ActorPtr target) { if (!tween_func_) this->Done(); } - void ActionCustom::UpdateTween(NodePtr target, float percent) + void ActionCustom::UpdateTween(ActorPtr target, float percent) { if (tween_func_) tween_func_(target, percent); diff --git a/src/kiwano/2d/ActionTween.h b/src/kiwano/2d/ActionTween.h index 598db22b..230eee75 100644 --- a/src/kiwano/2d/ActionTween.h +++ b/src/kiwano/2d/ActionTween.h @@ -90,9 +90,9 @@ namespace kiwano void SetDuration(Duration duration); 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: Duration dur_; @@ -118,9 +118,9 @@ namespace kiwano ActionPtr Reverse() const override; 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: Point start_pos_; @@ -151,7 +151,7 @@ namespace kiwano } protected: - void Init(NodePtr target) override; + void Init(ActorPtr target) override; protected: Point end_pos_; @@ -178,9 +178,9 @@ namespace kiwano ActionPtr Reverse() const override; 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: Point start_pos_; @@ -215,7 +215,7 @@ namespace kiwano } protected: - void Init(NodePtr target) override; + void Init(ActorPtr target) override; protected: Point end_pos_; @@ -247,9 +247,9 @@ namespace kiwano ActionPtr Reverse() const override; 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: float start_scale_x_; @@ -288,7 +288,7 @@ namespace kiwano } protected: - void Init(NodePtr target) override; + void Init(ActorPtr target) override; protected: float end_scale_x_; @@ -318,9 +318,9 @@ namespace kiwano } 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: float start_val_; @@ -373,9 +373,9 @@ namespace kiwano ActionPtr Reverse() const override; 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: float start_val_; @@ -405,7 +405,7 @@ namespace kiwano } protected: - void Init(NodePtr target) override; + void Init(ActorPtr target) override; protected: float end_val_; @@ -481,9 +481,9 @@ namespace kiwano inline void SetGeometry(ComPtr geo) { geo_ = geo; } 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: bool path_beginning_; @@ -502,7 +502,7 @@ namespace kiwano : public ActionTween { public: - using TweenFunc = Closure; + using TweenFunc = Closure; ActionCustom( Duration duration, /* 持续时长 */ @@ -521,9 +521,9 @@ namespace kiwano } 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: TweenFunc tween_func_; diff --git a/src/kiwano/2d/Node.cpp b/src/kiwano/2d/Actor.cpp similarity index 74% rename from src/kiwano/2d/Node.cpp rename to src/kiwano/2d/Actor.cpp index 6b42f464..9efd36df 100644 --- a/src/kiwano/2d/Node.cpp +++ b/src/kiwano/2d/Actor.cpp @@ -18,9 +18,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#include "Node.h" +#include "Actor.h" #include "Action.h" -#include "Scene.h" +#include "Stage.h" #include "../base/logs.h" #include "../renderer/render.h" @@ -32,13 +32,13 @@ namespace kiwano 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_y = anchor_y; } - Node::Node() + Actor::Actor() : visible_(true) , update_pausing_(false) , hover_(false) @@ -50,7 +50,7 @@ namespace kiwano , show_border_(false) , is_fast_transform_(true) , parent_(nullptr) - , scene_(nullptr) + , stage_(nullptr) , hash_name_(0) , z_order_(0) , opacity_(1.f) @@ -59,7 +59,7 @@ namespace kiwano { } - void Node::Update(Duration dt) + void Actor::Update(Duration dt) { if (!update_pausing_) { @@ -74,7 +74,7 @@ namespace kiwano if (!children_.IsEmpty()) { - NodePtr next; + ActorPtr next; for (auto child = children_.First(); child; child = next) { next = child->NextItem(); @@ -83,7 +83,7 @@ namespace kiwano } } - void Node::Render() + void Actor::Render() { if (!visible_) return; @@ -98,7 +98,7 @@ namespace kiwano else { // render children those are less than 0 in Z-Order - Node* child = children_.First().Get(); + Actor* child = children_.First().Get(); while (child) { if (child->GetZOrder() >= 0) @@ -119,7 +119,7 @@ namespace kiwano } } - void Node::RenderBorder() + void Actor::RenderBorder() { if (show_border_) { @@ -137,12 +137,12 @@ namespace kiwano } } - void Node::Dispatch(Event& evt) + void Actor::Dispatch(Event& evt) { if (!visible_) return; - NodePtr prev; + ActorPtr prev; for (auto child = children_.Last(); child; child = prev) { prev = child->PrevItem(); @@ -198,13 +198,13 @@ namespace kiwano EventDispatcher::Dispatch(evt); } - Matrix const & Node::GetTransformMatrix() const + Matrix const & Actor::GetTransformMatrix() const { UpdateTransform(); return transform_matrix_; } - Matrix const & Node::GetTransformInverseMatrix() const + Matrix const & Actor::GetTransformInverseMatrix() const { UpdateTransform(); if (dirty_transform_inverse_) @@ -215,7 +215,7 @@ namespace kiwano return transform_matrix_inverse_; } - void Node::UpdateTransform() const + void Actor::UpdateTransform() const { if (!dirty_transform_) return; @@ -246,11 +246,11 @@ namespace kiwano } // 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; } - void Node::UpdateOpacity() + void Actor::UpdateOpacity() { if (parent_ && parent_->IsCascadeOpacityEnabled()) { @@ -261,33 +261,33 @@ namespace kiwano 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(); } } - void Node::SetScene(Scene* scene) + void Actor::SetStage(Stage* scene) { - if (scene && scene_ != scene) + if (scene && stage_ != scene) { - scene_ = scene; - for (Node* child = children_.First().Get(); child; child = child->NextItem().Get()) + stage_ = scene; + 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_) { - NodePtr me = this; + ActorPtr me = this; parent_->children_.Remove(me); - Node* sibling = parent_->children_.Last().Get(); + Actor* sibling = parent_->children_.Last().Get(); 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) { @@ -320,7 +320,7 @@ namespace kiwano } } - void Node::SetOpacity(float opacity) + void Actor::SetOpacity(float opacity) { if (opacity_ == opacity) return; @@ -329,7 +329,7 @@ namespace kiwano UpdateOpacity(); } - void Node::SetCascadeOpacityEnabled(bool enabled) + void Actor::SetCascadeOpacityEnabled(bool enabled) { if (cascade_opacity_ == enabled) return; @@ -338,17 +338,17 @@ namespace kiwano UpdateOpacity(); } - void Node::SetAnchorX(float anchor_x) + void Actor::SetAnchorX(float anchor_x) { this->SetAnchor(anchor_x, anchor_.y); } - void Node::SetAnchorY(float anchor_y) + void Actor::SetAnchorY(float 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) return; @@ -358,27 +358,27 @@ namespace kiwano dirty_transform_ = true; } - void Node::SetAnchor(Point const& anchor) + void Actor::SetAnchor(Point const& anchor) { this->SetAnchor(anchor.x, anchor.y); } - void Node::SetWidth(float width) + void Actor::SetWidth(float width) { this->SetSize(width, size_.y); } - void Node::SetHeight(float height) + void Actor::SetHeight(float height) { this->SetSize(size_.x, height); } - void Node::SetSize(const Size& size) + void Actor::SetSize(const Size& size) { 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) return; @@ -388,19 +388,19 @@ namespace kiwano dirty_transform_ = true; } - void Node::SetTransform(Transform const& transform) + void Actor::SetTransform(Transform const& transform) { transform_ = transform; dirty_transform_ = true; is_fast_transform_ = false; } - void Node::SetVisible(bool val) + void Actor::SetVisible(bool val) { visible_ = val; } - void Node::SetName(String const& name) + void Actor::SetName(String const& 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); } - void Node::SetPositionY(float y) + void Actor::SetPositionY(float 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); } - void Node::SetPosition(float x, float y) + void Actor::SetPosition(float x, float y) { if (transform_.position.x == x && transform_.position.y == y) return; @@ -434,32 +434,32 @@ namespace kiwano 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); } - void Node::Move(const Point & v) + void Actor::Move(const Point & v) { 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); } - void Node::SetScaleY(float scale_y) + void Actor::SetScaleY(float scale_y) { this->SetScale(transform_.scale.x, scale_y); } - void Node::SetScale(float scale) + void Actor::SetScale(float 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) return; @@ -470,22 +470,22 @@ namespace kiwano is_fast_transform_ = false; } - void Node::SetScale(Point const& scale) + void Actor::SetScale(Point const& scale) { 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); } - void Node::SetSkewY(float skew_y) + void Actor::SetSkewY(float 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) return; @@ -496,12 +496,12 @@ namespace kiwano is_fast_transform_ = false; } - void Node::SetSkew(Point const& skew) + void Actor::SetSkew(Point const& skew) { this->SetSkew(skew.x, skew.y); } - void Node::SetRotation(float angle) + void Actor::SetRotation(float angle) { if (transform_.rotation == angle) return; @@ -511,9 +511,9 @@ namespace kiwano 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) { @@ -522,7 +522,7 @@ namespace kiwano if (child->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) KGE_ERROR_LOG(L"A node cannot be its own parent"); @@ -530,14 +530,14 @@ namespace kiwano children_.PushBack(child); child->parent_ = this; - child->SetScene(this->scene_); + child->SetStage(this->stage_); child->dirty_transform_ = true; child->UpdateOpacity(); child->Reorder(); } } - void Node::AddChildren(Array const& children) + void Actor::AddChildren(Array const& children) { for (const auto& node : children) { @@ -545,22 +545,22 @@ namespace kiwano } } - Rect Node::GetBounds() const + Rect Actor::GetBounds() const { return Rect(Point{}, size_); } - Rect Node::GetBoundingBox() const + Rect Actor::GetBoundingBox() const { return GetTransformMatrix().Transform(GetBounds()); } - Array Node::GetChildren(String const& name) const + Array Actor::GetChildren(String const& name) const { - Array children; + Array children; size_t hash_code = std::hash{}(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)) { @@ -570,11 +570,11 @@ namespace kiwano return children; } - NodePtr Node::GetChild(String const& name) const + ActorPtr Actor::GetChild(String const& name) const { size_t hash_code = std::hash{}(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)) { @@ -584,12 +584,12 @@ namespace kiwano return nullptr; } - Node::Children const & Node::GetChildren() const + Actor::Children const & Actor::GetChildren() const { return children_; } - void Node::RemoveFromParent() + void Actor::RemoveFromParent() { if (parent_) { @@ -597,14 +597,14 @@ namespace kiwano } } - void Node::RemoveChild(NodePtr child) + void Actor::RemoveChild(ActorPtr child) { 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()) return; @@ -612,12 +612,12 @@ namespace kiwano if (child) { child->parent_ = nullptr; - if (child->scene_) child->SetScene(nullptr); - children_.Remove(NodePtr(child)); + if (child->stage_) child->SetStage(nullptr); + children_.Remove(ActorPtr(child)); } } - void Node::RemoveChildren(String const& child_name) + void Actor::RemoveChildren(String const& child_name) { if (children_.IsEmpty()) { @@ -626,8 +626,8 @@ namespace kiwano size_t hash_code = std::hash{}(child_name); - Node* next; - for (Node* child = children_.First().Get(); child; child = next) + Actor* next; + for (Actor* child = children_.First().Get(); child; child = next) { next = child->NextItem().Get(); @@ -638,17 +638,17 @@ namespace kiwano } } - void Node::RemoveAllChildren() + void Actor::RemoveAllChildren() { children_.Clear(); } - void Node::SetResponsible(bool enable) + void Actor::SetResponsible(bool 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) return false; diff --git a/src/kiwano/2d/Node.h b/src/kiwano/2d/Actor.h similarity index 89% rename from src/kiwano/2d/Node.h rename to src/kiwano/2d/Actor.h index 5ecfc004..301b122f 100644 --- a/src/kiwano/2d/Node.h +++ b/src/kiwano/2d/Actor.h @@ -27,30 +27,30 @@ namespace kiwano { - class Stage; + class Director; - // 节点 - class KGE_API Node + // 角色 + class KGE_API Actor : public Object , public TimerManager , public ActionManager , public EventDispatcher - , public IntrusiveListItem + , public IntrusiveListItem { - friend class Stage; + friend class Director; friend class Transition; - friend class IntrusiveList; + friend class IntrusiveList; - using Children = IntrusiveList; + using Children = IntrusiveList; using UpdateCallback = Closure; public: - Node(); + Actor(); - // 更新节点 + // 更新角色 virtual void OnUpdate(Duration dt) { KGE_UNUSED(dt); } - // 渲染节点 + // 渲染角色 virtual void OnRender() {} // 获取显示状态 @@ -87,7 +87,7 @@ namespace kiwano 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; } @@ -146,11 +146,11 @@ namespace kiwano // 获取二维变换的逆矩阵 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( @@ -330,62 +330,62 @@ namespace kiwano bool enable ); - // 判断点是否在节点内 + // 判断点是否在角色内 bool ContainsPoint( const Point& point ) const; - // 添加子节点 + // 添加子角色 void AddChild( - NodePtr child + ActorPtr child ); - // 添加多个子节点 + // 添加多个子角色 void AddChildren( - Array const& children + Array const& children ); - // 获取所有名称相同的子节点 - Array GetChildren( + // 获取所有名称相同的子角色 + Array GetChildren( String const& name ) const; - // 获取名称相同的子节点 - NodePtr GetChild( + // 获取名称相同的子角色 + ActorPtr GetChild( String const& name ) const; - // 获取全部子节点 + // 获取全部子角色 Children const& GetChildren() const; - // 移除子节点 + // 移除子角色 void RemoveChild( - NodePtr child + ActorPtr child ); - // 移除子节点 + // 移除子角色 void RemoveChild( - Node* child + Actor* child ); - // 移除所有名称相同的子节点 + // 移除所有名称相同的子角色 void RemoveChildren( String const& child_name ); - // 移除所有节点 + // 移除所有角色 void RemoveAllChildren(); - // 从父节点移除 + // 从父角色移除 void RemoveFromParent(); - // 暂停节点更新 + // 暂停角色更新 inline void PauseUpdating() { update_pausing_ = true; } - // 继续节点更新 + // 继续角色更新 inline void ResumeUpdating() { update_pausing_ = false; } - // 节点更新是否暂停 + // 角色更新是否暂停 inline bool IsUpdatePausing() const { return update_pausing_; } // 设置更新时的回调函数 @@ -394,7 +394,7 @@ namespace kiwano // 获取更新时的回调函数 inline UpdateCallback GetCallbackOnUpdate() const { return cb_update_; } - // 渲染节点边界 + // 渲染角色边界 inline void ShowBorder(bool show) { show_border_ = show; } // 设置默认锚点 @@ -422,7 +422,7 @@ namespace kiwano void Reorder(); - void SetScene(Scene* scene); + void SetStage(Stage* scene); protected: bool visible_; @@ -435,8 +435,8 @@ namespace kiwano int z_order_; float opacity_; float displayed_opacity_; - Node* parent_; - Scene* scene_; + Actor* parent_; + Stage* stage_; size_t hash_name_; Point anchor_; Size size_; @@ -452,9 +452,9 @@ namespace kiwano }; - // 可视化节点 + // 可视化角色 class KGE_API VisualNode - : public Node + : public Actor { public: virtual void PrepareRender() override; diff --git a/src/kiwano/2d/Animation.cpp b/src/kiwano/2d/Animation.cpp index b8c9bbfc..6576923c 100644 --- a/src/kiwano/2d/Animation.cpp +++ b/src/kiwano/2d/Animation.cpp @@ -51,7 +51,7 @@ namespace kiwano frames_ = frames; } - void Animation::Init(NodePtr target) + void Animation::Init(ActorPtr target) { 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(target.Get()); diff --git a/src/kiwano/2d/Animation.h b/src/kiwano/2d/Animation.h index 5440c05e..609761f3 100644 --- a/src/kiwano/2d/Animation.h +++ b/src/kiwano/2d/Animation.h @@ -53,9 +53,9 @@ namespace kiwano ActionPtr Reverse() const override; 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: FramesPtr frames_; diff --git a/src/kiwano/2d/Canvas.h b/src/kiwano/2d/Canvas.h index 310db944..3af235d2 100644 --- a/src/kiwano/2d/Canvas.h +++ b/src/kiwano/2d/Canvas.h @@ -19,7 +19,7 @@ // THE SOFTWARE. #pragma once -#include "Node.h" +#include "Actor.h" #include "Font.hpp" #include "TextStyle.hpp" #include "../renderer/TextRenderer.h" diff --git a/src/kiwano/2d/DebugNode.h b/src/kiwano/2d/DebugNode.h index 40c0cf12..32988ef7 100644 --- a/src/kiwano/2d/DebugNode.h +++ b/src/kiwano/2d/DebugNode.h @@ -19,7 +19,7 @@ // THE SOFTWARE. #pragma once -#include "Node.h" +#include "Actor.h" namespace kiwano { diff --git a/src/kiwano/2d/GifSprite.h b/src/kiwano/2d/GifSprite.h index ed3aae54..5f124540 100644 --- a/src/kiwano/2d/GifSprite.h +++ b/src/kiwano/2d/GifSprite.h @@ -19,7 +19,7 @@ // THE SOFTWARE. #pragma once -#include "Node.h" +#include "Actor.h" #include "../base/Resource.h" #include "../renderer/render.h" diff --git a/src/kiwano/2d/Layer.cpp b/src/kiwano/2d/Layer.cpp index 5f4c8ba4..f2ffea4a 100644 --- a/src/kiwano/2d/Layer.cpp +++ b/src/kiwano/2d/Layer.cpp @@ -52,7 +52,7 @@ namespace kiwano if (!swallow_) { - NodePtr prev; + ActorPtr prev; for (auto child = children_.Last(); child; child = prev) { prev = child->PrevItem(); diff --git a/src/kiwano/2d/Layer.h b/src/kiwano/2d/Layer.h index 6d70be9a..1b48a530 100644 --- a/src/kiwano/2d/Layer.h +++ b/src/kiwano/2d/Layer.h @@ -19,12 +19,12 @@ // THE SOFTWARE. #pragma once -#include "Node.h" +#include "Actor.h" namespace kiwano { class KGE_API Layer - : public Node + : public Actor { public: Layer(); diff --git a/src/kiwano/2d/ShapeNode.h b/src/kiwano/2d/ShapeNode.h index 75d40318..3f9a9083 100644 --- a/src/kiwano/2d/ShapeNode.h +++ b/src/kiwano/2d/ShapeNode.h @@ -19,12 +19,12 @@ // THE SOFTWARE. #pragma once -#include "Node.h" +#include "Actor.h" #include "../renderer/render.h" // ID2D1Geometry namespace kiwano { - // 二维图形节点 + // 二维图形角色 class KGE_API ShapeNode : public VisualNode { @@ -144,7 +144,7 @@ namespace kiwano }; - // 矩形节点 + // 矩形角色 class KGE_API RectNode : public ShapeNode { @@ -171,7 +171,7 @@ namespace kiwano }; - // 圆角矩形节点 + // 圆角矩形角色 class KGE_API RoundedRectNode : public ShapeNode { @@ -214,7 +214,7 @@ namespace kiwano }; - // 圆形节点 + // 圆形角色 class KGE_API CircleNode : public ShapeNode { @@ -251,7 +251,7 @@ namespace kiwano }; - // 椭圆节点 + // 椭圆角色 class KGE_API EllipseNode : public ShapeNode { @@ -294,7 +294,7 @@ namespace kiwano }; - // 路径节点 + // 路径角色 class KGE_API PathNode : public ShapeNode { diff --git a/src/kiwano/2d/Sprite.cpp b/src/kiwano/2d/Sprite.cpp index dac76387..0c30462a 100644 --- a/src/kiwano/2d/Sprite.cpp +++ b/src/kiwano/2d/Sprite.cpp @@ -57,7 +57,7 @@ namespace kiwano { image_ = image; - Node::SetSize(image_->GetWidth(), image_->GetHeight()); + Actor::SetSize(image_->GetWidth(), image_->GetHeight()); return true; } return false; @@ -76,7 +76,7 @@ namespace kiwano void Sprite::Crop(const Rect& 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.y, 0.f), image_->GetSourceHeight() - image_->GetCropY()) ); diff --git a/src/kiwano/2d/Sprite.h b/src/kiwano/2d/Sprite.h index 9712750d..3374faf2 100644 --- a/src/kiwano/2d/Sprite.h +++ b/src/kiwano/2d/Sprite.h @@ -19,7 +19,7 @@ // THE SOFTWARE. #pragma once -#include "Node.h" +#include "Actor.h" #include "Image.h" namespace kiwano diff --git a/src/kiwano/2d/Scene.cpp b/src/kiwano/2d/Stage.cpp similarity index 88% rename from src/kiwano/2d/Scene.cpp rename to src/kiwano/2d/Stage.cpp index 5cb6e6a5..97d1ba25 100644 --- a/src/kiwano/2d/Scene.cpp +++ b/src/kiwano/2d/Stage.cpp @@ -18,32 +18,32 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#include "Scene.h" +#include "Stage.h" #include "../base/logs.h" #include "../renderer/render.h" namespace kiwano { - Scene::Scene() + Stage::Stage() { - scene_ = this; + stage_ = this; SetAnchor(0, 0); 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"); } } diff --git a/src/kiwano/2d/Scene.h b/src/kiwano/2d/Stage.h similarity index 91% rename from src/kiwano/2d/Scene.h rename to src/kiwano/2d/Stage.h index 207d759b..357cd58a 100644 --- a/src/kiwano/2d/Scene.h +++ b/src/kiwano/2d/Stage.h @@ -19,21 +19,21 @@ // THE SOFTWARE. #pragma once -#include "Node.h" +#include "Actor.h" namespace kiwano { // 场景 - class KGE_API Scene - : public Node + class KGE_API Stage + : public Actor { friend class Transition; - friend class Stage; + friend class Director; public: - Scene(); + Stage(); - virtual ~Scene(); + virtual ~Stage(); // 进入场景 virtual void OnEnter(); diff --git a/src/kiwano/2d/Text.h b/src/kiwano/2d/Text.h index a4a39b22..00a63ff5 100644 --- a/src/kiwano/2d/Text.h +++ b/src/kiwano/2d/Text.h @@ -19,7 +19,7 @@ // THE SOFTWARE. #pragma once -#include "Node.h" +#include "Actor.h" #include "Font.hpp" #include "TextStyle.hpp" #include diff --git a/src/kiwano/2d/Transition.cpp b/src/kiwano/2d/Transition.cpp index 13a380f8..5a40e290 100644 --- a/src/kiwano/2d/Transition.cpp +++ b/src/kiwano/2d/Transition.cpp @@ -19,8 +19,8 @@ // THE SOFTWARE. #include "Transition.h" -#include "Node.h" -#include "Scene.h" +#include "Actor.h" +#include "Stage.h" #include "../base/window.h" #include "../base/logs.h" #include "../renderer/render.h" @@ -55,7 +55,7 @@ namespace kiwano return done_; } - void Transition::Init(ScenePtr prev, ScenePtr next) + void Transition::Init(StagePtr prev, StagePtr next) { process_ = 0; 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); @@ -189,7 +189,7 @@ namespace kiwano { } - void EmergeTransition::Init(ScenePtr prev, ScenePtr next) + void EmergeTransition::Init(StagePtr prev, StagePtr 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); @@ -248,7 +248,7 @@ namespace kiwano { } - void MoveTransition::Init(ScenePtr prev, ScenePtr next) + void MoveTransition::Init(StagePtr prev, StagePtr 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); diff --git a/src/kiwano/2d/Transition.h b/src/kiwano/2d/Transition.h index 5690bab6..c313782b 100644 --- a/src/kiwano/2d/Transition.h +++ b/src/kiwano/2d/Transition.h @@ -24,13 +24,13 @@ namespace kiwano { - class Stage; + class Director; // 场景过渡 class KGE_API Transition : public Object { - friend class Stage; + friend class Director; public: explicit Transition( @@ -43,8 +43,8 @@ namespace kiwano protected: virtual void Init( - ScenePtr prev, - ScenePtr next + StagePtr prev, + StagePtr next ); virtual void Update(Duration dt); @@ -61,8 +61,8 @@ namespace kiwano Duration duration_; Duration delta_; Size window_size_; - ScenePtr out_scene_; - ScenePtr in_scene_; + StagePtr out_scene_; + StagePtr in_scene_; ComPtr out_layer_; ComPtr in_layer_; LayerProperties out_layer_prop_; @@ -84,8 +84,8 @@ namespace kiwano void Update(Duration dt) override; virtual void Init( - ScenePtr prev, - ScenePtr next + StagePtr prev, + StagePtr next ) override; }; @@ -103,8 +103,8 @@ namespace kiwano void Update(Duration dt) override; virtual void Init( - ScenePtr prev, - ScenePtr next + StagePtr prev, + StagePtr next ) override; }; @@ -122,8 +122,8 @@ namespace kiwano void Update(Duration dt) override; virtual void Init( - ScenePtr prev, - ScenePtr next + StagePtr prev, + StagePtr next ) override; }; @@ -142,8 +142,8 @@ namespace kiwano void Update(Duration dt) override; virtual void Init( - ScenePtr prev, - ScenePtr next + StagePtr prev, + StagePtr next ) override; void Reset() override; @@ -169,8 +169,8 @@ namespace kiwano void Update(Duration dt) override; virtual void Init( - ScenePtr prev, - ScenePtr next + StagePtr prev, + StagePtr next ) override; void Reset() override; diff --git a/src/kiwano/2d/include-forwards.h b/src/kiwano/2d/include-forwards.h index 620fb3da..1c0eedad 100644 --- a/src/kiwano/2d/include-forwards.h +++ b/src/kiwano/2d/include-forwards.h @@ -38,8 +38,8 @@ namespace kiwano KGE_DECLARE_SMART_PTR(GifImage); KGE_DECLARE_SMART_PTR(Frames); - KGE_DECLARE_SMART_PTR(Node); - KGE_DECLARE_SMART_PTR(Scene); + KGE_DECLARE_SMART_PTR(Actor); + KGE_DECLARE_SMART_PTR(Stage); KGE_DECLARE_SMART_PTR(Layer); KGE_DECLARE_SMART_PTR(Sprite); KGE_DECLARE_SMART_PTR(GifSprite); diff --git a/src/kiwano/base/Stage.cpp b/src/kiwano/base/Director.cpp similarity index 81% rename from src/kiwano/base/Stage.cpp rename to src/kiwano/base/Director.cpp index 6c06559e..ba9f220b 100644 --- a/src/kiwano/base/Stage.cpp +++ b/src/kiwano/base/Director.cpp @@ -18,26 +18,26 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#include "Stage.h" -#include "../2d/Node.h" -#include "../2d/Scene.h" +#include "Director.h" +#include "../2d/Actor.h" +#include "../2d/Stage.h" #include "../2d/Transition.h" #include "../2d/DebugNode.h" namespace kiwano { - Stage::Stage() + Director::Director() : 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) return; @@ -45,9 +45,9 @@ namespace kiwano 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_) { @@ -60,17 +60,17 @@ namespace kiwano } } - ScenePtr Stage::GetCurrentScene() + StagePtr Director::GetCurrentStage() { return curr_scene_; } - void Stage::SetRenderBorderEnabled(bool enabled) + void Director::SetRenderBorderEnabled(bool enabled) { render_border_enabled_ = enabled; } - void Stage::ShowDebugInfo(bool show) + void Director::ShowDebugInfo(bool show) { if (show) { @@ -83,7 +83,7 @@ namespace kiwano } } - void Stage::OnUpdate(Duration dt) + void Director::OnUpdate(Duration dt) { if (transition_) { @@ -116,7 +116,7 @@ namespace kiwano debug_node_->Update(dt); } - void Stage::OnRender() + void Director::OnRender() { if (transition_) { @@ -131,7 +131,7 @@ namespace kiwano debug_node_->Render(); } - void Stage::AfterRender() + void Director::AfterRender() { if (render_border_enabled_) { @@ -140,7 +140,7 @@ namespace kiwano } } - void Stage::HandleEvent(Event& evt) + void Director::HandleEvent(Event& evt) { if (debug_node_) debug_node_->Dispatch(evt); diff --git a/src/kiwano/base/Stage.h b/src/kiwano/base/Director.h similarity index 83% rename from src/kiwano/base/Stage.h rename to src/kiwano/base/Director.h index 1ff924c5..d05fcc62 100644 --- a/src/kiwano/base/Stage.h +++ b/src/kiwano/base/Director.h @@ -26,28 +26,28 @@ namespace kiwano { - class KGE_API Stage - : public Singleton + class KGE_API Director + : public Singleton , public Component { - KGE_DECLARE_SINGLETON(Stage); + KGE_DECLARE_SINGLETON(Director); public: // 切换场景 - void EnterScene( - ScenePtr scene /* 场景 */ + void EnterStage( + StagePtr scene /* 场景 */ ); // 切换场景 - void EnterScene( - ScenePtr scene, /* 场景 */ + void EnterStage( + StagePtr scene, /* 场景 */ TransitionPtr transition /* 场景动画 */ ); // 获取当前场景 - ScenePtr GetCurrentScene(); + StagePtr GetCurrentStage(); - // 启用或禁用场景内的节点边界渲染功能 + // 启用或禁用角色边界渲染功能 void SetRenderBorderEnabled(bool enabled); // 显示调试信息 @@ -67,15 +67,15 @@ namespace kiwano void HandleEvent(Event& evt) override; protected: - Stage(); + Director(); - virtual ~Stage(); + virtual ~Director(); protected: bool render_border_enabled_; - ScenePtr curr_scene_; - ScenePtr next_scene_; - NodePtr debug_node_; + StagePtr curr_scene_; + StagePtr next_scene_; + ActorPtr debug_node_; TransitionPtr transition_; }; } diff --git a/src/kiwano/base/Event.hpp b/src/kiwano/base/Event.hpp index 09d6d140..36dc8b9f 100644 --- a/src/kiwano/base/Event.hpp +++ b/src/kiwano/base/Event.hpp @@ -105,7 +105,7 @@ namespace kiwano void* data; }; - class Node; + class Actor; // 事件 struct KGE_API Event @@ -145,7 +145,7 @@ namespace kiwano }; UINT type; - Node* target; + Actor* target; union { diff --git a/src/kiwano/kiwano.h b/src/kiwano/kiwano.h index 720902b0..8a72f512 100644 --- a/src/kiwano/kiwano.h +++ b/src/kiwano/kiwano.h @@ -63,7 +63,7 @@ #include "base/time.h" #include "base/window.h" #include "base/input.h" -#include "base/Stage.h" +#include "base/Director.h" #include "base/logs.h" #include "renderer/render.h" #include "platform/modules.h" @@ -94,8 +94,8 @@ #include "2d/ActionManager.h" #include "2d/Transition.h" -#include "2d/Node.h" -#include "2d/Scene.h" +#include "2d/Actor.h" +#include "2d/Stage.h" #include "2d/Layer.h" #include "2d/Sprite.h" #include "2d/GifSprite.h" diff --git a/src/kiwano/platform/Application.cpp b/src/kiwano/platform/Application.cpp index 30af0120..9dbf5e2e 100644 --- a/src/kiwano/platform/Application.cpp +++ b/src/kiwano/platform/Application.cpp @@ -23,7 +23,7 @@ #include "../base/window.h" #include "../base/logs.h" #include "../base/input.h" -#include "../base/Stage.h" +#include "../base/Director.h" #include "../renderer/render.h" #include // GET_X_LPARAM, GET_Y_LPARAM #include // ImmAssociateContext @@ -66,7 +66,7 @@ namespace kiwano Use(Renderer::Instance()); Use(Input::Instance()); - Use(Stage::Instance()); + Use(Director::Instance()); } Application::~Application() @@ -100,7 +100,7 @@ namespace kiwano if (options.debug) { - Stage::Instance()->ShowDebugInfo(true); + Director::Instance()->ShowDebugInfo(true); Renderer::Instance()->SetCollectingStatus(true); } @@ -158,7 +158,7 @@ namespace kiwano } // Destroy all instances - Stage::Destroy(); + Director::Destroy(); Input::Destroy(); Renderer::Destroy(); Window::Destroy(); diff --git a/src/kiwano/ui/Button.cpp b/src/kiwano/ui/Button.cpp index 699eff81..84962b26 100644 --- a/src/kiwano/ui/Button.cpp +++ b/src/kiwano/ui/Button.cpp @@ -19,7 +19,7 @@ // THE SOFTWARE. #include "Button.h" -#include "../2d/Scene.h" +#include "../2d/Stage.h" #include "../base/window.h" namespace kiwano @@ -145,4 +145,4 @@ namespace kiwano } } -} \ No newline at end of file +} diff --git a/src/kiwano/ui/Menu.h b/src/kiwano/ui/Menu.h index a06424fc..07dc557e 100644 --- a/src/kiwano/ui/Menu.h +++ b/src/kiwano/ui/Menu.h @@ -25,7 +25,7 @@ namespace kiwano { // 菜单 class KGE_API Menu - : public Node + : public Actor { public: Menu();