From c8abe14a8d49edc2e38005a224904f64c198b2fa Mon Sep 17 00:00:00 2001 From: Nomango <569629550@qq.com> Date: Sat, 21 Apr 2018 18:42:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0NodeProperty=E7=BB=93?= =?UTF-8?q?=E6=9E=84=E4=BD=93=EF=BC=8C=E5=8F=AF=E4=BB=A5=E7=9B=B4=E6=8E=A5?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=92=8C=E8=AE=BE=E7=BD=AE=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E7=9A=84=E6=89=80=E6=9C=89=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/Node/Node.cpp | 31 +++++++++++++++++++++++++++++++ core/ecommon.h | 19 +++++++++++++++++++ core/enode.h | 8 ++++++++ 3 files changed, 58 insertions(+) diff --git a/core/Node/Node.cpp b/core/Node/Node.cpp index 0b1be0bf..0e75e10a 100644 --- a/core/Node/Node.cpp +++ b/core/Node/Node.cpp @@ -372,6 +372,25 @@ double e2d::Node::getOpacity() const return m_fRealOpacity; } +e2d::NodeProperty e2d::Node::getProperty() const +{ + NodeProperty prop; + prop.visable = m_bVisiable; + prop.posX = m_fPosX; + prop.posY = m_fPosY; + prop.width = m_fWidth; + prop.height = m_fHeight; + prop.opacity = m_fRealOpacity; + prop.pivotX = m_fPivotX; + prop.pivotY = m_fPivotY; + prop.scaleX = m_fScaleX; + prop.scaleY = m_fScaleY; + prop.rotation = m_fRotation; + prop.skewAngleX = m_fSkewAngleX; + prop.skewAngleY = m_fSkewAngleY; + return prop; +} + e2d::Collider * e2d::Node::getCollider() const { return m_pCollider; @@ -541,6 +560,18 @@ void e2d::Node::setSize(Size size) this->setSize(size.width, size.height); } +void e2d::Node::setProperty(NodeProperty prop) +{ + this->setVisiable(prop.visable); + this->setPos(prop.posX, prop.posY); + this->setSize(prop.width, prop.height); + this->setOpacity(prop.opacity); + this->setPivot(prop.pivotX, prop.pivotY); + this->setScale(prop.scaleX, prop.scaleY); + this->setRotation(prop.rotation); + this->setSkew(prop.skewAngleX, prop.skewAngleY); +} + void e2d::Node::setCollider(int nColliderType) { switch (nColliderType) diff --git a/core/ecommon.h b/core/ecommon.h index 536d0337..9abe9804 100644 --- a/core/ecommon.h +++ b/core/ecommon.h @@ -464,6 +464,25 @@ struct Font }; +// 节点属性 +struct NodeProperty +{ + bool visable; // 可见性 + double posX; // X 坐标 + double posY; // Y 坐标 + double width; // 宽度 + double height; // 高度 + double opacity; // 透明度 + double pivotX; // 中心点 X 坐标 + double pivotY; // 中心点 Y 坐标 + double scaleX; // 横向缩放 + double scaleY; // 纵向缩放 + double rotation; // 旋转角度 + double skewAngleX; // 横向倾斜角度 + double skewAngleY; // 纵向倾斜角度 +}; + + // 基础对象 class Object { diff --git a/core/enode.h b/core/enode.h index 1d822e14..a271187a 100644 --- a/core/enode.h +++ b/core/enode.h @@ -116,6 +116,9 @@ public: // 获取节点透明度 virtual double getOpacity() const; + // 获取节点属性 + virtual NodeProperty getProperty() const; + // 获取节点碰撞体 virtual Collider * getCollider() const; @@ -311,6 +314,11 @@ public: Size size ); + // 设置节点属性 + virtual void setProperty( + NodeProperty prop + ); + // 设置碰撞体 virtual void setCollider( int nColliderType