增加Node::setPosFixed方法,使节点坐标固定
This commit is contained in:
parent
fe9d155779
commit
718b1b1a1a
|
|
@ -35,6 +35,7 @@ e2d::Node::Node()
|
||||||
, m_bSortChildrenNeeded(false)
|
, m_bSortChildrenNeeded(false)
|
||||||
, m_bTransformNeeded(false)
|
, m_bTransformNeeded(false)
|
||||||
, m_bAutoUpdate(true)
|
, m_bAutoUpdate(true)
|
||||||
|
, m_bPositionFixed(false)
|
||||||
{
|
{
|
||||||
if (s_fDefaultColliderEnabled)
|
if (s_fDefaultColliderEnabled)
|
||||||
{
|
{
|
||||||
|
|
@ -224,7 +225,7 @@ void e2d::Node::_updateSelfTransform()
|
||||||
// 根据自身中心点变换 Final 矩阵
|
// 根据自身中心点变换 Final 矩阵
|
||||||
m_MatriFinal = m_MatriInitial * D2D1::Matrix3x2F::Translation(-pivot.x, -pivot.y);
|
m_MatriFinal = m_MatriInitial * D2D1::Matrix3x2F::Translation(-pivot.x, -pivot.y);
|
||||||
// 和父节点矩阵相乘
|
// 和父节点矩阵相乘
|
||||||
if (m_pParent)
|
if (!m_bPositionFixed && m_pParent)
|
||||||
{
|
{
|
||||||
m_MatriInitial = m_MatriInitial * m_pParent->m_MatriInitial;
|
m_MatriInitial = m_MatriInitial * m_pParent->m_MatriInitial;
|
||||||
m_MatriFinal = m_MatriFinal * m_pParent->m_MatriInitial;
|
m_MatriFinal = m_MatriFinal * m_pParent->m_MatriInitial;
|
||||||
|
|
@ -420,6 +421,15 @@ void e2d::Node::setPos(double x, double y)
|
||||||
m_bTransformNeeded = true;
|
m_bTransformNeeded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void e2d::Node::setPosFixed(bool fixed)
|
||||||
|
{
|
||||||
|
if (m_bPositionFixed == fixed)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_bPositionFixed = fixed;
|
||||||
|
m_bTransformNeeded = true;
|
||||||
|
}
|
||||||
|
|
||||||
void e2d::Node::movePosX(double x)
|
void e2d::Node::movePosX(double x)
|
||||||
{
|
{
|
||||||
this->movePos(x, 0);
|
this->movePos(x, 0);
|
||||||
|
|
|
||||||
|
|
@ -196,6 +196,11 @@ public:
|
||||||
double y
|
double y
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 节点坐标固定
|
||||||
|
virtual void setPosFixed(
|
||||||
|
bool fixed
|
||||||
|
);
|
||||||
|
|
||||||
// 移动节点
|
// 移动节点
|
||||||
virtual void movePosX(
|
virtual void movePosX(
|
||||||
double x
|
double x
|
||||||
|
|
@ -470,6 +475,7 @@ protected:
|
||||||
bool m_bDisplayedInScene;
|
bool m_bDisplayedInScene;
|
||||||
bool m_bSortChildrenNeeded;
|
bool m_bSortChildrenNeeded;
|
||||||
bool m_bTransformNeeded;
|
bool m_bTransformNeeded;
|
||||||
|
bool m_bPositionFixed;
|
||||||
Collider * m_pCollider;
|
Collider * m_pCollider;
|
||||||
Scene * m_pParentScene;
|
Scene * m_pParentScene;
|
||||||
Node * m_pParent;
|
Node * m_pParent;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue