增加NodeProperty结构体,可以直接获取和设置节点的所有属性

This commit is contained in:
Nomango 2018-04-21 18:42:07 +08:00
parent b2e655226b
commit c8abe14a8d
3 changed files with 58 additions and 0 deletions

View File

@ -372,6 +372,25 @@ double e2d::Node::getOpacity() const
return m_fRealOpacity; 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 e2d::Collider * e2d::Node::getCollider() const
{ {
return m_pCollider; return m_pCollider;
@ -541,6 +560,18 @@ void e2d::Node::setSize(Size size)
this->setSize(size.width, size.height); 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) void e2d::Node::setCollider(int nColliderType)
{ {
switch (nColliderType) switch (nColliderType)

View File

@ -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 class Object
{ {

View File

@ -116,6 +116,9 @@ public:
// 获取节点透明度 // 获取节点透明度
virtual double getOpacity() const; virtual double getOpacity() const;
// 获取节点属性
virtual NodeProperty getProperty() const;
// 获取节点碰撞体 // 获取节点碰撞体
virtual Collider * getCollider() const; virtual Collider * getCollider() const;
@ -311,6 +314,11 @@ public:
Size size Size size
); );
// 设置节点属性
virtual void setProperty(
NodeProperty prop
);
// 设置碰撞体 // 设置碰撞体
virtual void setCollider( virtual void setCollider(
int nColliderType int nColliderType